Virtual machine-install JDK + environment variable configuration + verification (record)

(1) Prepare the storage location/installation directory folder:

Enter the terminal environment in the virtual machine:
use this command [su root] to enter the login password and press Enter to enter the super user root , which has more privileges.
Insert picture description here
** Use the command [mkdir usr] to create the usr folder: mkdir is the designated command for creating a folder.
Insert picture description here
Create a java folder in the usr folder: to store jdk files
[cd usr] means to enter the folder named usr
[cd …] to take a step back
Insert picture description here

Go to the java folder and go back one step; go
to the usr folder and go back one step;
at this time, both the usr and java folders exist, and you can enter the java folder through [cd usr/java]:
Insert picture description here
At this time, The usr folder exists, you can create a new folder k with the following command.
Insert picture description here
If there is no usr folder, an error will be reported (it was not checked whether the usr folder exists at first)
Insert picture description here

(2) Prepare the network environment for downloading the jdk file:
(Note, there is a text on the Internet that downloads on the virtual machine, I chose to download on the host for the actual operation, here is only a record, no specific explanation)

Set the network status:
(1) Find the network adapter:
Insert picture description here
(2) Click to enter [Settings]
Insert picture description here
(3) Set to [Bridge Mode]
Insert picture description here

(3) Download on the host:

1. Download a transfer tool, XShell. Its role is to transfer files before windows and linux.
(Remarks, there are articles on the Internet that use the XShell tool, and the tool is not used in the actual operation here, so no record)

2. Download jdk from the official website
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
(1) Log in to the Oracle account:
Insert picture description here

Insert picture description here
Check the QQ mailbox, click the "reset password" in the email,
Insert picture description here
Insert picture description here
Insert picture description here
a page appears, fill in the password twice as instructed, the second time is used to confirm the password, and then click confirm, the following page will appear, indicating that the change is successful.
Insert picture description here
After the login is successful, download
Insert picture description here
appears
Insert picture description here
and click on the file in the corresponding directory.
Insert picture description here
Note that the file suffix ".tar.gz" here is the final file
Insert picture description here
. You can see the installation package file in the storage directory, and the JDK download is successful.
Insert picture description here
Insert picture description here
(4) Formally install the JDK for the virtual machine
(1) Perform some tests:
Go back to the virtual machine , find the usr folder through the desktop icon, and enter the java folder:
Insert picture description here
(there is a lock here, permission is required)
Insert picture description here
Compress the downloaded jdk The package is pulled into the java folder
(note: this part cannot be implemented)

(2) The root user who enters the terminal, as mentioned earlier, the root user has more permissions, and copy the jdk file here.
Enter the command "cp+space+directory where the file is located+space+the directory to be copied to+enter" as shown in the figure,
Insert picture description here
enter ll (the lowercase letter of LL in English) and press Enter:
Enter to view: as shown in the figure, there is no file, it may be What are the limitations of the "cp" command.
Insert picture description here
In the end, the reason was found that the directory of the java folder was incomplete. As shown in the figure, the directory was completed and the contents displayed in the total proved to have been successfully copied to the java folder.
Insert picture description here
Or click to view through the desktop:
Insert picture description here
(3) Unzip, the command is as follows
tar+Space+-zxvf+Space+File to unzip
Insert picture description here
Decompression is complete: Enter [ls] to view
Insert picture description here
(4) Configure environment variables
Enter the command as shown in the figure to enter the vi or vim interface:

Insert picture description here
or
Insert picture description here

Command notes for VIm: (Sorted from top to bottom according to common usage)
insert: i
Save and exit: 【Esc】+【:】+【wq】+Enter
Exit normally: 【Esc】+【:】+【q】+Enter
Exit without saving: 【Esc】+【:】+【q!】+Enter
Force exit: 【Esc】+【:】+【!】+Enter

Press [i] to enter the editing state, pull the mouse wheel to the bottom of the vi interface, and add the following commands to configure the environment (the vim interface needs to manually press [PgDn] on the keyboard to reach the bottom)
Insert picture description here

Enter the command as shown in the figure to make the profile file effective
Insert picture description here

To verify: enter [java -version] or [javac]
Insert picture description here
Insert picture description here
End of this article!

Guess you like

Origin blog.csdn.net/m0_46015143/article/details/113028231