Solved

excutable jar file

Posted on 2003-12-06
9
409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

756 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