This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating the .jar file

 
Charlie Goth
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is driving me mad.
Any help would be appreciated, I've looked at the trail at java.sun.com but I'm getting a java.lang.NoClassDefFoundError when I try to execute the file.

Files:
code <dir>
db-2x2.db
MANIFEST.MF

I'm typing:
"jar cvf runme.jar code db-2x2.db"
"jar umf manifest.mf runme.jar"
"java -jar runme.jar" - which gives me "Exception in thread "main" java.lang.NoClassDefFoundError: code/both/RunApp (wrong name: both/RunApp)

Manifest.mf:
"Main-Class: code.both.RunApp
"

The RunApp file is definately in the jar and definately has a public static void main(String[] args) method.

Any ideas?
 
Denis Spirin
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may read about it here:

http://www.cs.princeton.edu/introcs/85application/jar/jar.html

But anyaway, check out your manifest file. Say, copy contents from the link above and correct the file name.

1. Create manifest file
-------
Manifest.mf:

Manifest-Version: 1.0
Main-Class: your package.somepath.Start

-------

2. Make executable jar

$ jar cmf Manifest.mf runme.jar suncertify

// suncertify is the root directory for your packages
 
Charlie Goth
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not having much luck

What should go in the Main-Class section of the manifest?
The main class is in code/both/ BUT the package is just both.
I get slightly different output depending on what I specify as the Main-Class:
With code.both.RunApp I get a NoClassDefFoundError: code/both/RunApp (Wrong name: both/RunApp)with a stacktrace.

With both.RunApp I just get NoClassDefFoundError: both/RunApp

I've run what you suggested on a little app (1 class) and it works fine, so I think it's the code directory that is screwing it up (with a little help from me).
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Charlie,
There are 2 jar files for the assignment.
1. runme.jar file - this is supposed to contain only the class files.
As Denis mentioned, this is supposed to contain only, suncertify directory as the root package.
2. The complete jar file consisting the runme.jar file, the code directory(source code), version.txt, db2x2.db file, docs directory etc. This has a different name, something like SCJD_YourPrometricID.jar. Sorry, I cannot remember what exactly it is at this moment.May be the others can help you on this.After completion of the assignment, we upload this jar file for evaluation.

The examiner is expected to unjar the second jar file into a directory and then use runme.jar file to run/test our application.

runme.jar is expected to contain a maninfest file with the
Main-Class: entry. In ur case, I guess it could be

Main-Class: both.RunApp.

RunApp is the name of the class that has the main method and
both is the package in which RunApp class is defined.

Remember code directory contains the source files and is not used to run
your application.

if suncertify is not your root package(it should be for the assignment!), then create the runme.jar file with whatever root package/directory you have.

example:

jar cmf Manifest.mf runme.jar both

(if both is ur root package containing the other subpackages and classes)

You can test your application with the runme.jar file. Ignore the second jar file for the time being, you can do it later when you are ready to upload the assignment.

BTW, your package names are different, which assignment are you working on?
 
Charlie Goth
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did misread some stuff, so I'll try again.
I didn't have a base directory, I'm getting Eclipse to move things around now though.

Thanks
Charlie
 
Charlie Goth
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks again

Charlie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic