I have a jar file that I created on my PC using Java 7. I want to run it on my lab server which only has Java 6. I try to run the jar file: java -jar file.jar
but there was a UnsupportedClassVersionError exception.
Since I have no root right, I cannot install the new Java 7 on the server. However, I can download JDK7 to my working folder (let say /home/jdk7
)
Is there a way to run the jar file by specifying the jdk path to /home/jdk7 ? Thanks.
You can use the java
executable from your private JRE/JDK installation explicitly. If it's installed in /home/jdk7/
, the full command line should be:
/home/jdk7/bin/java -jar file.jar …
Alternately, you can make this installation's executables the "default" by prepending them to your PATH
, by using the following in ~/.bashrc
or ~/.profile
. (One of those or both will be correct for your lab system, I'm not sure since I use fish
.)
export PATH=/home/jdk7/bin:$PATH
Note: this will only help if it's in the environment of the logged in user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With