Kali – Changing Java

Tools

There are many types that a tester will need to change the version of Java they are using to match their target. Luckily, there is an easy way to switch between them using DebianAlternatives.

The following is an example to install and use an older version of Java. Start by downloading an older version and install it.

https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html

<—— Here are the following steps to install the downloaded older Java version.

┌──(kali㉿kali)-[~/Downloads]
└─$ sudo apt install -y ./jdk-11.0.6_linux-x64_bin.deb
[sudo] password for kali:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'jdk-11.0.6' instead of './jdk-11.0.6_linux-x64_bin.deb'
The following NEW packages will be installed:
jdk-11.0.6
0 upgraded, 1 newly installed, 0 to remove and 1131 not upgraded.
Need to get 0 B/155 MB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 /home/kali/Downloads/jdk-11.0.6_linux-x64_bin.deb jdk-11.0.6 amd64 11.0.6-1 [155 MB]
Selecting previously unselected package jdk-11.0.6.
(Reading database ... 304132 files and directories currently installed.)
Preparing to unpack .../jdk-11.0.6_linux-x64_bin.deb ...
Unpacking jdk-11.0.6 (11.0.6-1) ...
Setting up jdk-11.0.6 (11.0.6-1) ...

<—— Create an Alternative Option using the newly installed Java version

┌──(kali㉿kali)-[~/Downloads]
└─$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.0.6/bin/java 2

<—— Set an Alternative Java version to be the default

┌──(kali㉿kali)-[~/Downloads]
└─$ sudo update-alternatives --config java

There will be choices for each of the alternative java options (providing /usr/bin/java).

Select the Java version, in this case number 3 was the newly installed Java version.

Selection    Path                                         Priority   Status
------------------------------------------------------------
0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      auto mode
1            /opt/jdk1.8.0_251/bin/java                    1         manual mode
* 2            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
3            /usr/lib/jvm/jdk-11.0.6/bin/java              2         manual mode


Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk-11.0.6/bin/java to provide /usr/bin/java (java) in manual mode

<—— Check the current running Java version

┌──(kali㉿kali)-[~/Downloads]
└─$ java --version
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
java 11.0.6 2020-01-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)

Leave a Reply

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