Solved

classpath env var not set write i think?

Posted on 2004-09-01
15
374 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

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…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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:

717 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