(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.
** Use the command [mkdir usr] to create the usr folder: mkdir is the designated command for creating a folder.
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
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]:
At this time, The usr folder exists, you can create a new folder k with the following command.
If there is no usr folder, an error will be reported (it was not checked whether the usr folder exists at first)
(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:
(2) Click to enter [Settings]
(3) Set to [Bridge Mode]
(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:
Check the QQ mailbox, click the "reset password" in the email,
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.
After the login is successful, download
appears
and click on the file in the corresponding directory.
Note that the file suffix ".tar.gz" here is the final file
. You can see the installation package file in the storage directory, and the JDK download is successful.
(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:
(there is a lock here, permission is required)
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,
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.
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.
Or click to view through the desktop:
(3) Unzip, the command is as follows
tar+Space+-zxvf+Space+File to unzip
Decompression is complete: Enter [ls] to view
(4) Configure environment variables
Enter the command as shown in the figure to enter the vi or vim interface:
or
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)
Enter the command as shown in the figure to make the profile file effective
To verify: enter [java -version] or [javac]
End of this article!