File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Cattle Drive and the fly likes OOP-1, jr.jar, and the classpath on OSX (10.7.5) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "OOP-1, jr.jar, and the classpath on OSX (10.7.5)" Watch "OOP-1, jr.jar, and the classpath on OSX (10.7.5)" New topic

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

Steven Lacher

Joined: Dec 26, 2002
Posts: 12
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(
Caused by: java.lang.ClassNotFoundException
at edu.rice.cs.plt.reflect.PathClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 1 more

Am I missing something?

SCJP 1.4
Steven Lacher

Joined: Dec 26, 2002
Posts: 12
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.


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.)
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
Thanks, Steven. That's a good note to share.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: OOP-1, jr.jar, and the classpath on OSX (10.7.5)
It's not a secret anymore!