Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem running jar on new Windows 7 install

 
John Fey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Fey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can open it with "java -jar file.jar". How can i get it to open on double click ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic