During my attempt to install JDK-8 using the command, sudo apt-install openjdk-8-jdk, I encountered an error stating "Unable to locate package."
To address this issue, I'll guide you through the manual installation of JDK-8. You can apply similar steps to install other versions as well.
Open your preferred web browser, and navigate to this URL.
Oracle Java 8 - Download
This link provides access to download Oracle Java 8. Java 8 is a widely used version of the Java programming language, known for its stability and compatibility with many applications.
This webpage will offer access to the installation and archive files for JDK-8.
We'll specifically target the Linux version for installation. However, you'll notice various architecture options available. To determine your system's architecture, execute the command "uname -a" in your terminal.
Upon checking the result, I discovered that my system employs the x86_64 architecture. Consequently, I will download the x64 archive file. After completing the download, the next step is to prepare for the installation of JDK-8.
Navigate to the directory where the download is located.
Once there, extract the downloaded file.
After extraction, rename the folder to, "jdk-8."
To proceed, move this renamed folder to the /usr/lib/jvm directory. Open a new terminal and navigate to the download directory and Execute the "mv" command to relocate the folder to its new destination.
Now, let's execute the following command:
This command instructs the system to add a new alternative for the Java executable. It designates the new alternative's location as `/usr/lib/jvm/jdk-8/bin/java` and assigns it a priority of 1. This means that if other alternatives for the `java` command exist, the system will give preference to the one specified in this command with a priority value of 1. This approach proves valuable for managing multiple versions of a program and seamlessly switching between them.
Similarly, we proceed to add new alternatives for other executables. Replace the word "java" with "javac" to add a new alternative for the Java compiler.
And then repeat the process for the "jar" command.
Having successfully installed Java 8, the next step is to configure it as the default Java runtime environment (JRE) interactively. This configuration is especially handy when dealing with multiple installed Java versions, and you wish to designate one as the default.
To achieve this, enter the command `sudo update-alternatives --config java` in the terminal.
This command prompts the system to present you with two alternative options for Java. You'll need to choose the number corresponding to the location of jdk-8 and press "Enter."
By following this step, you'll effectively update Kali Linux to use Java 8. In case you wish to revert to the previous Java version, simply execute a similar command and select the desired alternative.
These steps provide a robust mechanism for managing different Java versions of your system.
However, the Java compiler has not yet been updated to version 8 yet. To achieve this, run the same command as before, but replace "java" with "javac." Then select the alternative "javac" option when prompted.
Likewise, proceed to update the path for the jar file.
Once these changes are made, you can verify them by checking the version:
You have successfully installed JAVA 8 on your Kali Linux.
Thanks for the guide btw, i get difficult when i try to move the file to /usr/lib/jvm. Turns out the one who moved is the extracted files
ReplyDeleteI keep reading a lot of posts when I first get into trouble. This is how I once reached this website (https://kodlogs.net/340/unable-to-locate-package-openjdk-8-jre) and got the desired solution. You can read this post as well as visit here. I think it will be very useful for you
ReplyDelete