• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Trouble running a .jar file

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am hoping someone can help me out with this.

I have a small app that I created a .jar file from so that it can be run by double-clicking on that. It has been working perfectly fine for everyone until this week. I have one person who gets a java.lang.noclassdeffounderror when trying to run it that way. I was able to create a cmd file that runs the .jar and that works fine. So what am I missing in my creation of the .jar that is not allowing it to run for this one person?

The .cmd file contains the following:

 
Marshal
Posts: 5472
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to define the application's entry point. There's a couple of ways to do it, both described here:
The Java Tutorials: Setting an Application's Entry Point
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I thought I had done that in my manifest file

Manifest-version: 1.0
Main-Class: src.main.java.appname
Class-Path: . lib/javafx-dialogs-0.0.1.jar lib/junit-4.7.jar lib/opencsv-2.3.jar lib/xmlpull-1.1.3.1.jar lib/xpp3_min-1.1.4c.jar lib/xstream-1.4.3.jar jarname.jar
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What class is it not finding?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephanie Challand wrote:Main-Class: src.main.java.appname


Is your class really in a package named "src.main.java"? In other words, for this to work you have to have this package statement in the source file appname.java:



You have probably the wrong package or directory structure in your JAR file.
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Yep the package statement is there. Like I mentioned this works on my computer and many others. I have only found one person who cannot double click the .jar and have it run, but double clicking the .cmd I showed above works for her. Just trying to get consistency so that everyone can run it by double-clicking the .jar.
 
Marshal
Posts: 76870
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So everybody else can get that .jar to run, except one person?
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, one so far. I suppose there may be more out there, but only one that I know of.
 
Greenhorn
Posts: 17
Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since it runs from the command line where you type out the path for the java.exe. Check the path variable on the persons pc. It needs to have the java directory ('c:\Program Files\Java\jdk1.6.0\bin\')in it.

Then the command line will work with:

java -jar app.jar

You might also check the file type association for .jar extensions

Also, if they are clicking on an icon to run the jar, check the 'Start in' property in the shortcut.
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I actually did a remote session with them and verified that their java classpath was the same as mine.

Isn't there a way to include that so that if the classpath is not set or set correctly the double-clicking of the .jar will run it properly?

I didn't specifically check the association of the file, but the .jar icon had the java look.
 
Mary Shell
Greenhorn
Posts: 17
Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the 'Start in' property on the shortcut, it should reflect the location of the jar.

Nothing happens when the field is empty.

Does it execute when you double click on it from the directory?
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It tries to open but I get the java.lang.noclassdeffound on that person's computer only
 
Campbell Ritchie
Marshal
Posts: 76870
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By no class def found do you mean an Exception? Has that .jar file become corrupted?
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What class?
ClassDefNotFound will tell you what class it can't find...
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main class I believe, since it wont even run. I just get the cmd window with that error. I just got a screenshot from the person and that was cut off a bit though.

It is just strange that everyone else can run it with the .jar and this person can run it with the .cmd file that runs the .jar.

So is there a better way to compile and distribute a java app? Java is not my typical programming language. I took a few classes in college, but for this project Java was needed so it could be run on macs and pcs. It is just a small app but we want to have consistency in how to distribute it to users and in how they run it.

Thank you all for all your suggestions!!
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephanie Challand wrote:The main class I believe, since it wont even run. I just get the cmd window with that error. I just got a screenshot from the person and that was cut off a bit though.



I'd want to know exactly which one.
It could be that it's incorrectly deployed and one of the jar files isn't accessible...so various classes can't be reached.
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would agree, but as I said over 30 others can run the EXACT same file perfectly fine, so I don't think that is it....
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephanie Challand wrote:I would agree, but as I said over 30 others can run the EXACT same file perfectly fine, so I don't think that is it....



Without knowing the exact error, though, you are playing on guesswork.

I have lots of instances where something is identical, but not working, only for it to turn out that that isn't actually the case.
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I understand that. Okay, then does anyone have any other ideas on how to create an executable type program that will work on both pcs and macs vs just a .jar file?

This is a project for a non-profit so free is best
 
Campbell Ritchie
Marshal
Posts: 76870
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you have been told, we ought to see the complete error message before we can help. As long as you have not put implementation‑specific code in the .jar, it should run exactly the same on Windows┬« Mac and Linux. I presume you have seen the instructions in the Java┬« Tutorials.
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I am attaching the error screenprint from the person. When they try to run the .jar this just flashes quickly so you cannot see the entire error message. When they run the SAME .jar from the command line using the code below it runs without the error so I am not sure how you would get the full error any better.



We have it running completely fine on over 30 computer, which include both macs and pcs. This one in question is a Windows 10 pc, but we have at least 2 others on Windows 10 which double-clicking the .jar runs fine.

I guess I just want to know what is the proper way to ensure that there is a way to easily run things on EVERY computer that we distribute this to as these are not computer savvy people.

Error Message:

https://www.dropbox.com/s/p51x2ekto52bjvv/2016-01-14_11-13-09.png?dl=0
 
Marshal
Posts: 4017
549
Android 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
Next time, please copy and paste the text here rather than providing a link to a screen capture.

This is the error message text:
    Exception in thread "main" java.lang.NoClassDefFoundError: C:\Users\river\Desktop\SR App\ScoreRoomApp v2/0\ScoreRoom/jar
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would have but it is not on my computer. This is what I got from that person....so sorry. You requested the error message so that is all I have to provide.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still the class name is not shown in the error message.
 
Stephanie Challand
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like I have said that is all I have. I guess I am on my own then...Thanks anyway.
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic