I know about java -version. I don't care what version I'm currently running. I care what other versions are installed on my linux box. If it's another java -* command I didn't see it in the java -help.
I've tried googling it but the answers are either for Windows or they say "use java -version." I know I've done this before.
5 Answers
On most Linux distributions you can use update-alternatives like this:
sudo update-alternatives --config javaIt will list all packages that provide java command and will let you change it. If you don't want to change it, simply Ctrl-C from it.
There is only one catch - if you installed some java not using official package manager (dpkg/apt-get, rpm/yum), but simply extracted it, update-alternatives will not show it.
You could do:
find / -name java To find all files. The package manager with your version of Linux should also be able to list them.
3I use this to list the Java installs available:
sudo update-alternatives --display java 1 I was previously using the following to determine the java 8 installation for an application that needed an environment variable set so it could use a java version that was not set as the default:
update-java-alternatives -l java-8-oracle
However, that stopped working today. The update-java-alternatives script/program is no longer installed on my Ubuntu 14.04 system. What's installed now is alternatives.
What I use now to get a specific alternatives java path is:
alternatives --display java | grep priority | grep jdk-1.8
Then I can massage the result to get what I need for my app's environment variable.
You leave a lot to be desired as far as details about your setup goes. Java can be installed in different ways in linux. You can install via your distributions package maanger, like apt, yum, yast, or you could install it manually.
How ever you installed it a Java installation needs the java executable to do any good in most cases, so you could use the locate or find commands to find the different ones.
Example which will most likely find links and duplicates, but the directory names should help you pinpoint it:
for f in $(locate -ber '^java$'); do test -x && echo "$f"; done