Howto install Oracle (Sun) Java JRE for Linux Mint

Koja
  12 years ago
  26

In this tutorial you can read how to configure java and the java browser plugin.


1. Open up the Terminal (Applications > Accessories > Terminal).

2. Copy/Paste or type the following line of code into Terminal and then press enter:

3. First remove every openjdk package including icedtea-plugin:

sudo apt-get update && apt-get remove openjdk-6-jre

Because libreoffice needs openjdk, your mint linux will automatically install openjdk-7 dependencies.
That would not be any problem for this tutorial.

Just because you can and it's recommended:

sudo apt-get autoremove && apt-get clean

All unnecessary packages will be removed.

Install JAVA

Download the tar.gz java package for linux on www.java.com and store the file in the folder Downloads.
(if you have Linux x64, download the x64 bit package, do not download the RPM!!)

1. In your terminal, run the command thats create a new subfolder in the directory opt.

2. Check if you want to create a x64 or 32 bit java directory.

  32 Bit version:

sudo mkdir -p -v /opt/java/32

  64-Bit version:

sudo mkdir -p -v /opt/java/64

3. Go to your download folder (where you have downloaded java).

4. Unpack it to the created subfolder.

  32 Bit version:

cd ~/Downloads
tar -zxvf jre-7u9-linux-i586.tar.gz
sudo mv -v jre1.7.0_* /opt/java/32

  64-Bit version:

cd ~/Downloads
tar -zxvf jre-7u9-linux-x64.tar.gz
sudo mv -v jre1.7.0_* /opt/java/64

5. The last step is to make the new JRE as default: (Check if you have 32 or x64)

  32 Bit version:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/32/jre1.7.0_09/bin/java" 1

sudo update-alternatives --set java /opt/java/32/jre1.7.0_09/bin/java

  64-Bit version:

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.7.0_09/bin/java" 1

sudo update-alternatives --set java /opt/java/64/jre1.7.0_09/bin/java

Install the Firefox Plugin

1. Make for every user in his home directory a subfolder:

mkdir -v ~/.mozilla/plugins

2. Create a symbolic link, so Firefox knows where to find the java plug-in.

  32-Bit version:

ln -s /opt/java/32/jre1.7.0_09/lib/i386/libnpjp2.so ~/.mozilla/plugins/

  64-Bit version:

ln -s /opt/java/64/jre1.7.0_09/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

3. Now you have to restart the browser and check in Firefox if the installation has been succeeded.

Type in the browser: about:plugins

TIP!!

A good thing to do is to set a maximum amount of disk space for the cache.

/opt/java/32/jre1.7.0_09/bin/ControlPanel

/opt/java/64/jre1.7.0_09/bin/ControlPanel

Click on settings under temporary Internet files and set amount the disk space to 50MB.

Note: do this step for every user account.

Comments
jahid_0903014 8 years ago

You can automate the task of installing Java (JDK/JRE) completely using this script


dickheijkoop 9 years ago

Thank you very much, worked great for me!


eyedat 9 years ago

Thank you !!! nice Work!


scriptx 10 years ago

Here is a more complete version:
http://community.linuxmint.com/tutorial/view/1839

This version:
* Allows for easy updating
* Updates more of the various jdk executables (ie: jar, keytool, servertool, etc)
* Has a fancy helper tool to help with the 'update-alternatives' commands!
* Does not allow for multi-versioning by default but you can modify the guide to make it so


krustybaguette 10 years ago

under Install the Firefox plugin the instructions should mention the need to close the browser while creating the symbolic link.


slackjp 10 years ago

The procedure presented by xfrank works fine. Thanks.

To install Java without going to the terminal this is what I did (I have LMDE 64bit):
Just added few minor tweaks (working fine in Linux 16.0 Mate).

1 - download the latest jre from the Oracle site
2 - uncompress it and put all the files and folders in a selected directory: It's better under /opt/java7 folder (but anywhere will work). Need to right-click for administrative rights to create and copy such folder.
3 - Search inside (in my case in jre1.7.0_60/lib/amd64) for the file libnpjp2.so
4 - Create a symlynk to libnpjp2.so by right-clicking on it
5 - Copy the symlink you created
6 - Go to the directory /usr/lib/mozilla/plugins (with administrative rights) and paste here the symlynk; you may change to libnpjp2.so
7 - That's all, java will work.
8 - This setup also works for Opera (Opera makes use of Mozilla plugins)
9 - Upcoming Java7 versions should just be overwriting all the contents of the /opt/java7 folder. The symlink will work without changes. In Java8 may work or not. Nevertheless, I am able to pay taxes again in Linux.


philsoft 10 years ago

nice easy install for us newbies thanks


xfrank 10 years ago

To install Java without going to the terminal this is what I did (I have LMDE 64bit):

1 - download the latest jre from the Oracle site
2 - uncompress it and put the files in /home in a .java directory
3 - search inside (in my case in jre1.7.0_51/lib/amd64) for the file libnpjp2.so
4 - create a symlynk to libnpjp2.so by clinking on it
5 - copy the symlink you created
6 - go to the directory usr/lib/mozilla/plugins and paste here the symlynk
7 - that's all, java will work


way12go 11 years ago

Goto Menu
click on internet
see google chrome
add google chrome to panel
right click on google chrome icon in panel
and choose edit
it will show
Application ... something like this
[[[ /opt/google/chrome/google-chrome %U ]]]

Now open terminal and copy paste enter this

/opt/google/chrome/google-chrome --allow-outdated-plugins

Application ... something like this
[[[ /opt/google/chrome/google-chrome %U ]]] add --allow-outdated-plugins

Finally you need this command in terminal

/opt/google/chrome/google-chrome --allow-outdated-plugins


lonnie333 11 years ago

I agree w/ uvlt:

"I think that everything goes easier by installing java, via ppa...
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html"

It did go much easier using the above link, rather than this intructional. Issues: Files were not found, root console was required for some commands, files did not copy. ppa was easy to follow and worked with no issues.


krustybaguette 11 years ago

getting nowhere fast with installing Java. I've followed this tutorial and others and had to remove all traces of java...or at least attempt to before starting each attempt to install. Getting it installed is no problem but installing the plugin just isn't working for me.
Currently I have jre1.7.0_21 at /usr/lib/jvm/jre1.7.0_21 linked to libnpjp2.so at /usr/lib/firefox/plugins
I'm so frustrated by this that I'm considering a complete reinstallation of Mint and that's no fun either ;-(


uvlt 11 years ago

I think that everything goes easier by installing java, via ppa...
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html


jbqld 11 years ago

as nobody has responded subetha & although I'm only a beginner, could I suggest you check which version you're installing and edit the name to match. The latest version I installed just this week was jre-7u17-linux-x64.tar.gz
(for 64bit) so I had to use:
tar zxvf jre-7u17-linux-x64.tar.gz


fatd 11 years ago

how do i reverse this? (uninstall all of these) my netbeans isn't working now


jbqld 11 years ago

Thanks Koja ... your instructions were clear enough for a beginner to follow; much appreciated :)


efthialex 11 years ago

It is really helpful! Thanks!


vinzg 11 years ago

Hello, if have to update to java _13 version or 14 15 etc

get latest java version then

sudo -i

tar -zxvf jre-7u13-linux-i586.tar.gz 7u13 or7u14 ...

cd /opt/java/32

rm -r jre1.7.0_12 or you older java folder

sudo mv -v jre1.7.0_13 /opt/java/32

cd /usr/lib/firefox/plugins

rm libnpjp2.so so you delete older link

ln -s /opt/java/32/jre1.7.0_13/lib/i386/libnpjp2.so /usr/lib/firefox/plugins

then from firefox preferences you have to set on JNLP file javaws

from open

opt java/32/jre1.7.0_13/bin and select javaws

so firefox can open jnlp file!

i spent time to fix this, i think can help







jammarra 11 years ago

Thank, it works, but already 1.7.0_10

P.S. add Chrome and Opera
Chrome:

sudo mkdir /opt/google/chrome/plugins && sudo ln -s /opt/java/64/jre1.7.0_10/lib/amd64/libnpjp2.so /opt/google/chrome/plugins

Opera: ctrl+f12

Advanced > Content > Plug-in Optins > Change Path :
/opt/java/64/jre1.7.0_10/lib/amd64/

and "Find New"


vinzg 11 years ago

Hello, after some problems; i solved creating this symbolic link


ln -s /opt/java/32/jre1.7.0_10/lib/i386/libnpjp2.so /usr/lib/firefox/plugins


jbqld 11 years ago

Thanks a million Koja, I've been hitting my head on the desk for weeks now, trying to get my favourite games site to work, the applets kept timing out before they finished loading, but having just followed your excellent instructions, it works like a charm! the only thing I needed to change was the version, from jre1.7.0_09 to jre1.7.0_10.


steenl 11 years ago

Works even in Debian Mint.


Koja 12 years ago

I have included the SUDO command and sepperate the 32 and x64 bit version commands. Last but not least, the lay-out is a little bit better so. Thanks Veoden for your comment!


Veoden 12 years ago

Perfect. Works fine to me. I only suggest that the command SUDO is included.