They offer different flash templates with latest features.
Login

Forgot password
Register
Back
Written by:
dudko
Score: 29
votes: 37
Format: Article

 How to install Oracle JDK on Linux Mint


Unlinke JRE, Java Development Kit includes various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.

Tutorial about How to install JRE for Linux Mint is almost identical for JDK.

Mint comes with a OpenJDK version of java libraries, which shouldn't be used for example Android development. [1]


1. Open up the Terminal (Alt + F2 > Terminal).

2. Remove OpenJDK installation.

sudo apt-get update && apt-get remove openjdk*

3. Download Oracle JDK from here. You are looking for a linux version with tar.gz extension. Also choose the right version from 32-bit (x86)  and 64bit (x64) one.

4. Change directory into one with downloaded tarball. In my case $HOME/Downloads.

cd ~/Downloads

5. Extract tarball. Replace with a name of dowloaded file. (just press Tab and it will be autocompleted.)

tar -zxvf jdk-

6. As a root create a folder in /opt where jdk will be stored.

sudo mkdir -p /opt/java

7. Move extracted folder to /opt/java. In my case, version number was 1.7.0_25.

sudo mv jdk1.7.0_25 /opt/java

8. Make JDK system default.

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_25/bin/java" 1
sudo update-alternatives --set java /opt/java/jdk1.7.0_25/bin/java


9. Test installed java version.

$ java -version
java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

Optinaly install firefox plugin by linking libnpjp2.so file to ~/.mozzila/plugins folder.

mkdir -p ~/.mozzila/plugins
ln -s /opt/java/jdk1.7.0_25/jre/lib/amd64/libnpjp2.so ~/.mozzila/plugins/


Tags: java jdk oracle firefox plugin
Created: 5 years ago.
Last edited: 5 years ago.
Reviewed: 5 years ago.


Comments
8 months ago

drjwsimmons
In step 8, I found I didn't need the update-alternatives --set call. The --install call did everything I needed.

The JDK installation has several other programs besides java, such as javac, javadoc, and javap. I made a shell script of update-alternatives --install calls for each of them and ran that as root to finish the installation.
 
8 months ago

drjwsimmons
To the previous user: I suspect that the problem is that you literally copied and pasted jdk1.7.0_25 when you were actually installing a different version. Try using the actual directory name created when you unpacked the tarball.  
11 months ago

SamuelHimself
I get the following error;
update-alternatives: error: alternative path /opt/java/jdk1.7.0_25/bin/java doesn't exist

Please help
 
1 year ago

rtiwari95
@matpil
Thanks for your help
 
1 year ago

matpil
@rtiwari95
Hi, you need to use sudo also on the second part of the command:
sudo apt-get update && sudo apt-get remove openjdk*

Another "issue":
For mozilla plugin the commands are:
mkdir -p ~/.mozila/plugins
ln -s /opt/java/jdk1.7.0_25/jre/lib/amd64/libnpjp2.so ~/.mozila/plugins/

regards
 
1 year ago

rtiwari95
i have a problem
showing this after entering first command please help!
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
 
1 year ago

yonito
Good job dudko and wolfred.It worked for me.
Linux Mint 18-1 "Serena" Mate 64 bit
java version 1.8.0_112
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
Appreciate it guys!!
 
1 year ago

xWolf
Thanks a lot for this great tutorial.
Easy to understand and it worked for me.
Mint 17.3 KDE now
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

Thanks
 
2 years ago

L30n1d45
Nicely written, works like charm. Thank you!!  
2 years ago

eliaskas
Very nice info... Thank's!  
2 years ago

wolfred
I have a problem when i run "Javac":

$ javac
The program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install

So i installed default-jdk from the software manager and problem SOLVED.

In this tutorial it explain another way to solve this problem.

http://www.tecmint.com/install-java-jdk-jre-in-linux/

$ update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.8.0_101/bin/javac 100
$ update-alternatives --config javac
 
2 years ago

srbiotik
Very nice tutorial, thank you sir :)  
2 years ago

RVA_Dom
thank you!  
2 years ago

iammag
Very usefull !  
2 years ago

Kail3913
thank you!  
2 years ago

Dineshkm
Nice tutorial
thank you
 
2 years ago

smokin-moe
Kernel: 3.19.0-32-generic x86_64 (64 bit)
Desktop: Cinnamon 2.8.8
Distro: Linux Mint 17.3 Rosa

jdk-8u91-linux-x64.tar.gz

java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)


Worked for me. Thankyou :)
 
2 years ago

dgbutterworth
I followed the Tutorial that describes how to install using the ppa created by webupd8.org. (Search for the that article.)  
2 years ago

thevaliantx
There are simpler ways to get Java onto the machine than this convoluted article shows.  
2 years ago

Hack06
Thank you!  
2 years ago

flurbius
The instructions are a bit terse, there is plenty of room for stuff to go wrong,
for instance:
I have a non standard location for my downloads even though I fixed it so that it still looks like it is under my home directory so when i did your step 5 I got a mass of errors that quickly zipped off the screen and if I hadnt noticed them would have left my Java folder short of a couple of hundred of the most important files, I looked in the folder and it had lots of stuff there so thought maybe they had been warnings went and had a look it was a permission thing I went back to step 5 and added sudo to the beginning of your first line and it went thru.

Also in your final Optinal(sic) step you have mispelled mozilla - not sure if thats an issue actually but makes me a bit suspicious that you didnt actually run those commands - just typed them here. And there is simply not enough information there to know how the .mozilla/plugins folder will be used and by who, I had a look around and firefox has a couple of plugins directories but not there, and will this work for multiple users or just me?

This is all intended as constructive criticism, I appreciate the effort you put into it, I just dont want anyone to come to grief because of it.

cheers
 
2 years ago

Gameranand
Thanks a lot. Worked perfectly :)  
3 years ago

callagg2
Excellent tutorial...worked perfectly on LMDE
thank you
 
3 years ago

jahid_0903014
@aroneasadas 
Check out this method: http://neurobin.github.io/OracleJDKInstaller/
 
3 years ago

aroneasadas
your instructions are not that good. Any one cant understand what you said thus can not completely install jdk with out any problems . just copy paste wont work so its not a good one  
3 years ago

kewi
Second the comment from sbrbot.
This guide works good but the other is easier to maintain.
 
3 years ago

sbrbot
Here is another (I must say better) article about how to install Oracle JDK because it suggest creating "current-java" folder which allows easier upgrade of JDK version.

http://community.linuxmint.com/tutorial/view/1839
 
3 years ago

aovchinn
You need another sudo in first command

sudo apt-get update && sudo apt-get remove openjdk*
 
3 years ago

jahid_0903014
you can automate this task with this script  
3 years ago

fuzzyanalysis
Fantastic, thanks. I also re-used your step 8 to set javac, the java compiler, for use in IDEs when programming in Java (IntelliJ and JBoss). Cheers.  
4 years ago

Indunil
This is complete tutorial and works fine!
I recoment this to all of you!
 
4 years ago

scriptx
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
 
4 years ago

DrTubbyGooberman
Great! Concise and to the point. Thank you!

Note that I think you need a 2nd sudo in the JDK removal command set.

Big help for a noob like me! Thanks again!
 
4 years ago

Bee1
Needed the assist for correct commands.
 
5 years ago

zantaz
You are C*azy ...  

Other tutorials from dudko

No other tutorials.