java sdk path in ubuntu

How to find JDK path in Ubuntu

JDK (Java Development Kit) is an implementation of one of the Java versions such as Standard Edition, Enterprise Edition, etc. Sometimes you may need to find JDK path on your system, in order to be able to install or configure another software which uses JDK. In this article, we will look at how to find JDK path in Ubuntu.


How to find JDK path in Ubuntu

Here are the steps to find JDK on your system. There are two different ways to do this. We will look at each of them one by one.


Method 1

If JAVA path is configured on your system, that is, if you are able to call java command using ‘java’ keyword only, and not by specifying its full path, then you can get JDK path by opening terminal and running the following command.

$ readlink -f $(which java) 


Method 2

You can use this method whether or not JAVA path is configured on your system.

Open terminal and run the following command to get symbolic links to java directory.

$ whereis java
java: /usr/bin/java /etc/java /usr/share/java

Now we know that java is present at /usr/bin/java.

Next, check if the above path is actual file location or just a symbolic link

$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2021-09-15 13:34 /usr/bin/java -> /etc/alternatives/java

As you can see, /usr/bin/java is a symbolic link that points to /e/tc/alternatives/java.

We repeat the above ls command for the destination of symbolic link.

$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 31 2021-09-15 13:34 /etc/alternatives/java -> /usr/local/jre1.6.0_07/bin/java

Now we know that the actual JDK location is /usr/local/jre1.6.0_07/bin/java.

In this article, we have learnt how to find JDK path in ubuntu. You can use these steps in almost any Linux distribution, since these ls commands are available in every Linux system.

Also read:

How to Get Length of List in Django Template
Difference Between df and du command
How to Create Startup Disk in Ubuntu
How to Install Fail2ban in Docker
Disk Utilities in Linux

Leave a Reply

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