• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executable jar file

 
Garandi Garandi
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create an executable jar file by doing the following, but when I run the jar file,
from an arbitrary directory where I copied the created jar file I get the error.

Exception in thread "main" java.lang.NoClassDefFoundError: suncertify/client/Fli
ghtdataPresenter

To create executable client.jar

ClientManifest contains the following lines

Where FlightdataPresenter contains the main() method.
To run the jar file I do the following

Please help to solve this problem.
Thank you
Garandi
[ January 13, 2003: Message edited by: Garandi Garandi ]
 
Matt Ghiold
Ranch Hand
Posts: 213
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

jar -cfvm client.jar ClientManifest scjd\starting\suncertify\client\*.*

Start your jar file creation at the starting level and this problem will go away. What's happening is your files package structure is looking like this starting.suncertify....
You want your jar file package to start at suncertify, so cd into your starting directory and run your previous command from there.
 
Garandi Garandi
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, but now I get the following error.

Exception in thread "main" java.lang.NoClassDefFoundError: suncertify/gui/Startu
pDialog
at suncertify.client.FlightdataPresenter.<init>(FlightdataPresenter.java
:20)
at suncertify.client.FlightdataPresenter.main(FlightdataPresenter.java:3
9)

Although StartupDialog is in gui.jar and gui.jar is in classpath.
Thank you
Garandi
[ January 13, 2003: Message edited by: Garandi Garandi ]
 
Ken Krebs
Ranch Hand
Posts: 451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Garandi,
The Main-Class line in your mainfest file is a path, not a package name. It should look like this:
Main-Class: suncertify/client/FlightdataPresenter
Note the use of / instead of .
Ken Krebs, a.k.a kktec
SCJP 1.4
 
Bernhard Woditschka
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think so I'm using

which works fine on xp, w2k, linux, solaris
hava a look at Sun's Tutorial
Bern
[ January 13, 2003: Message edited by: Bernhard Woditschka ]
 
Garandi Garandi
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ken,
I guess Bernhard is right, Main-Class is not the problem.
Thank you
Garandi
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Garandi Garandi:
Exception in thread "main" java.lang.NoClassDefFoundError: suncertify/gui/StartupDialog
Well? Is this class in your jar or not? If you constructed the jar using
jar -cfvm client.jar ClientManifest scjd\starting\suncertify\client\*.*
Then it will contain only the client package and subpackages. Make sure you include all classes you will need in the jar.
You can view the contents of a jar using the t flag:
jar -tf client.jar
HTH
- Peter
 
Garandi Garandi
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter
Exception in thread "main" java.lang.NoClassDefFoundError: suncertify/gui/StartupDialog

StartupDialog.class is in a different jar file, namely gui.jar, and I have gui.jar in my classpath.
Thank you
Garandi
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Garandi Garandi:
StartupDialog.class is in a different jar file, namely gui.jar, and I have gui.jar in my classpath.
That last point is irrelevant.
From the java tool documentation in the JDK:
-jar
Execute a program encapsulated in a JAR file. [...] When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

You will have to use a Class-Path manifest attribute.
- Peter
 
Garandi Garandi
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic