56syja
Last Updated: February 25, 2016
·
825
· kingsleyadio
Dsc 0466 01 01

Installing Oracle JDK on linux

So, probably your system is preconfigured with the OpenJDK or it doesnt even have any JDK installed at all, this process wi help you setup the oracle JDK for your linux machine.
You can get the latest JDK here if you dont already have it.
The latest version as of this writing is 7u25<br>
So, the first thing is to extract the JDK from its archive using this command: tar xzf jdk-7u25-linux-i586.tar.gz. You should have amd64 instead of i586 if you are running a 64 bit machine.<br>
Next is to move the extracted folder to the /opt directory using sudo mv jdk_1.7.0_25 /opt/. It is advisable to have a /opt/java folder so that some system files that need java can easily find it, so we will create a symlink to our java folder using this command sudo ln -s /opt/jdk_1.7.0_25 /opt/java. This also has the advantage that when you update your java version, you wont need to go through all this stress again, you just have to do sudo rm -rf /opt/java and sudo ln -s /opt/jdk_xxxx /opt/java again, and you are good to go.
Okay, so add this new path to the list of system paths by editing the /etc/profile file.
sudo gedit /etc/profile and add the following lines:<br>
JAVA_HOME=/opt/java<br>
PATH=$PATH:$JAVA_HOME/bin<br>
export JAVA_HOME<br>
export PATH<br>
Save and close after this. Use the command source /etc/profile to reload the system environment so that our new java would be available to use.
Next, we update system java to point to this one we just installed. Use the command sudo update-alternatives --config xx where xx would be java, javac, and javaws, and select the appropriate ones accordingly.<br>
You should have the oracle java working by now, and you can check using java -version.<br><br>
If you need to activate the newly installed java for your web browsers, then use the following steps.<br>
for chrome, cd /opt/google/chrome<br>
for mozilla, cd /usr/lib/mozilla<br>
then, sudo mkdir plugins. Ignore any error message and cd plugins<br>
Remove the java plugin if it already exists using sudo rm -rf libnpjp2.so<br>
Next is to link it with our new java plugin using sudo ln -s /opt/java/jre/lib/xx/libnpjp2.so where xx is either i586 or amd64 depending on the platform/java you installed.<br>
You can then restart your browser, and voila! the java plugin has been successfully installed.

Say Thanks
Respond

2 Responses
Add your response

7385
81609937c20aeab3598aea56f1f4f022

Who still uses Java in the browser? I mean, other than enterprise plugins, who needs or wants it?

over 1 year ago ·
7478
6658dbb9a55122f84902c03846038920

The text is for developers.

over 1 year ago ·
Filed Under