Solved

classpath env var not set write i think?

Posted on 2004-09-01
15
369 Views
Last Modified: 2013-11-23
i have a problem with a app when i run it using {java -classpath ".;./lib/msbase.jar;./lib/msutil.jar;./lib/mssqlserver.jar" createCab/CreateCabMain} it all works fine, BUT when i create a jar file i get a Exception in thread "main" java.lang.NoClassDefFoundError: createCab/CreateCabMain.

here is what i do to create the jar....

my manifest fil:
Main-Class: createCab.CreateCabMain
Class-Path: c:\Program Files\Sun\AppServer\jdk\lib\msbase.jar c:\Program Files\Sun\AppServer\jdk\lib\msutil.jar c:\Program Files\Sun\AppServer\jdk\lib\mssqlserver.jar .

the jar command:
jar cvmf mymanifest cabCreator.jar createCab/AtmCsvFileWriter.class createCab/CreateCabMain.class createCab/DataBaseConnector.class createCab/DataGetter.class createCab/MainFrame.class

and my classpath env var ( i set it cause i thought the one in the manifest was not working):
c:\Program Files\Sun\AppServer\jdk\lib\msbase.jar;c:\Program Files\Sun\AppServer\jdk\lib\msutil.jar;c:\Program Files\Sun\AppServer\jdk\lib\mssqlserver.jar;.

thanks....



0
Comment
Question by:bens2333
  • 4
  • 4
  • 3
  • +3
15 Comments
 
LVL 35

Expert Comment

by:girionis
Comment Utility
Can you make sure you have left a couple of blank lines at the end of your manifest file?
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
Also what happens if you do:

java -classpath .;./lib/msbase.jar;./lib/msutil.jar;./lib/mssqlserver.jar;cabCreator.jar createCab.CreateCabMain

of even

java -classpath .;./lib/msbase.jar;./lib/msutil.jar;./lib/mssqlserver.jar; -jar cabCreator.jar
0
 
LVL 3

Expert Comment

by:CI-Ia0s
Comment Utility
girionis, I've never needed to do that... (I think it's a superstition :P ).

bens, is the main class "createCab.CreateCabMain" or "CreateCabMain" within the folder "createCab"? If it's CreatCabMain (within the folder createCab), I don't think you need the "createCab/" prefix in the manifest file. The Main-Class attribute should be just the class, I think.
0
 

Author Comment

by:bens2333
Comment Utility
girionis...

i put a line (3) empty lines at the end same results.

run thei scommand:
java -classpath ;./lib/msbase.jar;./lib/msutil.jar;./lib/mssqlserver.jar;cabCreator.jar createCab.CreateCabMain

worked fine....

run this command:
java -classpath .;./lib/msbase.jar;./lib/msutil.jar;./lib/mssqlserver.jar -jar cabCreator.jar

same error message

dir structure

all the .class files are contained in the createCab dir and i removed the prefix from the manifest file still same error....

thanx...
0
 

Expert Comment

by:robertashok
Comment Utility
pls try with following
jar -cvf cabCreator.jar createCab/*

0
 

Author Comment

by:bens2333
Comment Utility
rob,
    i ran that command but got an error back that i have no manifest file.
jar -cvf cabCreator.jar createCab/*

after running again with my manifest file i got the same error as before (class not found)

jar -cvmf mymani cabCreator.jar createCab/*

mymani content:

Main-Class: createCab.CreateCabMain
Class-Path: c:\Program Files\Sun\AppServer\jdk\lib\msbase.jar c:\Program Files\Sun\AppServer\jdk\lib\msutil.jar c:\Program Files\Sun\AppServer\jdk\lib\mssqlserver.jar .


0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
That's weird, it should work. Can you try deleteing the jar file and redoing everything from scratch?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:bens2333
Comment Utility
i delete the jar each time i create a new.... do you mean delete and recreate the manifest, if so i do not know what to change in the file... it looks right to me)...
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> Class-Path: c:\Program Files\Sun\AppServer\jdk\lib\msbase.jar c:\Program Files\Sun\AppServer\jdk\lib\msutil.jar c:\Program Files\Sun\AppServer\jdk\lib\mssqlserver.jar .

these all need to be relative entries
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
eg. put all the jars in the same directory as your main jar and use

Class-Path: msbase.jar msutil.jar mssqlserver.jar

(And you can't include ., if that was to reference any classes then you'll need to jar them)

0
 

Author Comment

by:bens2333
Comment Utility
i found the problem with just trial and error.....it had to do with the classpath.  i removed "c:" and changed the "program files" dir to its dos name "progra~1" that worked just fine. also i changed the "\" to "/" and back. it works fine either way with "\" or "/"

so my new classpath in the manifest file is:
Class-Path: \Progra~1\Sun\AppServer\jdk\lib\msbase.jar \Progra~1\Sun\AppServer\jdk\lib\msutil.jar \Progra~1\Sun\AppServer\jdk\lib\mssqlserver.jar .


thanks everyoen for trying...
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
aren't they getting picked up by your classpath anyway?
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
So it was the space in the path...

bens2333 can you please ask a question to community support: http://www.experts-exchange.com/Community_Support/ for zero points to PAQ this question and refund the points back to you?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

772 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

12 Experts available now in Live!

Get 1:1 Help Now