Hi all,
I installed jdk 6_23 and set the path of jdk in system path properly. And then I could run any jar file by command line, but when i double-clicked on the jar file, a message of Java Virtual Machine Launcher occured : " could not find the main class ... Program will exit". I have check the manifest file of the jar file, it totally ok (so, it could execute by command line).
I am using windows 7. I tested with SwingSet2 demo, with another one, the result was too.
Anyone can help me ?
Thx in advanced.

If the "Main-Class" attribute is specified in the jar manifest, then you shouldn't have any trouble double-clicking it to run.

If the "Main-Class" attribute is specified in the jar manifest, then you shouldn't have any trouble double-clicking it to run.

Right!! But in my case, it doesn't that. I reinstalled jdk but the problem wasn't solved.
Help me plz!!!

The launcher error message suggests to me that the file association for .jar files may be giving you
javaw swingset2.jar
when it should be
javaw -jar swingset2.jar

The launcher error message suggests to me that the file association for .jar files may be giving you
javaw swingset2.jar
when it should be
javaw -jar swingset2.jar

For me, both java -jar SwingSet2.jar or javaw -jar SwingSet2.jar are ok,
but javaw SwingSet2.jar is not ok, it gives a message of Java Virtual Machine Launcher:
"could not find the main class ... Program will exit".
My wish: can execute jar file by double-clicking on it without re-setup my OS.
Thx for reading.

Java install usually sets the file association for .jar files. I don't know why that's not the case on your machine. Anyway, it only takes a minute to fix the file association so it has the -jar option specified - certainly NOT a re-setup of the OS!

Java install usually sets the file association for .jar files. I don't know why that's not the case on your machine. Anyway, it only takes a minute to fix the file association so it has the -jar option specified - certainly NOT a re-setup of the OS!

Guide me your way, plz
Thks.

Take a look at this thread to fix the file association.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.