To install Java on Oracle Linux 8, you have to install the latest JDK from the official release website. The JDK stands for Java Development Kit, an application of any one of the Micro Version platforms of the Java Platform published by Oracle Corporation. To install it on your Oracle Linux 8, you have to follow this article very eagerly.
Prerequisites
- Oracle Linux 8 installed on your Virtual Box
- Must have root user privileges
Download RPM File
To install Java in your Oracle Linux 8 system, you have to first download the RPM file for Oracle Linux 8.
Open any installed browser and search for the Java SE Oracle Download website. Click on the JDK Download to proceed.
There are a lot of RPM packages available on the JDK download page. You have to pick the Linux x64 RPM Package. Under the Download label, click on the .rpm JDK file to download it.
You will then see the below dialogue box. Checkmark the License Agreement terms and click on the Download button, followed by the RPM file name, to continue the download.
Another dialogue window will be opened. Pick the Save File option, and hit the OK to continue the download.
You can see that the download has started. Wait for some time until the download has been completed.
The downloaded JDK RPM file is now residing in the Downloads folder as cited below.
Check Repositories and Java Version
Firstly, open your Oracle Linux 8 terminal and add the following command to check installed repositories:
To check whether your Oracle system has any JDK package installed, use the following command:
You can also verify the latest version of the default Java version compatible and enabled for your system, using the command as follows:
Check Default Java Path
You can use the command below to check the default Java path of JDK:
You can see the default JDK path is /usr/bin/java.
To check the link file, which is /etc/alternatives/java, you can use the appended command below:
Unlink the Default Path
To unlink this file, e.g., /etc/alternatives/java, you have to login as a root user, as cited below:
Note: It will ask for your root password.
# exit
So, upon checking the version of Java, you will find that there is no such file or directory.
You can also check the file using the following “which” command:
Now, the Open JDK has been disabled completely.
Install JDK
To install JDK in Oracle Linux 8, open your Downloads folder, where you have downloaded the JDK file. Press the Right-key button from the mouse and hit on Open in Terminal. You will then see that your terminal has been opened. Login as a root user using the following command:
Using the list command, you can list the RPM file as follows:
Finally, you can install the JDK file. You have to use the rpm command, followed by the name of a file, as cited below:
Wait for some time until the JDK file has been installed. You will see that it will fail to read the link /usr/bin/java because we have already unlinked it.
Check RPM Package Name
To check the RPM file package name that has just been installed, execute the following command on your oracle Linux 8 terminal:
Check Directories and Files in Java
To check the directories and files used by JDK 15, you have to use the following rpm command, followed by the package name brought in the upper command:
You will see a long list of directories and folders used by the JDK package.
When you check the version of Java, it will show you the latest version that has just been installed, as appended below:
You can also check the version of Java only, as cited below:
Launch Java
To verify whether you installed the JDK kit and if it is working properly, you can use the affixed command:
Another command to check the working of Java is as follows:
When you check the Java link path, where the Java resides, it will show you the same old path. This means that /usr/bin/java has been replaced by the new JDK 15, as cited below:
Check File Path
Now to check the link file details, you have to use the list command, followed by /usr/bin/java path, as cited below:
Link File Path
At last, you can link this newly created Java with the old file path. You can also do that by using the following command:
Conclusion
We have discussed how to switch to root user in Linux Oracle 8, download RPM JDK file, remove link for default file path, check repositories and version, install JDK Kit on Oracle Linux 8, and link the default file path. Hopefully, you are now able to do all these particular tasks by following this guide.