The Computer Oracle

What is command to see all java versions installed on linux?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops

--

Chapters
00:00 What Is Command To See All Java Versions Installed On Linux?
00:28 Answer 1 Score 9
00:42 Answer 2 Score 1
01:19 Accepted Answer Score 96
01:48 Answer 4 Score 6
01:57 Thank you

--

Full question
https://superuser.com/questions/569633/w...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #java

#avk47



ACCEPTED ANSWER

Score 96


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.




ANSWER 2

Score 9


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.




ANSWER 3

Score 6


I use this to list the Java installs available:

sudo update-alternatives --display java



ANSWER 4

Score 1


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