dinesh707
dinesh707

Reputation: 12592

Where can I find the Java SDK in Linux after installing it?

I installed JDK using apt-get install but I don't know where my jdk folder is. I need to set the path for that. Does any one have a clue on the location?

Upvotes: 238

Views: 700288

Answers (14)

Arun
Arun

Reputation: 1763

below command worked in my debain 10 box!

root@debian:/home/arun# readlink -f $(which java)
/usr/lib/jvm/java-11-openjdk-amd64/bin/java

Upvotes: 3

Manish Sharma
Manish Sharma

Reputation: 1

This is the best way which worked for me Execute this Command:-

$(dirname $(readlink $(which javac)))/java_home

Upvotes: 0

Grant Rostig
Grant Rostig

Reputation: 520

On Linux Fedora30 several versions of the full java JDK are available, specifically package names:

java-1.8.0-openjdk-devel.x86_64 
java-11-openjdk-devel.x86_64

Once installed, they are found in: /usr/lib/jvm

To select the location/directory of a full development JDK (which is different from the simpler runtime only JRE) look for entries:

ls -ld java*openjdk*

Here are two good choices, which are links to specific versions, where you will have to select the version:

/usr/lib/jvm/java-1.8.0-openjdk
/usr/lib/jvm/java-11-openjdk

Upvotes: 3

Dread Quixadhal
Dread Quixadhal

Reputation: 83

This question still seems relevant, and the answer seems to be a moving target.

On my debian system (buster):

> update-java-alternatives -l
java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64

However, if you actually go look there, you'll see there are multiple directories and symbolic links placed there by the package system to simplify future maintenance.

The actual directory is java-11-openjdk-amd64, with another symlink of default-java. There is also an openjdk-11 directory, but it appears to only contain a source.zip file.

Given this, for Debian ONLY, I would guess the best value to use is /usr/lib/jvm/default-java, as this should always be valid, even if you decide to install a totally different version of java, or even switch vendors.

The normal reason to want to know the path is because some application wants it, and you probably don't want that app to break because you did an upgrade that changed version numbers.

Upvotes: 3

Anubhav Gupta
Anubhav Gupta

Reputation: 560

Three Step Process: First: open Terminal->$ whereis java it would give output like this: java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

Second: ls -l /usr/bin/java It would give output like this: lrwxrwxrwx 1 root root 22 Feb 9 10:59 /usr/bin/java -> /etc/alternatives/java

Third: ls -l /etc/alternatives/java output is the JDK path: lrwxrwxrwx 1 root root 46 Feb 9 10:59 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Upvotes: 5

Brent Worden
Brent Worden

Reputation: 10974

Use find to located it. It should be under /usr somewhere:

find /usr -name java

When running the command, if there are too many "Permission denied" message obfuscating the actual found results then, simply redirect stderr to /dev/null

find /usr -name java 2> /dev/null

Upvotes: 15

Hasan
Hasan

Reputation: 316

the command: sudo update-alternatives --config java will find the complete path of all installed Java versions

Upvotes: 3

Ashansu Pant
Ashansu Pant

Reputation: 47

Simple, try it:

It's /usr/local/java/jdk[version]

Upvotes: 2

Paŭlo Ebermann
Paŭlo Ebermann

Reputation: 74760

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

Upvotes: 459

Ankit Singh
Ankit Singh

Reputation: 2622

Another best way to find Java folder path is to use alternatives command in Fedora Linux (I know its for Ubuntu but I hit this post from google just by its headline). Just want to share incase people like me looking for answers for fedora flavour.

To display all information regarding java

alternatives --display java

Upvotes: 8

Dutch Glory
Dutch Glory

Reputation: 26323

on OpenSUSE 13.1/13.2 its: /usr/lib64/jvm/java-1.6.0-openjdk-(version-number)
version-number can be 1.7.x 1.8.x etc. check software manager witch version you have installed...

André

Upvotes: 0

forcefsck
forcefsck

Reputation: 2995

update-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.

Upvotes: 58

Andrew T Finnell
Andrew T Finnell

Reputation: 13628

This question will get moved but you can do the following

which javac

or

cd /
find . -name 'javac'

Upvotes: 14

The Surrican
The Surrican

Reputation: 29866

$ which java 

should give you something like

/usr/bin/java

Upvotes: 40

Related Questions