Adding to classpath on OSX

Can someone tell me how to add to classpath on OSX?

+62
java classpath
Nov 04 '09 at 18:32
source share
5 answers

If you want to make a specific set of JAR files (or .class files) available for each Java application on your computer, it is best to add these files to /Library/Java/Extensions .

Or, if you want to do this for every Java application, but only when your Mac OS X account is running, use ~/Library/Java/Extensions instead.

EDIT: If you want to do this only for a specific application, as Torboener asked, then you will need to tell us more about how the application is packaged.

+83
Nov 04 '09 at 20:03
source share

On OSX, you can set the class path from scratch as follows:

 export CLASSPATH=/path/to/some.jar:/path/to/some/other.jar 

Or you can add to the existing classpath as follows:

 export CLASSPATH=$CLASSPATH:/path/to/some.jar:/path/to/some/other.jar 

This is the answer to your exact question; I am not saying that it is right or wrong; I will leave it for others to comment.

+33
Jul 03 '12 at 5:14
source share

If you just want to use the class path only for the current runtime. This can be done by adding the path to the class path when running the java command.

At the command line. using java -cp "path/to/your/jar:." main java -cp "path/to/your/jar:." main and not just java main

Thus, your team indicates the class path of the process where it can look for libraries.

+2
Nov 17 '16 at 18:17
source share

If your shell is tcsh or csh, you can install it in / etc / profile. Open a terminal, "vim / etc / profile" and add the following line:

setenv CLASSPATH (insert your classpath here)

-2
Nov 04 '09 at 18:42
source share

Usually there is no need for this. Primarily

 echo $CLASSPATH 

If there is something there, you probably want to check Applications → Utilities → Java.

-8
Nov 04 '09 at 18:43
source share



All Articles