Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 10 down vote accepted

On most Linux distributions you can use update-alternatives like this:

sudo update-alternatives --config java

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

share|improve this answer
Any reason not to use update-alternatives --list java just to list them? – Xiao Oct 17 '15 at 1:20
@Xiao: unfortunately, not all versions of update-alternatives have --list option. e.g. Centos 6.7 doesn't. – mvp Oct 19 '15 at 17:45

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.

share|improve this answer
"package manager" ... Unless someone installed a java version manually. Find is a valid approach, though :) find / -type f -name java -print 2>/dev/null | xargs -i echo {} -version | bash – tink Mar 21 '13 at 22:22

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
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .