| Author |
Problems with jr.jar even though compile runs. Assignment OOP-1 DaysOld.java
|
margaret gillon
Ranch Hand
Joined: Nov 12, 2008
Posts: 61
|
|
I am working on MAC OSX leopard 10.5.8. I am on OOP-1. I can compile my class but when I try and run it I get an error.
macbook: java mmg$ javac -classpath /Users/mmg/java/jr.jar /Users/mmg/java/DaysOld.java
macbook:java mmg$ java DaysOld 2009-1-1
Exception in thread "main" java.lang.NoClassDefFoundError: com/javaranch/common/GDate
This is my version information.
macbook:~ mmg$ java -version
java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02-304)
Java HotSpot(TM) Client VM (build 1.5.0_19-137, mixed mode, sharing)
I found another post in the cattle drive forum (2001/08/20) and it seems the person had a bad .zip file of the javaranch class. They re-downloaded and the problem was resolved. I have re-downloaded the jr.jar and no change.
Any suggestions welcome.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9090
|
|
If you are including the jar file at compile time, then include it at runtime too. try
[I've never used machintosh so I don't know what the path separator on it is, I've written ; which is used on windows]
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 26710
|
|
|
The path separator on a Mac is probably : like on Unix.
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 9982
|
|
Campbell Ritchie wrote:The path separator on a Mac is probably : like on Unix.
Correct.
I ran a simple test just to show I am running the same versions and to show the classpath in use on my Mac:
As you can see from lines 2 & 4, I am using the same versions of OS/X and Java. Specifying the classpath when running the java command allowed me to include the jar file. Note the period (.) that is explicitly named in the classpath so that I can ensure that I have the current working directory included when running my program.
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
margaret gillon
Ranch Hand
Joined: Nov 12, 2008
Posts: 61
|
|
Yes it had to be a : not a ;
This worked.
java -classpath /Users/mmg/java/jr.jar:. DaysOld 2009-1-1
Thanks for the help.
|
 |
 |
|
|
subject: Problems with jr.jar even though compile runs. Assignment OOP-1 DaysOld.java
|
|
|