Home / How to / How to Install Java JDK in Kali Linux

How to Install Java JDK in Kali Linux

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.

Check Also

Correct way of installing VirtualBox Guest Additions in Kali Linux 2016.2/2017 (Kali Rolling)

How to install VirtualBox Guest Additions in Kali Linux (Kali Rolling / Kali Linux 2016.2 / Kali 2017)

Since Kali Linux 2016 came out (also known as Kali Rolling), it seems that Official …

Run Kali Linux in Microsoft Azure on SSD for free - blackMORE Ops - 1

Run Kali Linux in Microsoft Azure on SSD for free

Big news for Kali Linux users, now you can run Kali Linux in Microsoft Azure …

36 comments

  1. Thank you

  2. kalilinuxnoob1987

    Thank you. Great tutorial!!! :)

  3. thank you very much

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

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

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

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

    • 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

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

  8. 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.

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

  10. How can i install jre java ?
    Thanks in advance

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

  12. installing jdk 1.8.0_31 but not well confiqured

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

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

  14. 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

  15. 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?

  16. 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.

    • 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

  17. 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

  18. 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 ?

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

  20. 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?

  21. 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/

  22. thanks a lot, admin!

  23. 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#

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

Leave a Reply

Your email address will not be published. Required fields are marked *