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?
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.
This is the best way which worked for me Execute this Command:-
$(dirname $(readlink $(which javac)))/java_home
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.
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
Simple, try it:
It's /usr/local/java/jdk[version]
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