Solved

excutable jar file

Posted on 2003-12-06
9
400 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
 

Author Comment

by:dkim18
ID: 9889018
Actually, a little different err msg, but same " NoClassDefFoundError" error.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now