?
Solved

classpath env var not set write i think?

Posted on 2004-09-01
15
Medium Priority
?
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 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