Mac OS X environment variables

In my efforts to do things properly, I’ve removed my various .jar files from the Library/Java/Extensions directory, and am attempting to modify the CLASSPATH environment variable to work as I can only assume it should; but I’ve hit a few blocks…

  1. ‘export Classpath=[path]’ does not work for more than the one time I run Terminal. If I close and reopen, it’s no longer set. I was under the impression that environment variables were more permanent than that.

Anyhow, assuming I was wrong, I went ahead and edited (read "added) my ~/.profile to include the above ‘export’ line. Now I get the environment variable right on every time… Only problem is that 2) when I type, say “java demos.gears.Gears” from within the jogl-demos/build directory, it still won’t run. Okay, so I add the demos .jar file:

java -cp jogl-demos.jar demos.gears.Gears

This works, but for some reason, it’s not reading ANYTHING that’s already in my CLASSPATH environment variable to be included in the running of said java app. If, however, I type:

java -cp jogl-demos.jar:$CLASSPATH demos.gears.Gears

…the program runs without a hitch.

So the question comese dow to – what am I doing/interpreting wrong/incorrectly? Is the CLASSPATH variable just a convenience thing, perhaps, and not actually intended to be a default search path for classes when starting a java program?

sorry, I’m a tad frustrated at my own incompetence

Any help is appreciated.
–Scott

This is as expected.

-cp or -classpath replaces the environemnt classpath with the one you sepcifiy for that run of Java

What shell are you using?
There are all sorts of ugly unix text files that you have to edit to have your environment set up for every shell (Terminal) you open. It’s an asinine carry-over from the 70’s or earlier that to this day nobody has bothered to correct. Even OS X that managed to add a decent GUI to unix left this part alone. I think it’s based on unix nerds wanting to feel that knowing how to do this arcane stuff makes them superior or something, so they pretend that a real UI isn’t worth making… :slight_smile:

See also:
http://www.macosxhints.com/article.php?story=20040715133738459&query=environment+variable

Thanks for the responses. I’m using bash… just the basic terminal default. The CLASSPATH variable I set does seem to be working now when I access a jogl app from the terminal. Interestingly, however, I can’t run my projects through NetBeans anymore, though, as it doesn’t seem to be asking about the DYLD_LIBRARY_PATH variable to access the .jnilib files from JOGL… >.<;;

–Scott