开发者

Basic Java environment question:

开发者 https://www.devze.com 2022-12-24 13:21 出处:网络
CLASSPATH PATH Which goes into User and which goes into System?I get different answers from different sites.

CLASSPATH PATH

Which goes into User and which goes into System? I get different answers from different sites.

Thanks开发者_开发问答.


CLASSPATH : An environment variable which specifies the directories to search for classes.

e.g: When I build a J2EE application, i would need servlet-api.jar, as this is not provided by the standard Java Library, you need to tell the compiler (javac in my case).

I can do this by either:

javac -classpath "some-path" my_program.java

or

CLASSPATH="some-path"
javac  my_program.java

or

mv some-path/library.jar /usr/lib/jvm/java-(version)-sun/lib
javac my_program.java

The thid option would work only if you are a system administrator. If you need to make your changes permanent, export CLASSPATH in your bashrc (or some other way in windows)

Note: that when you import a jar file from an IDE (eclipse/netbeans), it does most of the hardwork for you.You only need to do all this if you are running your application from command line.

PATH: environment variable that specifies a path to look for executables. So javac in previous case is accessible only if the location of binary is in the PATH environment variable.


It doesn't really matter. The "System" versus "User" difference only changes who gets the variables; all users, or only you.


Classpath goes into System ... I don't know which PATH are you talking about? but you should check this

PATH => System PATH? then that also belongs to system... but that's not java specific.

Ohh! am I getting the question right?


All environment variables have system-wide defaults (if you included "not defined" as a default value), and the system-wide default can be configured by the system administrator. Individual users can override the default for their own user accounts. For most systems, the system-wide defaults are given in /etc/profile, /etc/bashrc, or some other configuration file in the /etc directory. The user can override environment variables in ~/.login, ~/.bashrc, ~/.cshrc, or some other hidden file (which doesn't have to exist) in their home folder, depending on which shell is their default and based on whether they would like the environment to be setup for the whole login session or for their terminal session.

0

精彩评论

暂无评论...
验证码 换一张
取 消