Install JDK 92017/09/25 |
Install Java SE Development Kit 9 (JDK9) and build Java Environment.
|
|
[1] | Download and install JDK 9. Make sure the latest version and source URL of JDK on Oracle download site. |
[root@dlp ~]#
[root@dlp ~]# curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/9+181/jdk-9_linux-x64_bin.rpm" rpm -Uvh jdk-9_linux-x64_bin.rpm Preparing... ################################# [100%] Updating / installing... 1:jdk-9-2000:9-ga ################################# [100%] Unpacking JAR files... plugin.jar... javaws.jar... deploy.jar...[root@dlp ~]# java -version java version "9" Java(TM) SE Runtime Environment (build 9+181) Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
[root@dlp ~]#
vi /etc/profile # add follows to the end
export JAVA_HOME=/usr/java/default export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar source /etc/profile
|
[2] | If another version of JDK had been installed, change the default like follows. |
[root@dlp ~]# alternatives --config java There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/bin/java 2 /usr/java/jdk-9/bin/java # select the latest one Enter to keep the current selection[+], or type selection number: 2 |
[3] | Create a test program and make sure if it works normally. |
[root@dlp ~]#
vi day.java import java.util.Calendar; class day { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; int day = cal.get(Calendar.DATE); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); System.out.println(year + "/" + month + "/" + day + " " + hour + ":" + minute); } } # compile [root@dlp ~]# javac day.java # run [root@dlp ~]# java day 2017/9/26 19:47 |
Sponsored Link |
|