Solved

classpath env var not set write i think?

Posted on 2004-09-01
15
370 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
ID: 11956743
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
ID: 11956784
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
ID: 11956816
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
ID: 11957481
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
ID: 11957551
pls try with following
jar -cvf cabCreator.jar createCab/*

0
 

Author Comment

by:bens2333
ID: 11957769
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
ID: 11957890
That's weird, it should work. Can you try deleteing the jar file and redoing everything from scratch?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:bens2333
ID: 11958079
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
ID: 11958490
> 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
ID: 11958498
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
ID: 11958628
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
ID: 11958669
aren't they getting picked up by your classpath anyway?
0
 
LVL 35

Expert Comment

by:girionis
ID: 11960810
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
ID: 12319466
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.

920 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

16 Experts available now in Live!

Get 1:1 Help Now