wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with jar" Watch "Problem with jar" New topic
Author

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 mainfest.mf 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.
Cheers

------------------
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"
Sheriff

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 manifest.mf. 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\test.java
javac chat\test1\test1.java which gave me to classfiles.
I've added the following line to autoexec.bat
PATH=%PATH%;"C:\Program\Mts";c:\jdk1.3\bin"
Can't think of anything else to do. Please help.
// Snylt Master
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with jar
 
Similar Threads
classpath jar
jar files - classNotFoundException
Complie time using custom classloader for decryption.
Creating JAR File - Eclipse or otherwise
Jar manifest problem