This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

OOP-1, jr.jar, and the classpath on OSX (10.7.5)

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've read that you can put JAR files on a mac in /System/Library/Java/Extensions and they become available to the JVM.

But I put jr.jar in there, and it doesn't seem to be recognized.

This code compiles:

import com.javaranch.common.*;
public class DaysOld
{
public static void main (String [] args)
{
GDate dateIn = new GDate();

System.out.println( "just a stub" );
}
}

But when I run it, the class isn't found

java.lang.NoClassDefFoundError: com/javaranch/common/GDate
at DaysOld.main(DaysOld.java:6)
Caused by: java.lang.ClassNotFoundException
at edu.rice.cs.plt.reflect.PathClassLoader.findClass(PathClassLoader.java:148)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more


Am I missing something?
 
Steven Lacher
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Turned out I WAS missing something.

I'm using the DrJava IDE to write my code. It's a simple IDE without lots of fancy bells and whistles. HOWEVER, it does have its own classpath settings. I put the jar in the top level folder I'm using for the cattledrive, and then used the preferences/resource locations command to add the jr. jar.

Voila!

I also tested just using the terminal, after adding a .bashrc file to my drive, as follows:

Use a text editor (e.g., TextEdit) to add the following line to the file /Users/username/.bashrc.

export CLASSPATH=.:/Users/username/cattledrive/

(or wherever it is you're keeping the jr.jar.)
 
Sheriff
Posts: 9099
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Steven. That's a good note to share.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!