how to run jar file on RHEL5?

7.8k views Asked by At

I have made a jar file which i tested in windows and it works fine. now i want to test it for red hat enterprise linux 5. but i dont know how to run jar files in rhel5.

i've tried java -jar My.jar but it says bash: java: command not found. i've set JAVA_HOME variable as export JAVA_HOME=/root/jdk1.6.0_21 but still not working.

can anybody tell me how to run jar file in rhel5?

2

There are 2 answers

4
Jigar Joshi On BEST ANSWER

You need to set PATH variable , something like

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

replace /usr/java/jdk1.5.0_07/bin with path to your jdk's bin directory.

The problem is your terminal tries to find java command from the PATH , but it couldn't find it.

Update:

You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:

# vi /etc/profile

Next setup PATH / JAVA_PATH variables as follows:

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
0
Qwerky On

Top tip but slightly off topic.

1) Install your JDK in /usr/local/jdkX.X.X_XX/
2) Create a symbolic link /usr/local/java -> your chosen JDK installation

When you install new versions of java or if you want to revert to an older version, just change the symbolic link.