Home How to How to Install Java JDK in Kali Linux

How to Install Java JDK in Kali Linux

by blackMORE

POST UPDATED with latest version of Java: 18/12/2013.

This is a small guide with instructions that users can copy paste and make Java work in their Kali Linux. Thanks to purehate for providing original instructions. I’ve modified his instruction to suit my needs and I hope this will benefit users as well. Oracle Sun Java JDK in Kali Linux

So lets get on with this guide…

Instructions on How to Install Java JDK in Kali Linux:

Download the latest Java SE SDK version

Go to the following link and download jdk7. At the time of writing this guide the jdk version was jdk-7u45-linux-x64. Note that I’m using x64 which is 64-bit. 32-bit users should choose their versions accordingly. Not that tough really!

Following is what I’ve used.

JDK-7u45-Linux-x64

Again, at the time of writing this guide the available version was jdk-7u45-linux-x64.tar.gz

Download and save the file in /root directory.

UnTar the Archive and move to /opt

tar -xzvf /root/jdk-7u45-linux-x64.tar.gz
mv jdk1.7.0_45 /opt
cd /opt/jdk1.7.0_45

Install and register binaries

This step registers the downloaded version of Java as an alternative, and switches it to be used as the default:

update-alternatives --install /usr/bin/java java /opt/jdk1.7.0_45/bin/java 1
update-alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_45/bin/javac 1
update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /opt/jdk1.7.0_45/jre/lib/amd64/libnpjp2.so 1
update-alternatives --set java /opt/jdk1.7.0_45/bin/java
update-alternatives --set javac /opt/jdk1.7.0_45/bin/javac
update-alternatives --set mozilla-javaplugin.so /opt/jdk1.7.0_45/jre/lib/amd64/libnpjp2.so

Test

First of all, close your browser and re-open. You won’t believe how many users actually forgets to do this step and later complains Java ain’t working. I’d advise to bookmark this site to be able to reopen these instructions quickly, or simply copy these into a leafpad/vi/text file.

To check the version of Java you are now running

java -version

To check the browser plugin just click Do I have Java?

This should take you to Oracles Java website and you will see a confirmation message.

Thanks for reading.

You may also like

36 comments

Phelipe André February 26, 2014 - 10:05 am

Thank you

Reply
blackMORE Ops February 26, 2014 - 6:50 pm

You're welcome Phelipe.

Reply
kalilinuxnoob1987 March 9, 2014 - 3:54 pm

Thank you. Great tutorial!!! :)

Reply
blackMORE Ops March 11, 2014 - 6:48 pm

Thanks. Glad it helped you.

Reply
gobang May 31, 2014 - 5:35 am

thank you very much

Reply
ian June 7, 2014 - 9:20 am

i get question how about this ???
no alternatives for mozilla
when i check my java is 1.6 version
please reply me …..:(

Reply
Shivam Goel July 11, 2014 - 4:25 am

what if i have a Iceweasl browser..what changes in command of mozilla??

Reply
Null August 13, 2014 - 7:48 am

Just a quick question. Why JDK over JRE? That confused me a little.

Reply
smokey April 6, 2015 - 5:01 am

Its preference I would assume, but the JDK includes jre when you install it lol

Reply
cat_os August 26, 2015 - 8:20 pm

JDK is for developer, for those who develop java applications and it have tools for developing. Note that JDK also include JRE. I develop java software and I find that JDK is needed in my development.

JRE on the other hand, is for the end-user who is using java application, but not developing. JRE doesn’t include JDK.h

There is another JRE for Server. In total, there are 3 packages available. JDK, JRE & JRE Server.

A little source to read if interested in detail : http://www.oracle.com/technetwork/java/javase/downloads/index.html

Reply
Null August 13, 2014 - 7:53 am

Sorry, one final question. Why extract it to the root folder instead of creating a separate folder for it inside of root?

Reply
Null August 13, 2014 - 7:58 am

I see it actually does go to it’s own folder. I retract my last question. My understanding of all the options of all the programs needs serious work.

Reply
Nil October 9, 2014 - 6:44 am

I looked the website and there is no 32-bit version?!

Reply
cat_os August 26, 2015 - 8:23 pm

(x86) is another name for 32-bit version. Download that one.

Reply
Michael January 3, 2015 - 1:52 am

gracias :)

Reply
omar January 26, 2015 - 11:49 pm

How can i install jre java ?
Thanks in advance

Reply
Avineshwar February 1, 2015 - 9:29 pm

Guide needs to be updated in accordance with the latest JDK.

Reply
george February 17, 2015 - 2:25 am

installing jdk 1.8.0_31 but not well confiqured

Reply
Hadeus March 31, 2015 - 1:54 pm

Dont forget :
apt-get install icedtea-7-plugin

This allows Java to work in your browser (if thats what you want)

Reply
tingga June 26, 2015 - 10:08 pm

help error while installing: tar (child): /root/jdk-7u79-linux-x64.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Reply
cat_os August 26, 2015 - 8:26 pm

I’m sure you haven’t copy the JDK file into your root as bMO said in the guide.

Reply
Robert Beltran August 14, 2015 - 11:27 am

This still applies. Thanks!

Reply
blackMORE Ops August 14, 2015 - 12:05 pm

Thanks Robert. Appreciate the feedback.

Reply
jim August 20, 2015 - 10:40 pm

hey..i used the procedure above but when i opened gparted, i got this error
(gpartedbin:28676): glibmm-ERROR **:
unhandled exception (type std::exception) in signal handler:
what: locale::facet::_S_create_c_locale name not valid

could it have been caused by this procedure?

Reply
cat_os August 27, 2015 - 6:15 am

Thank you blackmoreops for this guide, working on 2015. I even made a video tutorial on this giving credit to blackmoreops himself. Feel free to watch, and thanks again to blackmoreops, really useful guide for me.

Reply
kevin March 15, 2016 - 9:30 pm

i got this error after
update-alternatives –install /usr/bin/java java /opt/jdk1.8.0_73 bin/java 1
update-alternatives: priority must be an integer

Reply
Game?/Addict!! (@MXTFEAR) September 11, 2015 - 12:30 am

I get this error when entering the alternative
root@kali:/opt/jdk1.8.0_60# update-alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /opt/jdk1.8.0_60/jre/lib/amd64/libnpjp2.so 1
update-alternatives: error: alternative path /opt/jdk1.8.0_60/jre/lib/amd64/libnpjp2.so doesn’t exist

Reply
Dr-Hack September 16, 2015 - 4:16 pm

what about Kali Sana ? , as it seems not to be working .
altought the version terminal shows is
“java version “1.7.0_79″
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode) ”

but i dont get any Java in the list of execute the java file from it , where i am going wrong ?

Reply
Dhafer October 1, 2015 - 10:02 am

helpful .. useful and it works … thx for help u save my day

Reply
Suci Ramadhan October 16, 2015 - 11:02 am

I got this problem when entering this tar -xzvf/ root/jdk-7u79-linux-i586.tar.gz
tar (child): /root/jdk-7u79-linux-i586.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2 tar: Error is not recoverable: exiting now

How could I solve this problem?

Reply
Dhammu ViRuS November 30, 2016 - 7:30 pm

Nice Work by admin…
also you can use script i made, simple run script and enjoy….
get script at https://cyberghosts.wordpress.com/2016/11/30/update-java-in-kali-linux/

Reply
MR. Riz December 11, 2016 - 12:44 pm

thanks a lot, admin!

Reply
said February 16, 2017 - 12:59 am

Thanks bro

Reply
Stefan April 11, 2017 - 2:54 am

Thanks!

My install: jdk1.8.0_121 for KaliLinux 2017 on Intel 32bit system

root@kali:~# cd /opt
root@kali:/opt# ls
jdk1.8.0_121 Teeth
root@kali:/opt# cd jdk1.8.0_121
root@kali:/opt/jdk1.8.0_121# update-alternatives –install /usr/bin/java java /opt/jdk1.8.0_121/bin/java 1
root@kali:/opt/jdk1.8.0_121# update-alternatives –install /usr/bin/javac javac /opt/jdk1.8.0_121/bin/javac 1
root@kali:/opt/jdk1.8.0_121# update-alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /opt/jdk1.8.0_121/jre/lib/i386/libnpjp2.so 1
root@kali:/opt/jdk1.8.0_121# update-alternatives –set java /opt/jdk1.8.0_121/bin/java
update-alternatives: using /opt/jdk1.8.0_121/bin/java to provide /usr/bin/java (java) in manual mode
root@kali:/opt/jdk1.8.0_121# update-alternatives –set javac /opt/jdk1.8.0_121/bin/javac
update-alternatives: using /opt/jdk1.8.0_121/bin/javac to provide /usr/bin/javac (javac) in manual mode
root@kali:/opt/jdk1.8.0_121# update-alternatives –set mozilla-javaplugin.so /opt/jdk1.8.0_121/jre/lib/i386/libnpjp2.so
update-alternatives: using /opt/jdk1.8.0_121/jre/lib/i386/libnpjp2.so to provide /usr/lib/mozilla/plugins/libjavaplugin.so (mozilla-javaplugin.so) in manual mode
root@kali:/opt/jdk1.8.0_121#

Reply
Bruno IGNABAI TCHINDEBE September 6, 2017 - 9:21 pm

thank you !!!

Reply
Nirmalya February 4, 2018 - 8:48 pm

Really that is good for all Kali Linux user and it is working

Reply

Leave your solution or comment to help others.

This site uses Akismet to reduce spam. Learn how your comment data is processed.