First, there are three different editions of Java:
- Java Standard Edition (SE)
- Java Enterprise Edition (EE)
- Javae Micro Edition (ME).
Next, Java offers several packages for installation.There are two different Java SE packages
- Java Runtime Environment (JRE) or sometimes called Java SE Runtime Edition. JRE is an implementation of the Java Virtual Machine (JVM). The JVM is the component that runs compiled Java applications and applets.
- Java Development Kit (JDK). JDK includes the JRE (and JVM) and other software that is required for developing, and compiling Java applications and applets.
Finally, thereare also two different implementations of Java: OpenJDK and Oracle Java. OpenJDK is the reference implementation of Java and is fully open source. Oracle Java was the original reference implementation and is commonly used by commercial applications. It is not surprising that commercial application require Oracle Java instead of OpenJDK. Most Java applications will work fine with either implementation. However, use the version recommended by the application being installed. If the application refers to downloading Java from Oracle, then it's likely requires Oracle Java.
Since most business application require Oracle Java, the instructions below are specifically for Oracle Java. To install OpenJDK, the steps are simpler since it can be installed directly using the yum command without downloading the installation file (Step 3). The steps are divided into several steps
- Get the download URL for the Oracle Java JRE (http://www.oracle.com/technetwork/java/javase/index.html). Accept the license.
- Download the JRE rpm file using the URL file (it should look something like this: http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jre-8u162-linux-x64.rpm). This can be done using either wget or curl.
- Using wget: wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jre-8u162-linux-x64.rpm"
- Using curl: curl -L -b "oraclelicense=a" -O http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jre-8u162-linux-x64.rpm
- Install the RPM file using YUM:
sudo yum localinstall jre-8u161-linux-x64.rpm - Confirm alternatives setting and take note of the path: sudo alternatives --config java
- Setup the environment variable for all users using the path from the step above (eg. /usr/java/jre1.8.0_161/jre):
sudo sh -c "echo export JAVA_HOME=/usr/java/jre1.8.0_161/jre >> /etc/environment"
export JAVA_HOME=/usr/java/jre1.8.0_161
export JRE_HOME=/usr/java/jre1.8.0_161/jre
export PATH=$PATH:/usr/java/jre1.8.0_161/bin:/usr/java/jre1.8.0_161/jre/bin
export JRE_HOME=/usr/java/jre1.8.0_161/jre
export PATH=$PATH:/usr/java/jre1.8.0_161/bin:/usr/java/jre1.8.0_161/jre/bin
For extra points, the jar and jac Java components can also be setup to ensure a wider range of applications can use the installed java.
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_161/bin/jar 2
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_161/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_161/bin/jar
alternatives --set javac /opt/jdk1.8.0_161/bin/javac
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_161/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_161/bin/jar
alternatives --set javac /opt/jdk1.8.0_161/bin/javac
No comments:
Post a Comment