Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with jr.jar even though compile runs. Assignment OOP-1 DaysOld.java

 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9520
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]
 
Campbell Ritchie
Sheriff
Pie
Posts: 48946
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The path separator on a Mac is probably : like on Unix.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11878
195
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic