I wonder if it is possible to find all JDK’s installed on my OS.
Let’s assume it’s one of the Debian-based distributions. I want to find any JDK in use, downloaded, or installed without being active. I want every JDK that could be used.
I need to include cases where somebody has changed the name the of package. I think the only solution is to search through the whole file system for specific jdk parts.
I know I can find all running java processes with jps -m
or ps aux | grep java
.
If I want to locate installed JDK’s, I can use update-alternatives --config java
.
But is it also possible to find JDK that were only downloaded, but not installed?
In my opinion, the most specific corner case will be when somebody unpacked a JDK and then packed it to any format (like .tar,.zip etc) without making any changes.
2
Answers
A quick and dirty way to find all JDK folders, wherever they might be, would be to just search for the file
javac
, which would be present in thebin/
folder of any JDK. On Linux, you may try from root:This approach should only find JDK, and not JRE, the latter which doesn’t have compile capabilities. You would follow a similar process on other OS, such as Windows.
Try the following on the command-line: