How to know that Java is installed in a Linux system?

18

4

I am using Ubuntu. How to know if Java is installed ?

Andy Frédéric

Posted 2011-11-11T05:59:07.257

Reputation:

Answers

21

In your terminal type java -version or just javac if it returns something, then you've java installed. Otherwise, there is also the possibility that the path variables do not contain the java path. So use locate jdk or locate java to see if you have the java binary. Don't forget to run updatedb if you are using locate for the first time.

abhinav

Posted 2011-11-11T05:59:07.257

Reputation: 416

9

You should be able to run which java or java -version.

Daniel Haley

Posted 2011-11-11T05:59:07.257

Reputation: 201

4

The above answers seems pretty OBVIOUS..!! (only if you have to check JAVA)

For checking any package (whether it is installed or not), u can do the following :

sudo aptitude search packageName

It will get you a list of Packages (that you wanted to find out, whether installed or not). In the list, on the left hand side, (the key to the Your question) , there lies a small Alphabet denoting whether the corresponding package is already installed on your system or not.

For example, for java, you will do like :

sudo aptitude search jdk

and you will get something like :

i A default-jdk

i A default-jdk-doc

i A openjdk-6-doc i A

i A openjdk-6-jdk

i A openjdk-6-jre v

p openjdk-6-jre-shark

p openjdk-6-jre-zero

p openjdk-6-source

Now the "i" on the left shows that it is installed.

CHEERS..!!

Ramandeep Singh

Posted 2011-11-11T05:59:07.257

Reputation:

3

java -v

should do the job aswell.

Sebastian Oberste-Vorth

Posted 2011-11-11T05:59:07.257

Reputation:

If it's on the $PATH. – Daniel Beck – 2011-11-12T14:27:03.137