• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar file will not run

 
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Sprinkler program is done and works fine in the IDE (Netbeans). The Sprinkler.jar file executes on the Mac OS (High Sierra) just fine. On the Win 10 platform, it doesn't do anything when I double-click it. Then I tried to run the following command from an administrator dos window, but errors out.

C:\Users\Mike\NetBeansProjects\Sprinkler\dist>java -jar Sprinkler.jar
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

Here is what i have tried to correct this.
Set paths to the jre and jdk
In the Netbeans IDE, I checked to make certain the project run category had a main class defined as Sprinkler.Sp.
Tried running just "java" and got the same error. (looks like it's not actually a problem with my Sprinkler.jar)
Attached a JPG of the paths.

What else do I need to check?
Path.JPG
[Thumbnail for Path.JPG]
 
Mike Gauthier
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also ran java -fullversion and the result is: java full version "1.8.0_172-b11"

BTW is there a way I can edit my own posts here instead of having to add another post for corrections/additions?
 
Rancher
Posts: 517
15
Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From Windows command prompt try this:

> java -version

The output should be something like this (this is on a WIndows 7 PC with Java 8):

java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
 
Mike Gauthier
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is what I got.
Fullversion works, but version gets the same error message.

C:\WINDOWS\system32> java -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

C:\WINDOWS\system32> java -fullversion
java full version "1.8.0_172-b11"

C:\WINDOWS\system32>
 
Marshal
Posts: 4491
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can't run java -version without encountering an error, then it seems like your Java installation is broken.

Is re-installing Java an option?
 
Prasad Saya
Rancher
Posts: 517
15
Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The output should be something like this (this is on a Windows 7 PC with Java 8):

> java -fullversion
java full version "1.8.0_172-b11"


> java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)



- In the Windows control panel what do you see for the Java related installations?
- In the C:\Program Files\Java folder what do you see?
 
Mike Gauthier
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I uninstalled the jdk and the jre.  Control panel shows nothing java
I reinstalled both and now the control panel shows both at version Java 8 172
BTW: this is a 64-bit Win 10 system
Making Progress:
C:\Users\Mike>java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)

C:\Users\Mike>java -fullversion
java full version "1.8.0_172-b11"

C:\Users\Mike>
Now when I double-click the jar file I get a new task "Java (TM) platform SE binary"
But the program is still not displaying anything.
Control-Panel.JPG
[Thumbnail for Control-Panel.JPG]
dist.JPG
[Thumbnail for dist.JPG]
 
Prasad Saya
Rancher
Posts: 517
15
Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...Now when I double-click the jar file I get a new task "Java (TM) platform SE binary"
But the program is still not displaying anything.



Did you try this?

> java -jar Sprinkler.jar

EDIT: You will probably find an answer at this web page (setting a default program for executing a jar file in Windows 10):
https://answers.microsoft.com/en-us/windows/forum/windows_10-files-winpc/how-to-change-default-programs-to-open-jar-files/98397722-c044-4e48-95e2-ab823b75c2d2
 
Mike Gauthier
Ranch Hand
Posts: 35
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Did you try this?
> java -jar Sprinkler.jar



That revealed the problem!
There is code in my program that detects the OS and adjusts a couple items depending if it is running on Windows or something else. That code had a typo in the portion executed when Windows was detected. I could see the error message when using Java -jar Sprinkler.jar but I could bot see it when I just double-clicked the jar file.

Thanks for the help. Everything is working as it should now in both environments.!
 
reply
    Bookmark Topic Watch Topic
  • New Topic