CentOS 7
Sponsored Link

JDK 11 : Install
2018/10/17
 
Install Java SE Development Kit 11 (JDK 11) and build Java Environment.
[1] Download and install JDK 11.
Make sure the latest version and source URL of JDK on Oracle download site.
⇒ https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html

JDK 11 release notes are the follows.
⇒ https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html
[root@dlp ~]#
curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.rpm"
[root@dlp ~]#
rpm -Uvh jdk-11.0.1_linux-x64_bin.rpm

warning: jdk-11.0.1_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-11.0.1-2000:11.0.1-ga        ################################# [100%]

[root@dlp ~]#
java -version

java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
[root@dlp ~]#
vi /etc/profile.d/jdk11.sh
# create new

export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
[root@dlp ~]#
source /etc/profile.d/jdk11.sh
[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/java/jdk-11.0.1/bin/java
   2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java)

Enter to keep the current selection[+], or type selection number: 1
[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);
    }
}

# possible to run java file

[root@dlp ~]#
java day.java

2018/10/16 19:15
# also possible to run after compile

[root@dlp ~]#
javac day.java

[root@dlp ~]#
java day

2018/10/16 19:18
Matched Content
 
Tweet