I sent a runnable jar to a friend. He double clicks on it and it doens’t open it crashes. However my other friend can open it.
I believe the problem is that my first friend has multiple versions of java on their machine and it is using the wrong version on the double click.
How can I have the correct version of java be used to run my jar? I am ok to have my friend do this from the command line.
He could simply grab the correct version of the java as part of his execution statement on the command line. If, for instance, you are compiling with Java6, he could do something like the following in windows:
He would simply run this command wherever the jar file is located. This is assuming, of course, that he has JRE 1.6.0_13 installed – change that out for whatever version he is running. Also, the path will be different for different systems.
Another options in Windows is that you can specify different versions of Java to be the default through the java configuration in the control panel, if I remember correctly.
Edit:
Additionally, you can change the
javaexecutable in the command tojavawif you want it to run in the background – i.e. if it is a Swing application primarily, and a console is not required.