views:

721

answers:

3

Hi,

I have written a Java GUI app (using Netbeans 6.7) requiring Java 1.6. I successfully run it on my XP PC and also my Mac OSX (10.5.7).

My client is running Vista Business, and cannot run the application by double clicking the jar file. He can execute it from the command line: "javaw -jar ..." The error received is: "Cannot find the main class... Program will exit".

I've asked the client to do the following:

  • install the latest JRE
  • run JarFix

I've verified that:

  • JRE is installed in correct location
  • jar file association is correct
  • application works (as I have tested it on XP and Mac OSX, and the client can run it from the command line)

Any ideas on what else I can investigate? Note, Netbeans created the main jar file, and also a lib directory with a couple of other Jarfiles. I've unzipped the jarfile and examined the manifest file (which looks good). The correct main class is also within the app's jarfile.

Does the client need to be careful as to where the application is executed from in Vista?

Thanks very much. Prembo

+2  A: 

Does exactly the same JAR file work on other operating systems?

Is the manifest file (META-INF/MANIFEST.MF) in the JAR file correct? One catch to watch out for is that the manifest file MUST end with an empty line; if it doesn't, the last line in the manifest file will be ignored. So, for example, if the last line in your manifest file is something like this:

Main-Class: com.mypackage.MyProgram

and it is not followed by an empty line, then Java will ignore the line and it will not be able to find the main class of the program.

See Sun's Java Tutorial about deploying Java programs in JAR files for exact details about how to package your application in a JAR; it also contains the warning about the manifest file needing to end with an empty line.

Also, double-check if the right version of Java is used. Are you using the exact same version of Java as on Windows XP? Try:

java -version

to see which Java version is being used.

Jesper
Yes - the exact jar file works in Mac OSX, XP and from command line in Vista Business.Manifest was created by Netbeans, and so is OK. I've verified that last line is just a comment line so it isn't an issue.The Java versions are different, but I've tried on a variety of 1.6.x versions and all are OK on the different OSs (except Vista Business of course)
Prembo
Thanks for suggestions...
Prembo
+1  A: 

I'm running Vista Enterprise and have very little differences between it and other Windows versions (with regards to Java).

Here are some random ideas that may or may not work:

  • Have you tried: right clicking on the Jar -> Open with -> Java(TM) Platform SE Binary
  • Could it be permissions related? (probably not since it runs via the command line)
  • Have you tried it with UAC off? (UAC sandboxes java apps, and they can't write to certain locations like Program Files)
  • Did you make sure they have the same files as you in JAVA_HOME/lib/ext/
  • you could try setting environment variables:
    • JAVA_HOME=<your_java_home>
    • CLASSPATH=.
    • PATH=<your_java_home>\bin
Brad Cupit
Thanks for your suggestions. I'll investigate.
Prembo
A: 

Sometimes JDK needs to be installed separately,along with the net beans IDE. If you have jdk installed then you can try checking for classpath,path in the environmental variables.