Solved

excutable jar file

Posted on 2003-12-06
9
404 Views
Last Modified: 2013-11-23
I have read some articles, and followed those step, but wasn't successful.
I have WebCrawler.class and CrawlerException.class under same dir.
I created myManiFest and content the following lines

Manifest-Version: 1.0
Main-Class: WebCrawler

In the same dir, I created jar file by typing the following:

jar cmf myMiniFest dkim18.jar WebCrawler.class CrawlerException.class

and got dkim18.jar file, but when I excuted the jar file by typing

java -jar dkim18.jar

I have "NoClassDefFoundError"

What did I do wrong?

0
Comment
Question by:dkim18
  • 4
  • 3
  • 2
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9888834
Is the WebCrawler class in a package? If so, that should be reflected in the Main-Class declaration
0
 

Author Comment

by:dkim18
ID: 9888961
Yes, WebCrawler class in a package

package dkim18.crawler;

So, I changed myManiFest file like this:

Manifest-Version: 1.0
Main-Class: dkim18.crawler.WebCrawler

But, still have same problem.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9888996
Try putting a couple of blank lines after the Main-Class in the manifest (this was a bug).

Go through each step carefully - it;s easy to make an error.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:dkim18
ID: 9889018
Actually, a little different err msg, but same " NoClassDefFoundError" error.
0
 

Author Comment

by:dkim18
ID: 9889071
I put a couple of blank lines after the Main-Class in the manifest and went through again.
but same error.
Should I make myManiFest excutable?
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 125 total points
ID: 9889142
This is what i did step-by-step

1. Create following manifest and save as mf.txt

Manifest-Version: 1.0
Main-Class: dkim18.crawler.WebCrawler

2. Create and compile class

javac dkim18/crawler/WebCrawler.java

3. Create jar

 jar -cfm   dkim18.jar mf.txt ./dkim18/crawler/WebCrawler.class

4. Run it

java -jar dkim18.jar


0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 9890133
you need to include all the required application classes in your jar with the matching directory structure.

from the directory containing the dkim18 directory run:

jar -cfm   dkim18.jar mf.txt dkim18/crawler/WebCrawler.class dkim18/crawler/CrawlerException.class

The follwoing can be used if there are only two classes in the crawler directory:

jar -cfm   dkim18.jar mf.txt dkim18/crawler/*.class

And ensure your Main-Class attribute contains the fully qualified classname as mentiuoned above.
0
 
LVL 92

Expert Comment

by:objects
ID: 9890299
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9891854
8-)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 98
check java version using powershell 13 92
Java exception bubble up 2 18
hibernate example for saving data 19 40
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question