tags:

views:

343

answers:

3

I'm trying to run a .jar file on my centos box, but it says "java: command not found".

What's the best or easiest way to solve this? I was hoping for a yum command but not sure that that will exist for java?

+3  A: 

Either the JRE is not installed or, more likely, its location is not included in your PATH environment variable. If the java executable is not in your PATH, you would need to use the full path & filename to execute it.

Syntactic
+4  A: 

Apparently some versions of CentOS doesn't come with a JVM installed due to some licensing restriction. See HowTo Install Java on CentOS 4 and CentOS 5 for instructions.

Bill the Lizard
The "licensing restriction" is outdated. It is in the linked document starting at *"SPECIAL NOTE: Starting with CentOS 5.3 ..."*.
Stephen C
@Stephen: That still explains what you need to do. Either upgrade CentOS so you can use OpenJDK or follow the instructions for installing one of the other JRE/JDKs. I updated my answer to reflect this.
Bill the Lizard
A: 

You can use such command to check if Java is available in your repository:

yum list | grep java

It should return something like that:

java-1.6.0-openjdk
java-1.6.0-sun

If such package exists you can install it using such command (run it as the root user):

yum install java-1.6.0-openjdk
Lukasz Stelmach
thanks lukasz, that was the package I was looking for. Solved!
Jorre