This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jar file will not run  RSS feed

 
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Ranch Hand
Posts: 506
12
Java Notepad
  • Mark post as helpful
  • send pies
  • 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
  • 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>
 
Saloon Keeper
Posts: 1930
239
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 506
12
Java Notepad
  • Mark post as helpful
  • send pies
  • 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
  • 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
Ranch Hand
Posts: 506
12
Java Notepad
  • Mark post as helpful
  • send pies
  • 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
  • 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.!
 
A timing clock, fuse wire, high explosives and a tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!