|
9 years ago 7 |
This tutorial is a more complete version of the existing tutorials at:
http://community.linuxmint.com/tutorial/view/1372
http://community.linuxmint.com/tutorial/view/1091
http://tutorialforlinux.com/how-to-install-oracle-jdk-on-linux-distros-easy-guides/
I recommend installing Oracle JDK using this guide because updating to a new JDK version is an extremely simple 3-step process.
# If you need to Update your Oracle JDK version, click here.
# If you wish to Install Oracle JDK, continue on the first section.
# Get the update-alternatives helper tool here.
# Quickly jump to the update-alternatives section.
Note: At the time of writing the current 64bit version was jdk-7u67-linux-x64.tar.gz.
Change the commands below to use the correct filename which you have downloaded.
The installation for JRE is very similar but probably not 100% compatible with this guide.
1. Open up a new Terminal window: Menu -> Accessories -> Terminal
Typically for Gnome you can also do: Alt + F2 -> gnome-terminal -> Enter
Typically for KDE you can also do: Alt + F2 -> konsole -> Enter
2. Remove the current OpenJDK or IcedTea installation(s).
# Remove everything unrelated to Oracle Java:
## OpenJDK JDK/JRE, IcedTea JDK/JRE/browser-plugin, and GCJ JDK/JRE
sudo apt-get update
sudo apt-get remove openjdk* icedtea* default-jre default-jdk gcj-jre gcj-jdk icedtea-{6..7}-plugin icedtea-plugin
# clean up
sudo apt-get autoremove
sudo apt-get autoclean
3. Using your browser, download Oracle JDK from here.
Choose the correct version for your system architecture: 32-bit (x86) or 64bit (x64).
Download the Linux version which ends in the ".tar.gz" extension. Not the ".rpm" file.
Download the file into your Downloads directory.
For example /home/YOUR_USERNAME/Downloads
You can use the following command to determine which JDK version to download:
uname -m
If you see "x86_64" (amd64, ia64, alpha, or any other 64bit string) you need to download the 64bit JDK version. Otherwise, download the 32bit version.
4. Within the Terminal, change directory to where the JDK was downloaded (in my case ~/Downloads) and copy the .tar.gz file into /opt/java .
cd ~/Downloads
sudo cp jdk-7u67-linux-x64.tar.gz /opt/java/
5. Create and change directory to /opt/java and extract the .tar.gz file there.
sudo mkdir -p /opt/java
cd /opt/java
sudo tar -zxvf jdk-7u67-linux-x64.tar.gz
6. Create a sym-link for the current JDK version.
By pointing `current-java' to the folder containing the current JDK version you can make the update process easier.
sudo rm -f /opt/java/current-java
sudo ln -s /opt/java/jdk1.7.0_67 /opt/java/current-java
# /opt/java/current-java now points to /opt/java/jdk1.7.0_67
# if you need to update the jdk version, simply delete current-java and recreate it so that is points to the folder containing the most recent version of java
# here are the complete instructions for updating to a new JDK version
7. Make Oracle JDK the system default. Note that these are all using the "/opt/java/current-java" sym-link.
When a new version comes out you only change 1 simple setting so that, for example, `current-java' points to `jdk2.0' (or any other version you wish to use).
You only have to update your system configuration files using the commands in this section once because it always expects the find the latest version of Java located at `/opt/java/current-java' ... and it does!
By using this symlink method you only need to execute the following commands once.
Note: the following commands can be obtained or changed quickly by executing the helper.tool script as described in the next section
# 1. su to root
su
# 2. create a new textfile & chmod
cd /opt/java && touch inst.cmds && chmod +x inst.cmds
# 3. open the new textfile
# choose your favorite text editor:
gedit inst.cmds #recommended method
nano inst.cmds #alternate method
vi inst.cmds #alternate method
# etc...
# 4. copy the 'update-alternatives' commands below
# 5. paste the commands into the inst.cmds textfile
# 6. save the inst.cmds textfile
# 7. execute the inst.cmds file to update your system java settings
/bin/bash inst.cmds
rm inst.cmds
update-alternatives --install /usr/bin/jexec jexec /opt/java/current-java/lib/jexec 1065 && sleep 1s
update-alternatives --set jexec /opt/java/current-java/lib/jexec && sleep 1s
update-alternatives --install /usr/bin/appletviewer appletviewer /opt/java/current-java/bin/appletviewer 1065 && sleep 1s
update-alternatives --set appletviewer /opt/java/current-java/bin/appletviewer && sleep 1s
update-alternatives --install /usr/bin/apt apt /opt/java/current-java/bin/apt 1065 && sleep 1s
update-alternatives --set apt /opt/java/current-java/bin/apt && sleep 1s
# the file /opt/java/current-java/bin/ControlPanel was ignored
update-alternatives --install /usr/bin/extcheck extcheck /opt/java/current-java/bin/extcheck 1065 && sleep 1s
update-alternatives --set extcheck /opt/java/current-java/bin/extcheck && sleep 1s
update-alternatives --install /usr/bin/idlj idlj /opt/java/current-java/bin/idlj 1065 && sleep 1s
update-alternatives --set idlj /opt/java/current-java/bin/idlj && sleep 1s
update-alternatives --install /usr/bin/jar jar /opt/java/current-java/bin/jar 1065 && sleep 1s
update-alternatives --set jar /opt/java/current-java/bin/jar && sleep 1s
update-alternatives --install /usr/bin/jarsigner jarsigner /opt/java/current-java/bin/jarsigner 1065 && sleep 1s
update-alternatives --set jarsigner /opt/java/current-java/bin/jarsigner && sleep 1s
update-alternatives --install /usr/bin/java java /opt/java/current-java/bin/java 1065 && sleep 1s
update-alternatives --set java /opt/java/current-java/bin/java && sleep 1s
update-alternatives --install /usr/bin/javac javac /opt/java/current-java/bin/javac 1065 && sleep 1s
update-alternatives --set javac /opt/java/current-java/bin/javac && sleep 1s
update-alternatives --install /usr/bin/javadoc javadoc /opt/java/current-java/bin/javadoc 1065 && sleep 1s
update-alternatives --set javadoc /opt/java/current-java/bin/javadoc && sleep 1s
update-alternatives --install /usr/bin/javafxpackager javafxpackager /opt/java/current-java/bin/javafxpackager 1065 && sleep 1s
update-alternatives --set javafxpackager /opt/java/current-java/bin/javafxpackager && sleep 1s
update-alternatives --install /usr/bin/javah javah /opt/java/current-java/bin/javah 1065 && sleep 1s
update-alternatives --set javah /opt/java/current-java/bin/javah && sleep 1s
update-alternatives --install /usr/bin/javap javap /opt/java/current-java/bin/javap 1065 && sleep 1s
update-alternatives --set javap /opt/java/current-java/bin/javap && sleep 1s
update-alternatives --install /usr/bin/java-rmi.cgi java-rmi.cgi /opt/java/current-java/bin/java-rmi.cgi 1065 && sleep 1s
update-alternatives --set java-rmi.cgi /opt/java/current-java/bin/java-rmi.cgi && sleep 1s
update-alternatives --install /usr/bin/javaws javaws /opt/java/current-java/bin/javaws 1065 && sleep 1s
update-alternatives --set javaws /opt/java/current-java/bin/javaws && sleep 1s
update-alternatives --install /usr/bin/jcmd jcmd /opt/java/current-java/bin/jcmd 1065 && sleep 1s
update-alternatives --set jcmd /opt/java/current-java/bin/jcmd && sleep 1s
update-alternatives --install /usr/bin/jconsole jconsole /opt/java/current-java/bin/jconsole 1065 && sleep 1s
update-alternatives --set jconsole /opt/java/current-java/bin/jconsole && sleep 1s
update-alternatives --install /usr/bin/jcontrol jcontrol /opt/java/current-java/bin/jcontrol 1065 && sleep 1s
update-alternatives --set jcontrol /opt/java/current-java/bin/jcontrol && sleep 1s
update-alternatives --install /usr/bin/jdb jdb /opt/java/current-java/bin/jdb 1065 && sleep 1s
update-alternatives --set jdb /opt/java/current-java/bin/jdb && sleep 1s
update-alternatives --install /usr/bin/jhat jhat /opt/java/current-java/bin/jhat 1065 && sleep 1s
update-alternatives --set jhat /opt/java/current-java/bin/jhat && sleep 1s
update-alternatives --install /usr/bin/jinfo jinfo /opt/java/current-java/bin/jinfo 1065 && sleep 1s
update-alternatives --set jinfo /opt/java/current-java/bin/jinfo && sleep 1s
update-alternatives --install /usr/bin/jmap jmap /opt/java/current-java/bin/jmap 1065 && sleep 1s
update-alternatives --set jmap /opt/java/current-java/bin/jmap && sleep 1s
update-alternatives --install /usr/bin/jmc jmc /opt/java/current-java/bin/jmc 1065 && sleep 1s
update-alternatives --set jmc /opt/java/current-java/bin/jmc && sleep 1s
update-alternatives --install /usr/bin/jmc.ini jmc.ini /opt/java/current-java/bin/jmc.ini 1065 && sleep 1s
update-alternatives --set jmc.ini /opt/java/current-java/bin/jmc.ini && sleep 1s
update-alternatives --install /usr/bin/jps jps /opt/java/current-java/bin/jps 1065 && sleep 1s
update-alternatives --set jps /opt/java/current-java/bin/jps && sleep 1s
update-alternatives --install /usr/bin/jrunscript jrunscript /opt/java/current-java/bin/jrunscript 1065 && sleep 1s
update-alternatives --set jrunscript /opt/java/current-java/bin/jrunscript && sleep 1s
update-alternatives --install /usr/bin/jsadebugd jsadebugd /opt/java/current-java/bin/jsadebugd 1065 && sleep 1s
update-alternatives --set jsadebugd /opt/java/current-java/bin/jsadebugd && sleep 1s
update-alternatives --install /usr/bin/jstack jstack /opt/java/current-java/bin/jstack 1065 && sleep 1s
update-alternatives --set jstack /opt/java/current-java/bin/jstack && sleep 1s
update-alternatives --install /usr/bin/jstat jstat /opt/java/current-java/bin/jstat 1065 && sleep 1s
update-alternatives --set jstat /opt/java/current-java/bin/jstat && sleep 1s
update-alternatives --install /usr/bin/jstatd jstatd /opt/java/current-java/bin/jstatd 1065 && sleep 1s
update-alternatives --set jstatd /opt/java/current-java/bin/jstatd && sleep 1s
update-alternatives --install /usr/bin/jvisualvm jvisualvm /opt/java/current-java/bin/jvisualvm 1065 && sleep 1s
update-alternatives --set jvisualvm /opt/java/current-java/bin/jvisualvm && sleep 1s
update-alternatives --install /usr/bin/keytool keytool /opt/java/current-java/bin/keytool 1065 && sleep 1s
update-alternatives --set keytool /opt/java/current-java/bin/keytool && sleep 1s
update-alternatives --install /usr/bin/native2ascii native2ascii /opt/java/current-java/bin/native2ascii 1065 && sleep 1s
update-alternatives --set native2ascii /opt/java/current-java/bin/native2ascii && sleep 1s
update-alternatives --install /usr/bin/orbd orbd /opt/java/current-java/bin/orbd 1065 && sleep 1s
update-alternatives --set orbd /opt/java/current-java/bin/orbd && sleep 1s
update-alternatives --install /usr/bin/pack200 pack200 /opt/java/current-java/bin/pack200 1065 && sleep 1s
update-alternatives --set pack200 /opt/java/current-java/bin/pack200 && sleep 1s
update-alternatives --install /usr/bin/policytool policytool /opt/java/current-java/bin/policytool 1065 && sleep 1s
update-alternatives --set policytool /opt/java/current-java/bin/policytool && sleep 1s
update-alternatives --install /usr/bin/rmic rmic /opt/java/current-java/bin/rmic 1065 && sleep 1s
update-alternatives --set rmic /opt/java/current-java/bin/rmic && sleep 1s
update-alternatives --install /usr/bin/rmid rmid /opt/java/current-java/bin/rmid 1065 && sleep 1s
update-alternatives --set rmid /opt/java/current-java/bin/rmid && sleep 1s
update-alternatives --install /usr/bin/rmiregistry rmiregistry /opt/java/current-java/bin/rmiregistry 1065 && sleep 1s
update-alternatives --set rmiregistry /opt/java/current-java/bin/rmiregistry && sleep 1s
update-alternatives --install /usr/bin/schemagen schemagen /opt/java/current-java/bin/schemagen 1065 && sleep 1s
update-alternatives --set schemagen /opt/java/current-java/bin/schemagen && sleep 1s
update-alternatives --install /usr/bin/serialver serialver /opt/java/current-java/bin/serialver 1065 && sleep 1s
update-alternatives --set serialver /opt/java/current-java/bin/serialver && sleep 1s
update-alternatives --install /usr/bin/servertool servertool /opt/java/current-java/bin/servertool 1065 && sleep 1s
update-alternatives --set servertool /opt/java/current-java/bin/servertool && sleep 1s
update-alternatives --install /usr/bin/tnameserv tnameserv /opt/java/current-java/bin/tnameserv 1065 && sleep 1s
update-alternatives --set tnameserv /opt/java/current-java/bin/tnameserv && sleep 1s
update-alternatives --install /usr/bin/unpack200 unpack200 /opt/java/current-java/bin/unpack200 1065 && sleep 1s
update-alternatives --set unpack200 /opt/java/current-java/bin/unpack200 && sleep 1s
update-alternatives --install /usr/bin/wsgen wsgen /opt/java/current-java/bin/wsgen 1065 && sleep 1s
update-alternatives --set wsgen /opt/java/current-java/bin/wsgen && sleep 1s
update-alternatives --install /usr/bin/wsimport wsimport /opt/java/current-java/bin/wsimport 1065 && sleep 1s
update-alternatives --set wsimport /opt/java/current-java/bin/wsimport && sleep 1s
update-alternatives --install /usr/bin/xjc xjc /opt/java/current-java/bin/xjc 1065 && sleep 1s
update-alternatives --set xjc /opt/java/current-java/bin/xjc && sleep 1s
######## system config for /opt/java/current-java/jre/bin/
###########################################
# the file /opt/java/current-java/bin/ControlPanel was ignored
update-alternatives --install /usr/bin/java_vm java_vm /opt/java/current-java/jre/bin/java_vm 1065 && sleep 1s
update-alternatives --set java_vm /opt/java/current-java/jre/bin/java_vm && sleep 1s
##############################
# alternate steps / old version / least recommended method
# 1. copy and paste the commands into a terminal window and press enter
8. Test installed Java version.
user@computer ~ $ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
9. Optional: Install the Firefox plugin by linking libnpjp2.so file to ~/.mozilla/plugins folder and restart the browser.
You must use the correct architecture: 64bit: amd64 or 32bit: i386
mkdir -p ~/.mozilla/plugins
ln -s /opt/java/current-java/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
# if you have a 32bit version, change "amd64" to "i386"
10. Update either the main system configuration or your own user configuration file.
# The following will set up important environment variables for use with Java and Java applications.
# Option 1 - System-wide settings - This is the option I chose
# To edit the system's bashrc configuration:
# (choose your favorite text editor)
sudo gedit /etc/bash.bashrc #recommended method
sudo nano /etc/bash.bashrc #alternate method
sudo vi /etc/bash.bashrc #alternate method
# etc...
############################ OR ###############################
# Option 2 - User-only
# To edit your own user's bashrc configuration:
# (choose your favorite text editor)
gedit ~/.bashrc #recommended method
nano ~/.bashrc #alternate method
vi ~/.bashrc #alternate method
# etc...
And then copy and paste the following:
Please let me know if you encounter any issues with the following code.
############ $CLASS_PATH
CLASS_PATH="$CLASS_PATH"
if ! [[ "$CLASS_PATH" =~ ^:*(.*:+)*\.{1}(:+.*)*$ ]]; then
CLASS_PATH="$CLASS_PATH":.
fi
if ! [[ "$CLASS_PATH" =~ ^:*(.*:+)*\.{2}(:+.*)*$ ]]; then
CLASS_PATH="$CLASS_PATH":..
fi
export CLASS_PATH
############ $JAVA_HOME
JAVA_HOME="$JAVA_HOME"
if ! [[ "$JAVA_HOME" =~ ^:*(.*:+)*/opt/java/current-java{1}(:+.*)*$ ]]; then
JAVA_HOME="$JAVA_HOME":/opt/java/current-java
fi
export JAVA_HOME
############ $PATH
# this appears to work for me, if you encounter issues you could
# simply hard-code $JAVA_HOME/bin into the PATH var
PATH="$PATH"
regex="^:*(.*:+)*($JAVA_HOME/bin){1}(:+.*)*$"
if ! [[ "$PATH" =~ $regex ]]; then
PATH="$PATH:$JAVA_HOME/bin"
fi
export PATH
For example here is the first 10 lines of my /etc/bash.bashrc file:
user@computer ~ $ head -n 10 /etc/bash.bashrc
# System-wide .bashrc file for interactive bash(1) shells.
##################################################
# Added Oct 2, 2014
# Provide correct paths/environment variables for Oracle JDK
# see /home/user/system_changes.txt
##################################################
############ $CLASS_PATH
CLASS_PATH="$CLASS_PATH" #create CLASS_PATH if it doesnt exist already
if ! [[ "$CLASS_PATH" =~ ^:*(.*:+)*\.{1}(:+.*)*$ ]]; then # if C_P *does not* contain . add it
...... the rest of the file ......
11. Optional. Sym-link the man pages so you can view the various manpages:
eg: man jinfo; man javac; man jarsigner; man javaws
# su to root
su
# cd and create file
cd /opt/java && touch manpagelinker.tool && chmod +x manpagelinker.tool
# copy the text below and paste it into the linker.tool file
# (choose your favorite text editor)
gedit manpagelinker.tool #recommended method
nano manpagelinker.tool #alternate method
vi manpagelinker.tool #alternate method
# etc...
# execute the linker.tool file
/bin/bash manpagelinker.tool
# optional, you can re-use this file if need to delete or re-link the manpages
rm manpagelinker.tool
######################################
######################################
ln -s /opt/java/current-java/man/man1/appletviewer.1 /usr/share/man/man1/appletviewer.1
ln -s /opt/java/current-java/man/man1/apt.1 /usr/share/man/man1/apt.1
ln -s /opt/java/current-java/man/man1/extcheck.1 /usr/share/man/man1/extcheck.1
ln -s /opt/java/current-java/man/man1/idlj.1 /usr/share/man/man1/idlj.1
ln -s /opt/java/current-java/man/man1/jar.1 /usr/share/man/man1/jar.1
ln -s /opt/java/current-java/man/man1/jarsigner.1 /usr/share/man/man1/jarsigner.1
ln -s /opt/java/current-java/man/man1/java.1 /usr/share/man/man1/java.1
ln -s /opt/java/current-java/man/man1/javac.1 /usr/share/man/man1/javac.1
ln -s /opt/java/current-java/man/man1/javadoc.1 /usr/share/man/man1/javadoc.1
ln -s /opt/java/current-java/man/man1/javafxpackager.1 /usr/share/man/man1/javafxpackager.1
ln -s /opt/java/current-java/man/man1/javah.1 /usr/share/man/man1/javah.1
ln -s /opt/java/current-java/man/man1/javap.1 /usr/share/man/man1/javap.1
ln -s /opt/java/current-java/man/man1/javaws.1 /usr/share/man/man1/javaws.1
ln -s /opt/java/current-java/man/man1/jcmd.1 /usr/share/man/man1/jcmd.1
ln -s /opt/java/current-java/man/man1/jconsole.1 /usr/share/man/man1/jconsole.1
ln -s /opt/java/current-java/man/man1/jdb.1 /usr/share/man/man1/jdb.1
ln -s /opt/java/current-java/man/man1/jhat.1 /usr/share/man/man1/jhat.1
ln -s /opt/java/current-java/man/man1/jinfo.1 /usr/share/man/man1/jinfo.1
ln -s /opt/java/current-java/man/man1/jmap.1 /usr/share/man/man1/jmap.1
ln -s /opt/java/current-java/man/man1/jmc.1 /usr/share/man/man1/jmc.1
ln -s /opt/java/current-java/man/man1/jps.1 /usr/share/man/man1/jps.1
ln -s /opt/java/current-java/man/man1/jrunscript.1 /usr/share/man/man1/jrunscript.1
ln -s /opt/java/current-java/man/man1/jsadebugd.1 /usr/share/man/man1/jsadebugd.1
ln -s /opt/java/current-java/man/man1/jstack.1 /usr/share/man/man1/jstack.1
ln -s /opt/java/current-java/man/man1/jstat.1 /usr/share/man/man1/jstat.1
ln -s /opt/java/current-java/man/man1/jstatd.1 /usr/share/man/man1/jstatd.1
ln -s /opt/java/current-java/man/man1/jvisualvm.1 /usr/share/man/man1/jvisualvm.1
ln -s /opt/java/current-java/man/man1/keytool.1 /usr/share/man/man1/keytool.1
ln -s /opt/java/current-java/man/man1/native2ascii.1 /usr/share/man/man1/native2ascii.1
ln -s /opt/java/current-java/man/man1/orbd.1 /usr/share/man/man1/orbd.1
ln -s /opt/java/current-java/man/man1/pack200.1 /usr/share/man/man1/pack200.1
ln -s /opt/java/current-java/man/man1/policytool.1 /usr/share/man/man1/policytool.1
ln -s /opt/java/current-java/man/man1/rmic.1 /usr/share/man/man1/rmic.1
ln -s /opt/java/current-java/man/man1/rmid.1 /usr/share/man/man1/rmid.1
ln -s /opt/java/current-java/man/man1/rmiregistry.1 /usr/share/man/man1/rmiregistry.1
ln -s /opt/java/current-java/man/man1/schemagen.1 /usr/share/man/man1/schemagen.1
ln -s /opt/java/current-java/man/man1/serialver.1 /usr/share/man/man1/serialver.1
ln -s /opt/java/current-java/man/man1/servertool.1 /usr/share/man/man1/servertool.1
ln -s /opt/java/current-java/man/man1/tnameserv.1 /usr/share/man/man1/tnameserv.1
ln -s /opt/java/current-java/man/man1/unpack200.1 /usr/share/man/man1/unpack200.1
ln -s /opt/java/current-java/man/man1/wsgen.1 /usr/share/man/man1/wsgen.1
ln -s /opt/java/current-java/man/man1/wsimport.1 /usr/share/man/man1/wsimport.1
ln -s /opt/java/current-java/man/man1/xjc.1 /usr/share/man/man1/xjc.1
12. Log out and log back in (or restart your pc) so the environment variables are properly initialized.
Don't forget to frequently check the Java website for updates!
This is a manual installation and it does not get automatically updated!
Back to top
Back to Update
Back to Install
This section assumes that you have already installed the JDK using the Installation section of this guide.
cd ~/Downloads
sudo cp jdk-latest.tar.gz /opt/java/
sudo mkdir -p /opt/java
cd /opt/java && ls -lah jdk*.tar.gz
sudo tar -zxvf jdk-latest.tar.gz
sudo rm current-java
sudo ln -s /opt/java/jdk-latest-version-folder /opt/java/current-java
# change jdk-latest-version-folder to the correct version/folder name which you just extracted from the .tar.gz file
5. Test that your new version works:
user@computer ~ $ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
user@computer ~ $ update-alternatives --get-selections | grep java
appletviewer manual /opt/java/current-java/bin/appletviewer
apt manual /opt/java/current-java/bin/apt
extcheck manual /opt/java/current-java/bin/extcheck
idlj manual /opt/java/current-java/bin/idlj
jar manual /opt/java/current-java/bin/jar
jarsigner manual /opt/java/current-java/bin/jarsigner
java manual /opt/java/current-java/bin/java
javac manual /opt/java/current-java/bin/javac
javadoc manual /opt/java/current-java/bin/javadoc
javafxpackager manual /opt/java/current-java/bin/javafxpackager
javah manual /opt/java/current-java/bin/javah
javap manual /opt/java/current-java/bin/javap
java-rmi.cgi manual /opt/java/current-java/bin/java-rmi.cgi
java_vm manual /opt/java/current-java/jre/bin/java_vm
javaws manual /opt/java/current-java/bin/javaws
jcmd manual /opt/java/current-java/bin/jcmd
jconsole manual /opt/java/current-java/bin/jconsole
jcontrol manual /opt/java/current-java/bin/jcontrol
jdb manual /opt/java/current-java/bin/jdb
jexec manual /opt/java/current-java/lib/jexec
jhat manual /opt/java/current-java/bin/jhat
jinfo manual /opt/java/current-java/bin/jinfo
jmap manual /opt/java/current-java/bin/jmap
jmc manual /opt/java/current-java/bin/jmc
jmc.ini manual /opt/java/current-java/bin/jmc.ini
jps manual /opt/java/current-java/bin/jps
jrunscript manual /opt/java/current-java/bin/jrunscript
jsadebugd manual /opt/java/current-java/bin/jsadebugd
jstack manual /opt/java/current-java/bin/jstack
jstat manual /opt/java/current-java/bin/jstat
jstatd manual /opt/java/current-java/bin/jstatd
jvisualvm manual /opt/java/current-java/bin/jvisualvm
keytool manual /opt/java/current-java/bin/keytool
native2ascii manual /opt/java/current-java/bin/native2ascii
orbd manual /opt/java/current-java/bin/orbd
pack200 manual /opt/java/current-java/bin/pack200
policytool manual /opt/java/current-java/bin/policytool
rmic manual /opt/java/current-java/bin/rmic
rmid manual /opt/java/current-java/bin/rmid
rmiregistry manual /opt/java/current-java/bin/rmiregistry
schemagen manual /opt/java/current-java/bin/schemagen
serialver manual /opt/java/current-java/bin/serialver
servertool manual /opt/java/current-java/bin/servertool
tnameserv manual /opt/java/current-java/bin/tnameserv
unpack200 manual /opt/java/current-java/bin/unpack200
wsgen manual /opt/java/current-java/bin/wsgen
wsimport manual /opt/java/current-java/bin/wsimport
xjc manual /opt/java/current-java/bin/xjc
Back to top
Back to Update
Back to Install
This is just a quick'n'dirty script I put together, its not meant to be comprehensive
helper.tool code is available at http://pastebin.com/1qG17YND
Here's a tool I used to enumerate all the appropriate 'update-alternatives' commands:
# After you have created the helper.tool file try executing this command for more information:
./helper.tool -h
# or
./helper.tool -e
# 1. Recommended steps:
# su to root
su
# 2. execute these commands:
cd /opt/java/current-java
touch helper.tool && chmod +x helper.tool
touch out.txt && chmod +x out.txt
# 3. copy and paste the helper.tool code into the helper.tool file & save
# (choose your favorite text editor)
gedit helper.tool #recommended method
nano helper.tool #alternate method
vi helper.tool #alternate method
# etc...
# 4. run helper.tool & get the install commands
./helper.tool -i > out.txt
# Now the textfile called "out.txt" contains a list of commands
# The commands inside "out.txt" are the same commands listed in Step 7 of the installation section above
# By executing the commands in step 5 below, you are executing the same commands listed in Step 7 of the installation section above
# 5. then, as root:
/bin/bash out.txt
rm out.txt
# 6. optional, delete the helper.tool file
# you might need to update your java settings later on, the tool can make it a little bit easier
rm helper.tool
# now your JDK executables should be symlinked and installed correctly
##############################################
# Check your settings:
update-alternatives --get-selections | grep java
# they should all be pointed to /opt/java/current-java/...
##############################################
## If you need to uninstall / remove what was just installed do this:
su
cd /opt/java/current-java
touch helper.tool && chmod +x helper.tool
touch out.txt && chmod +x out.txt
# now copy and paste the helper.tool code into the "helper.tool" file... then execute it like this:
./helper.tool -r > out.txt
/bin/bash out.txt
rm out.txt
helper.tool code:
helper.tool code is available at http://pastebin.com/1qG17YND
Exactly what i needed, fixed my AndroidStudio issu "Use Oracle JDK instead of OpenJDK for better performances." or something like that.
Awesome tuto. But on step 4 before to copy you need to:
sudo mkdir -p /opt/java
(instead of doing it on step 5 you should do it on step 4).
Thx a lot. Great work and helps a lot. The helper tool is very good.
Some small quirks though with step 10:
My env ended up like this:
CLASS_PATH=:.:..
JAVA_HOME=:/opt/java/current-java
PATH=
Not sure if the CLASS_PATH is as intended but seems useful.
But JAVA_HOME is a problem, though easily fixed.
Otherwise great so far. Thx.
Thanks guys! I've updated /opt/java/current-jdk to /opt/java/current-java
brinktastee: I've fixed all the problems you've pointed out thank you for the comment! :)
I'm not sure when/why the helper.tool code got truncated so I've removed it completely... the code can be found at the Pastebin URL.
1 mkdir -p ~/.mozzila/plugins should be ...mozilla...
2 out.out is this supposed to be out.txt?
3. helper.tool code is incomplete? Need to use a supplied url.
It's listed in step 7
You missed the most important part!
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.8.0_25/bin/java" 1
sudo update-alternatives --set java /opt/java/jdk1.8.0_25/bin/java
You can create the directory using
sudo mkdir -p /opt/java
I've updated the guide too, sorry for the confusion.
nice and comprehensive