Solved

excutable jar file

Posted on 2003-12-06
9
417 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

623 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