Reputation: 63
I made a Runnable Jar that will run as service in windows, but the final pc that will execute him, has 3 versions of java installed, 1.3, 1.6 and 1.7, and my jar needs to be executed with 1.7, because him uses classes that are present only in 1.7+ version, o don't know how are configured the environiment variables, my question is:
Is possible to force my code to run in java 1.7?
Upvotes: 1
Views: 2685
Reputation: 2542
You can also do this without persistently resetting your path environments. Just use the absolute path to your jre/jdk instead of typing "java": e.g.: "C:\Program Files\Java\jre7\bin"\java -jar foo.jar
, same goes for MacOS and Linux.
Upvotes: 1
Reputation: 2155
Rather than setting path/classpath at top level, you should create a batch file and set path/classpath there.
Then command to run your jar.
Upvotes: 0
Reputation: 5168
Set your JAVA_HOME and PATH environment variable to point to the Java 7 directory.
See https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them to know how to do it.
Upvotes: 0