[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

classpath env var not set write i think?

Posted on 2004-09-01
15
Medium Priority
?
378 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
14 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

831 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