0

I installed OS X El Capitan and, along with it, Oracle's Java 8 SDK. I've already verified that, using java -version, java is correctly installed. I need to add some user classes to the file path, but, when I use echo $CLASSPATH, I cannot see the actual path being used by OS X. How can I know where should I install my user classes?

3

First, I found out that my Yosemite Installation has also no CLASSPATH set. Second, when issueing

$ java -help

it directed me to the URL:

Java SE documentation

Klicking there led me to How Java Runtime finds classes and within there it is written:

"[…] User classes are classes that are defined by developers and third parties and that do not take advantage of the extension mechanism. You identify the location of these classes with the -classpath option on the command line (preferred) or with the CLASSPATH environment variable. See Setting the Class Path.[…]"

Effectively it says "put your classes wherever you want and just run java -classpath <userclassdirectory>.

Just take time to read the complete document.

  • 1
    And the Oracle Java Document says clearly that setting the CLASSPATH variable is NOT the proper way... :-) And the default paths can also be got from the "Setting the Class Path" link... – Garex Nov 25 '15 at 11:38
  • Ok... the thing is... I've not programmed in java for some years, so I did not remember how that was done. I remembered that I used to put my files in a path and also that I had to configure it. But well, in the end it is something that can be done after reading $ java -help. – JPCF Nov 25 '15 at 16:04
  • @Garex hmm sorry for not being clear from the beginning. I'm trying to run a make script that I cannot change. In former times, I'd simply add a new path to $PATH. But now, I do not know how to add the path before script's execution. Should I EXPORT it before running make? – JPCF Nov 26 '15 at 16:48
  • Try this: CLASSPATH=${CLASSPATH}:<your local path> make. If this does not work, try exporting it before. – Garex Nov 26 '15 at 20:23
0

Add an export line to bash profile. Take note that it is not a recommended practice as explained in other answers and Oracle's documentation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .