After Ubuntu is installed, we need to install and configure the Java environment to support the running of other jre-based software. So install and configure the Java environment immediately after Ubuntu is installed. Next we will teach you how to achieve this goal step by step.
Download jdk. The current version is the jdk-8u45. Select a version suitable for your system to Download. After the version is downloaded, put it in the Download directory.
Then press Ctrl + Alt + t to open the terminal to enter the Download directory, and unzip it using the tar-xf jdk-8u45-linux-x64.tar.gz command, run sudo cp-r jdk1.8.0 _ 45 // usr/lib/and enter the password to copy it to the/usr/lib directory. You can run the ls/usr/lib/jdk1.8.0 _ 45 command to check whether the copy has been successfully copied.
Run sudo gedit/etc/profile to open the/etc/profile file, and add the following three lines at the end of the file:
Export JAVA_HOME =/usr/lib/jdk1.8.0 _ 45
Export CLASSPATH =.: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib: $ CLASSPATH
Export PATH = $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin: $ PATH
If you follow the first two steps correctly, the above three rows can be copied directly.
Finally, Ctrl + s is saved.
Enter the command sudo source/etc/profile to make it take effect, and then use the command java-version. If you see the java version information, it indicates that the installation is successful. However, only the thread of the terminal that has run the sudo source/etc/profile command can use Java environment variables, while other threads are not. After the restart, you can do it all.
Install jdk in ubuntu and set java environment variables in ubuntu
Download jdk-6u12-linux-i586.bin,
Start to install jdk:
Use the terminal to enter the directory where the jdk-6u12-linux-i586.bin is stored, my location is:/home/liujicheng/java
Step 1: Change permissions; default files do not have executable permissions
Chmod g + x jdk-6u12-linux-i586.bin
Step 2: install
Sudo-s./jdk-6u12-linux-i586.bin
After the installation is complete, configure the environment variables below
Configure classpath and modify the environment variables of all users
$ Sudo vi/etc/profile or $ sudo gedit/etc/profile
Add at the end of the file
# Set java environment
JAVA_HOME =/home/liujicheng/java/jdk1.6.0 _ 12
Export JRE_HOME =/home/liujicheng/java/jdk1.6.0 _ 12/jre
Export CLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH
Export PATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH
Restart the computer and run the command to test the jdk Version.
Java-version
The following information is displayed: The installation is successful.
Java version "1.6.0 _ 12"
Java (TM) SE Runtime Environment (build 1.6.0 _ 12-b04)
Java HotSpot (TM) Server VM (build 11.2-b01, mixed mode)