This depends a bit from your package system ... if the java command works, you can type readlink -f $(which java) to find the location of the java command. On the OpenSUSE system I'm on now it returns /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java (but this is not a system which uses apt-get).
On Ubuntu, it looks like it is in /usr/lib/jvm/java-6-openjdk/ for OpenJDK, and in some other subdirectory of /usr/lib/jvm/ for Suns JDK (and other implementations as well, I think).
Debian is the same.
For any given package you can determine what files it installs and where it installs them by querying dpkg. For example for the package 'openjdk-6-jdk': dpkg -L openjdk-6-jdk
This depends a bit from your package system ... if the java command works, you can type readlink -f $(which java) to find the location of the java command. On the OpenSUSE system I'm on now it returns /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java (but this is not a system which uses apt-get).
On Ubuntu, it looks like it is in /usr/lib/jvm/java-6-openjdk/ for OpenJDK, and in some other subdirectory of /usr/lib/jvm/ for Suns JDK (and other implementations as well, I think).
Debian is the same.
For any given package you can determine what files it installs and where it installs them by querying dpkg. For example for the package 'openjdk-6-jdk': dpkg -L openjdk-6-jdk
Copyupdate-java-alternatives -l
will tell you which java implementation is the default for your system and where in the filesystem it is installed. Check the manual for more options.
For example, on Windows I'd be able to find the java interpreter (java.exe) and compiler (javac.exe) both in the directory C:\ProgramFiles\Java\jdk.11.0.1\jmods
Where might a directory like this be on Linux? I've scoured \usr and \home, but haven't been able to find anything (other than random one-off files that are related to Java)
Where is Java/the JDK installed on Linux?
Setting up Fedora 32 to use the latest Java version in development environments.
You set JAVA_HOME and etc in IntelliJ, not from shell.
More on reddit.com"Unable to locate the Java runtime" error on launch. Will give gold.
Is there a way to hide the dir path in terminal?
Videos
Try either of the two:
$ which java
$ whereis java
For your first java program read this tutorial:
"Hello World!" for Solaris OS and Linux
On RHEL7, you can use locate:
locate openjdk
or find:
find / -iname "*openjdk-*"
and it led me to the /usr/lib/jvm/ directory which contained the directories:
java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/
jre/
jre-1.8.0/
jre-1.8.0-openjdk/
jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/
jre-openjdk/
Each of these contain a bin/java
To find the full path of the symbolic link use:
readlink -f $(which java)
*Credit: Answer on Stack Overflow
Simply do (in terminal):
update-alternatives --list java
And you'll get an output like this:
$ update-alternatives --list java
/usr/bin/gij-5
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
The last line is the place your java is in.
You need to dig into symbolic links. Below is steps to get Java directory
Step 1:
$ whereis java
java: /usr/bin/java /etc/java /usr/share/java
That tells the command java resides in /usr/bin/java.
Step 2:
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-01-15 18:34 /usr/bin/java -> /etc/alternatives/java
So, now we know that /usr/bin/java is actually a symbolic link to /etc/alternatives/java.
Dig deeper using the same method above:
Step 3:
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 31 2009-01-15 18:34 /etc/alternatives/java -> /usr/local/jre1.6.0_07/bin/java
So, thats the actual location of java: /usr/local/jre.....
You could still dig deeper to find other symbolic links.
Reference : where is java's home dir?
In your terminal type java -version or just javac if it returns something, then you've java installed. Otherwise, there is also the possibility that the path variables do not contain the java path. So use locate jdk or locate java to see if you have the java binary. Don't forget to run updatedb if you are using locate for the first time.
You should be able to run which java or java -version.