Running a jar from shell script Running a jar from shell script shell shell

Running a jar from shell script


compare "java -version " and ""$JAVA_HOME"/bin/java -version"

You probably have multiple JVMs installed


As already mentioned - you're trying to use byte code compiled by the later compiler with old jvm.

Please note that if your PATH contains multiple java executables of different versions you can switch between them easily using '-version' key.

Suppose you have java5 and java6 at your PATH and java5 is located before java6 there. You can see that java5 is used by default then (if you execute 'java -version' it prints corresponding information). However, you can start java6 easily using command like 'java -version:1.6 ...' (e.g. if you execute 'java -version:1.6 -version' you see that java6 is used).


Export the java and jre home which you need to use in your sh file.

Run the jar using the exported java home

e.g

export JAVA_HOME=/opt/java6export JRE_HOME=/opt/java6/jre/opt/java6/bin/java -Xms2048m -Xmx2048m -jar abc.jar $1