• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem running jar on new Windows 7 install

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can open it with "java -jar file.jar". How can i get it to open on double click ?
 
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic