File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Problem with jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with jar" Watch "Problem with jar" New topic

Problem with jar

Snylt Master
Ranch Hand

Joined: Jul 07, 2001
Posts: 55
Hello java ranchers!
I've read the topics here about jar and suns tutorial about jar. Doesn't seems to get it right anyway.
I've created 2 classfiles in diffrent directory's ( testing protected etc ). The classes compile and it can be run without any compications. When I try too make a jar file it doesn't seems to work.

I've created the jar file like this
jar cmf classLoader.txt test.jar chat\test\test.class chat\test1\test1.class
in my classLoader.txt file it just say "Main-Class: chat\test1\test1". I have altso tested to just type "Main-class: test1" and "Main-Class: test1.class" and so on.
The seems to be right and the jarfile looks fine , but when I try too run it like this:
java -jar test.jar I get an errormessage like this:
Exception in thread main. NoClassDefoundError.
How come when it runs without jar?
Hope you can understand what I meen.

Preparing for the Java 2 Certification exam
[This message has been edited by Snylt Master (edited July 10, 2001).]

Preparing for the Java 2 Certification exam
Lucas Richardson
Ranch Hand

Joined: Jul 08, 2001
Posts: 32
Put that in a file called wheretostart.txt
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Where does your jar sit, and what is your classpath?
Sometimes just putting the jar file IN the classpath helps.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Snylt Master
Ranch Hand

Joined: Jul 07, 2001
Posts: 55
I have included the jar file path in my classpath. Ive tried the wheretostart.txt. I dunno why the textfile must be named like this? Seems to me that i can name my testfile anything. All it does is copying the line in the textfile to the line in Is there another way of making a jar file. I think it is my package declaration wich is wrong. Class test goes in package chat\test. and class test 1 goes in package chat\test1. When compiling I used the following line.
javac chat\test\
javac chat\test1\ which gave me to classfiles.
I've added the following line to autoexec.bat
Can't think of anything else to do. Please help.
// Snylt Master
I agree. Here's the link:
subject: Problem with jar
It's not a secret anymore!