OracleJDK (Installing): Difference between revisions
m (Removed WIP tag) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
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. | 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. | ||
Line 25: | Line 23: | ||
== Copy Package to Magnolia == | == Copy Package to Magnolia == | ||
Copying the download file from your computer to Magnolia is beyond the scope of this article, but for help try googling [//www.google.com/search? | Copying the download file from your computer to Magnolia is beyond the scope of this article, but for help try googling [//www.google.com/search?q={{urlencode:how to use scp}} how to use scp] if you are on Linux or a Mac, or [//www.google.com/search?q={{urlencode:how to use WinSCP}} how to use WinSCP] if you are on a Windows machine. | ||
= Installing = | = Installing = | ||
Line 126: | Line 124: | ||
= Final Setup = | = Final Setup = | ||
We have successfully modified the | We have successfully modified the {{V|PATH}} variable so that our installed version of ''Oracle JDK'' is used, however this is only active for the current login session. If we were to logout then back in again, we would find the the {{V|PATH}} variable has gone back to its original value. To make the {{V|PATH}} variable changes persistent across logins we need to edit the {{C|.bashrc}} file. Following the directions [[Initial_Setup#The_.bashrc_File|here]], add the following three lines to the bottom of your {{C|.bashrc}}: | ||
{{FileBox|title=(additional lines to add)|filename=${HOME}/.bashrc|1= | {{FileBox|title=(additional lines to add)|filename=${HOME}/.bashrc|1= | ||
Line 134: | Line 132: | ||
}} | }} | ||
The | The {{V|MANPATH}} variable defines the search path for manuals that are commonly installed with packages on Linux, they are usually in a {{Path|man}} directory. Setting the {{V|MANPATH}} variable enables commands like {{C|man javac}} to bring up the manual for {{C|javac}}. The variable {{V|JAVA_HOME}}, is commonly needed when compiling packages that depend on {{C|java}}. You can now logout then back in, and find that the version you installed is now active, check it with the {{C|which}} command as show above. | ||
[[Category:Installing Programs]] | [[Category:Installing Programs]] |
Latest revision as of 12:23, 18 October 2018
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.
The general outline below can be used to install any binary package. Packages that need to be compiled, however, require a few extra steps.
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
Copying 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 WinSCP 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 account, 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
Exploring what was Extracted
Looking inside the new directory we see a bunch of 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.
Testing the New Programs
Lets try the programs we just extracted 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, but 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.
Setting Up the New PATH
Modify the PATH variable, then check the java and javac binaries with the which command:
user $
export PATH=$HOME/Installed/jdk1.8.0_181/bin:$PATH
user $
which java javac
~/Installed/jdk1.8.0_181/bin/java ~/Installed/jdk1.8.0_181/bin/javac
Testing Again
The correct binaries are now used ('~' is a shortcut for $HOME), lets check that the proper versions run:
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
The correct versions of java and javac now work. We have successfully installed a package in our account! The next section will make sure the changes we made are persistent across logins.
Final Setup
We have successfully modified the PATH variable so that our installed version of Oracle JDK is used, however this is only active for the current login session. If we were to logout then back in again, we would find the the PATH variable has gone back to its original value. To make the PATH variable changes persistent across logins we need to edit the .bashrc file. Following the directions here, add the following three lines to the bottom of your .bashrc:
export PATH=$HOME/Installed/jdk1.8.0_181/bin:$PATH export MANPATH=~/Installed/jdk1.8.0_181/man:$MANPATH export JAVA_HOME=$HOME/Installed/jdk1.8.0_181
The MANPATH variable defines the search path for manuals that are commonly installed with packages on Linux, they are usually in a man directory. Setting the MANPATH variable enables commands like man javac to bring up the manual for javac. The variable JAVA_HOME, is commonly needed when compiling packages that depend on java. You can now logout then back in, and find that the version you installed is now active, check it with the which command as show above.