If you want to create Java Program in Ubuntu, the first thing is to configuring JDK. And that what this page will tell you.
-
JDK preparing
Above all, prepare a tar.gz JDK package. If you don't want to download it from the official website, a mirror website is a good choice: http://repo.huaweicloud.com/java/jdk.
You can use wget
or VMware shared folders or even a U-disk to put it into your Ubuntu disk.
Ubuntu:~$ ls /home/user/temp
jdk-8u212-linux-x64.tar.gz
And here I prepared a jdk-8u212-linux-x64.tar.gz
in /home/user/temp
.
-
Archive unpacking
Use the command:
Ubuntu:~$ tar -zxf /home/user/temp/jdk-8u212-linux-x64.tar.gz -C unpackpath
The parameter unpackpath
after -C
is to indicate the path of your unpacked files or folders.
-
Environment variables configuration
Use the command:
Ubuntu:~$ sudo vim /etc/profile
open the file and add the following content to it:
JAVA_HOME=unpackpath/jdk1.8.0_212
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
and then use the command:
Ubuntu:~$ sudo source /etc/profile
to validate the modification.
-
Configuration confirming
Use the command:
Ubuntu:~$ java -version
to confirm the jdk and java version, if you configured it successfully, the interface will be shown as:
java version "1.8.0_212"
Java(TM) SE Runtime Environment (Build 1.8.0_212-b10)
Java HotSpot(TM) 64Bit Server VM (build 25.212-b10, mixed mode)