jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Problem running jar on new Windows 7 install Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem running jar on new Windows 7 install" Watch "Problem running jar on new Windows 7 install" New topic
Author

Problem running jar on new Windows 7 install

John Fey
Greenhorn

Joined: Mar 08, 2010
Posts: 3
I have a program I wrote that is in a .jar file that works fine on my Windows XP computer, but when I try double clicking the exact same jar file on my dad's new Windows 7 install with Java 6.18, I get a pop-up that says, "Java virtual machine launcher Could not find the main class: C:\MyFolder\MyApp.jar Program will exit."

About a month ago I tried messing around with the environment variables, but I couldn't get anything to work.

What do I need to do to get this file to run on his computer?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

There is a flaw in the javaw command that does launches your JAR. It catches any exception and shows that message. The problem is most likely something totally different.

Open a command prompt, go to the folder where the JAR file is located, and execute "java -jar myfile.jar" (replace the name of the JAR file of course). That will show the full stack trace. My guess is that you're missing a library somewhere.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
John Fey
Greenhorn

Joined: Mar 08, 2010
Posts: 3
Rob Prime wrote:There is a flaw in the javaw command that does launches your JAR. It catches any exception and shows that message. The problem is most likely something totally different.

Open a command prompt, go to the folder where the JAR file is located, and execute "java -jar myfile.jar" (replace the name of the JAR file of course). That will show the full stack trace. My guess is that you're missing a library somewhere.

When I do that it launches my program, nothing else appears at the command prompt.

Even though I can now start my program by using the command you gave me, I'd still like to be able to start it by double clicking it, because that is what my dad is used to.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

What happens if you replace "java" with "javaw"? Because that's what should get executed if you double click the JAR file.
John Fey
Greenhorn

Joined: Mar 08, 2010
Posts: 3
Rob Prime wrote:What happens if you replace "java" with "javaw"? Because that's what should get executed if you double click the JAR file.

Both "java" and "javaw" start my program. With "java" it doesn't go back to the command prompt until you exit my program, with "javaw", it goes right back to the command prompt after you enter the command. Neither one give any more output in the command window.
Alex Parvan
Ranch Hand

Joined: Dec 10, 2009
Posts: 115
I just noticed i have the same problem
Exception in thread "main" NoClassDefFoundError, ClassNotFoundException
Stack trace doesn't have anything helpful.

I used this same .jar file when i was using Vista (a few weeks ago) and now on Windows 7 it doesn't work.


"Quoting yourself is stupid" - Me
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

John, there must be something wrong with the file association. The class path etc is fine since you get no problems on the command line. You'll need to fix your file association for .jar. On my Windows XP machine I have the following settings:
- Action: open
- Application used to perform action: "C:\Program Files\Java\jre6\bin\javaw.exe" -jar "%1" %*
- Use DDE: checked
- DDE Message:
- Application: javaw
- DDE Application Not Running:
- Topic: System

Parvan Alexandru wrote:I just noticed i have the same problem
Exception in thread "main" NoClassDefFoundError, ClassNotFoundException
Stack trace doesn't have anything helpful.

Sure it does. It mentions the class that could not be found. You then search for a JAR file or folder that has that class.
Alex Parvan
Ranch Hand

Joined: Dec 10, 2009
Posts: 115
I can open it with "java -jar file.jar". How can i get it to open on double click ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem running jar on new Windows 7 install
 
Similar Threads
making exe file from java code
standalone application question
Apache-Tomcat installation
Command Line from a jar
How to install a java jar on windows vista and 7