OracleJDK (Installing): Difference between revisions

From HPC Wiki
Jump to:navigation Jump to:search
(Created page with "Instructions and tips for installing the {{C|Oracle SE JDK}} in a users account. Each user can install software in their own account, without any extra permissions. {{WIP|aut...")
 
(Initial commit)
Line 1: Line 1:
Instructions and tips for installing the {{C|Oracle SE JDK}} in a users account. Each user can install software in their own account, without any extra permissions.
{{WIP|author=bgo}}
 
Instructions and tips for installing the {{C|Oracle SE JDK}} in a users account. Since this is a binary package, installing is fairly straightforward. Each user can install software in their own account, without any extra permissions. These instructions are specifically for version ''8u181'', but should work just the same for any other version.  


{{WIP|author=bgo}}
__TOC__


= Download =
= Download =
Line 7: Line 9:
To download the software, google [//www.google.com/search?safe=off&q={{urlencode:oracle jdk downloads}} oracle jdk downloads], or go directly to the [//www.oracle.com/technetwork/java/javase/downloads/index.html download page].
To download the software, google [//www.google.com/search?safe=off&q={{urlencode:oracle jdk downloads}} oracle jdk downloads], or go directly to the [//www.oracle.com/technetwork/java/javase/downloads/index.html download page].


Once on the download page, scroll down to the desired version and click on the {{C|JDK Download}} button. From there you'll be presented with a page containing a section similar to this:
Once on the download page, scroll down to the desired version and click on the ''JDK Download'' button. From there you'll be presented with a page containing a section similar to this:


[[File:OracleJDK-Download-8u181.png]]
[[File:OracleJDK-Download-8u181.png]]


{{C|Oracle}} requires users to accept a license before they can download, accept the license by click on the button, shown hightlighted in the top orange box on the image above.
== Accept License ==
 
{{C|Oracle}} requires users to accept a license before being allowed to download; accept the license by clicking on the ''Accept License Agreement'' button, shown highlighted by the top orange box in the image above.
 
== Download Correct Version ==
 
Now that we have accepted the license, we can download the JDK. Look for the ''Linux x64'' version, and the filename ending in ''tar.gz''. The second orange box in the image above shows the appropriate file to download. Click the appropriate file and download it to you computer.
 
== Copy Package to Magnolia ==
 
Copy the download file from your computer to Magnolia is beyond the scope of this article, but for help try googling [//www.google.com/search?safe=off&q={{urlencode:how to use scp}} how to use scp] if you are on Linux or a Mac, or [//www.google.com/search?safe=off&q={{urlencode:how to use PuTTY}} how to use PuTTY] if you are on a Windows machine.
 
= Installing =
 
We assume that the user has [[#Copy_Pakage_to_Magnolia|copied]] the ''JDK'' file to their home directory. After [[Connect_to_Magnolia|connecting to Magnolia]], check that the file is there with:
 
{{Cmd|ls -lh *.tar.gz|output=<pre>
-rw-r--r-- 1 users users 178M Sep 28 17:39 jdk-8u181-linux-x64.tar.gz
</pre>}}
 
Since in all likelihood we will be needing to install additional packages in our accounts, lets make a directory where we will put all the packages we install. Make a directory called {{Path|Installed}} and move into that directory:
 
{{Cmd|mkdir Installed|cd Installed}}
 
== Extracting Files from the Package ==
 
Now that we are in the {{Path|Installed}} directory, extract all the files from the ''JDK'' package we downloaded:
 
{{Cmd|tar xlvf ../jdk-8u181-linux-x64.tar.gz}}
 
A long list of files will scroll past as they are extracted. Once the extraction is complete, listing the directory contents shows that a new directory has been created:
 
{{Cmd|ls|output=<pre>jdk1.8.0_181</pre>}}
 
Looking inside the new directory we see a bunch files, along with more directories:
 
{{Cmd|ls jdk1.8.0_181|output=<pre>
bin            lib          src.zip
COPYRIGHT      LICENSE      THIRDPARTYLICENSEREADME-JAVAFX.txt
include        man          THIRDPARTYLICENSEREADME.txt
javafx-src.zip  README.html
jre            release
</pre>}}
 
When installing packages on Linux, a few directories are common, namely: {{Path|bin}}, {{Path|lib}}, {{Path|include}}, and {{Path|man}}. We see that all of these exist, which is good. The {{Path|bin}} directories usually contain the binaries that we run, so let see what is there:
 
{{Cmd|ls jdk1.8.0_181/bin|output=<pre>
appletviewer  javafxpackager  jdb      jrunscript    pack200      unpack200
ControlPanel  javah          jdeps    jsadebugd    policytool  wsgen
extcheck      javap          jhat    jstack        rmic        wsimport
idlj          javapackager    jinfo    jstat        rmid        xjc
jar          java-rmi.cgi    jjs      jstatd        rmiregistry
jarsigner    javaws          jmap    jvisualvm    schemagen
java          jcmd            jmc      keytool      serialver
javac        jconsole        jmc.ini  native2ascii  servertool
javadoc      jcontrol        jps      orbd          tnameserv
</pre>}}
 
Now we see some programs we are expecting: {{C|java}} and {{C|javac}}. Lets try the programs and make sure the versions are correct:
 
{{Cmd|java -version|output=<pre>
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
</pre>}}
 
{{Cmd|javac version|output=<pre>
javac 1.8.0_131
</pre>}}
 
Both {{C|java}} and {{C|javac}} run, but they are not the version we expected: ''1.8.0_131'' instead of ''1.8.0_181''. This is because we have not told Linux where to find the new programs, and instead ran the default system installed {{C|java}} and {{C|javac}} programs. We can see exactly which programs were run by using the {{C|which}} command:
 
{{cmd|which java javac|output=<pre>
/usr/bin/java
/usr/bin/javac
</pre>}}
 
We see that the programs in the {{Path|/usr/bin}} directory were run, where we want to use the programs in {{Path|$HOME/Installed/jdk1.8.0_181/bin}} ($HOME is a variable that expands to each users home directory). Luckily, this is easy to fix by using the ''$PATH'' variable.
 
{{Cmd|export PATH=$HOME/Installed/jdk1.8.0_181/bin:$PATH|which java javac|output=<pre>
~/Installed/jdk1.8.0_181/bin/java
~/Installed/jdk1.8.0_181/bin/javac
</pre>}}
 
{{Cmd|java -version|output=<pre>
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
</pre>}}
 
{{Cmd|javac -version|output=<pre>
javac 1.8.0_181
</pre>}}

Revision as of 12:03, 3 October 2018

Warning
This page is a work in progress by bgo (talk | contribs). Treat its contents with caution.

Instructions and tips for installing the Oracle SE JDK in a users account. Since this is a binary package, installing is fairly straightforward. Each user can install software in their own account, without any extra permissions. These instructions are specifically for version 8u181, but should work just the same for any other version.

Download

To download the software, google oracle jdk downloads, or go directly to the download page.

Once on the download page, scroll down to the desired version and click on the JDK Download button. From there you'll be presented with a page containing a section similar to this:

Accept License

Oracle requires users to accept a license before being allowed to download; accept the license by clicking on the Accept License Agreement button, shown highlighted by the top orange box in the image above.

Download Correct Version

Now that we have accepted the license, we can download the JDK. Look for the Linux x64 version, and the filename ending in tar.gz. The second orange box in the image above shows the appropriate file to download. Click the appropriate file and download it to you computer.

Copy Package to Magnolia

Copy the download file from your computer to Magnolia is beyond the scope of this article, but for help try googling how to use scp if you are on Linux or a Mac, or how to use PuTTY if you are on a Windows machine.

Installing

We assume that the user has copied the JDK file to their home directory. After connecting to Magnolia, check that the file is there with:

user $ls -lh *.tar.gz
-rw-r--r-- 1 users users 178M Sep 28 17:39 jdk-8u181-linux-x64.tar.gz

Since in all likelihood we will be needing to install additional packages in our accounts, lets make a directory where we will put all the packages we install. Make a directory called Installed and move into that directory:

user $mkdir Installed
user $cd Installed

Extracting Files from the Package

Now that we are in the Installed directory, extract all the files from the JDK package we downloaded:

user $tar xlvf ../jdk-8u181-linux-x64.tar.gz

A long list of files will scroll past as they are extracted. Once the extraction is complete, listing the directory contents shows that a new directory has been created:

user $ls
jdk1.8.0_181

Looking inside the new directory we see a bunch files, along with more directories:

user $ls jdk1.8.0_181
bin             lib          src.zip
COPYRIGHT       LICENSE      THIRDPARTYLICENSEREADME-JAVAFX.txt
include         man          THIRDPARTYLICENSEREADME.txt
javafx-src.zip  README.html
jre             release

When installing packages on Linux, a few directories are common, namely: bin, lib, include, and man. We see that all of these exist, which is good. The bin directories usually contain the binaries that we run, so let see what is there:

user $ls jdk1.8.0_181/bin
appletviewer  javafxpackager  jdb      jrunscript    pack200      unpack200
ControlPanel  javah           jdeps    jsadebugd     policytool   wsgen
extcheck      javap           jhat     jstack        rmic         wsimport
idlj          javapackager    jinfo    jstat         rmid         xjc
jar           java-rmi.cgi    jjs      jstatd        rmiregistry
jarsigner     javaws          jmap     jvisualvm     schemagen
java          jcmd            jmc      keytool       serialver
javac         jconsole        jmc.ini  native2ascii  servertool
javadoc       jcontrol        jps      orbd          tnameserv

Now we see some programs we are expecting: java and javac. Lets try the programs and make sure the versions are correct:

user $java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
user $javac version
javac 1.8.0_131

Both java and javac run, but they are not the version we expected: 1.8.0_131 instead of 1.8.0_181. This is because we have not told Linux where to find the new programs, and instead ran the default system installed java and javac programs. We can see exactly which programs were run by using the which command:

user $which java javac
/usr/bin/java
/usr/bin/javac

We see that the programs in the /usr/bin directory were run, where we want to use the programs in $HOME/Installed/jdk1.8.0_181/bin ($HOME is a variable that expands to each users home directory). Luckily, this is easy to fix by using the $PATH variable.

user $which java javac
~/Installed/jdk1.8.0_181/bin/java
~/Installed/jdk1.8.0_181/bin/javac
user $java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
user $javac -version
javac 1.8.0_181