aspose file tools*
The moose likes Java in General and the fly likes Why can't I run these jar files on a PC that doesn't have the JRE 6? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why can Watch "Why can New topic
Author

Why can't I run these jar files on a PC that doesn't have the JRE 6?

Clark Johnson
Greenhorn

Joined: Mar 08, 2007
Posts: 20
Let me be more explicit. It appears that it is not possible to run a jar file containing .class files compiled using the JDK 6 on computers that only have the JRE 5. I tried to run some jar files on some computers that only had the JRE 5 installed, but I kept getting a message saying that the main class was not found (the manifest files are fine). When I tried to run the jar files on computers that had the JDK 6 installed, the programs worked fine.

I don't want every person who will be using this program to have to download the latest JRE. Will I solve this problem if I compile the files using the JDK 5.0?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38756
    
  23
As far as I know:- Yes.

As long as you only use JDK5 compatible features.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
You can also use JDK 6 to create class/jar files for use with JDK 5. Check out the "-source" and "-target" options of javac.


Ping & DNS - my free Android networking tools app
Clark Johnson
Greenhorn

Joined: Mar 08, 2007
Posts: 20
Hello guys,
After researching this subject, I'd like to mention that compiling Java 5-compatible programs, using the JDK 6, using the -source and -target parameters, won't always work, as these parameters won't detect references to classes that were introduced in subsequent Java versions.

I suggest that anyone trying to take care of a similar problem compile his or her programs using the JDK 5 instead.
[ March 22, 2007: Message edited by: Clark Johnson ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
Originally posted by Clark Johnson:
... as these parameters won't detect references to classes that were introduced in subsequent Java versions.

I'm not sure what you mean by this. All those settings are doing is making sure that the class files produced can be run on an earlier JVM. If the code contains JDK6-only methods, then you need to make sure that they are not executed on a Java 5 JVM (by including appropriate checks in the code).

Obviously, JDK 5 will not be able to compile code that uses any JDK 6 methods, so the workaround of using JDK 5 to compile the program is not really going to work.
Clark Johnson
Greenhorn

Joined: Mar 08, 2007
Posts: 20

Obviously, JDK 5 will not be able to compile code that uses any JDK 6 methods, so the workaround of using JDK 5 to compile the program is not really going to work.[/QB]


Correct, but depending on the size of your program, it can easier to have the JDK 5 tell you which methods won't work than rereading the documentation of all the methods you used. It seems like a safer and more efficient way to take of this problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why can't I run these jar files on a PC that doesn't have the JRE 6?