Jar File For All Java Versions?

Go To StackoverFlow.com

0

I have been working on a Java game and I recently wanted to see if others could download and play it. After using Eclipse and making the game into a runnable jar file with the libraries extracted into the project, I had several people download it and try to play. All people had the same problem, the jar wouldn't open. Either as an applet on my website, or just a desktop application. They would get some class error which when I looked it up online meant that they needed to update their Java version. Is there anyway to make it so that my jar file can be used by most, if not all Java versions?

Problem: Jar file cannot be opened by others. Get class error

Assumption: Eclipse is causing the problem

Other Info: I use jre7 and jdk1.7

2012-04-03 22:15
by Trey
You can build your app with a java version that you know most people will have. This usually means using Java 5 or Java 6 - jahroy 2012-04-03 22:29


0

Eclipse by default is probably compiling for Java 1.7. If your users have a lower version of Java, your program won't be able to run. You need to change the target Java version. In Eclipse,

  1. Right click on your project
  2. Click on "Properties..."
  3. Click on "Java Compiler" (it's on the side),
  4. Ensure "Enable project specific settings" is checked.
  5. Change all the drop downs that say "1.7" to "1.4" (or the oldest version of Java you want to support).

Regenerate the .jar and it should work (or at least your users should stop getting a version error).

When you use a lower version of Java, note that certain language features and classes may no longer be available. Fortunately, you'll get compiler errors if you accidentally used any of these new features.

You should also post the exact error your users are getting.

2012-04-03 22:30
by Jack Edmonds


2

I am not claiming to be a pro here Little Willis, but when coding your game you have to keep in mind if you are coding for something like jre7 you may find issues if the user only has jre5 due to update library information that they may be missing. I do not, however; believe that to be the root of your issue. Just something I've missed before.

Can you post the error they get please?

Edit The comment at the bottom of your original post by jahroy and the steps given by Jack Edmonds, outline the problem that I was speaking of and how to remedy it.

2012-04-03 22:20
by JDD
Ads