开发者

java classpath variable in RHEL 5.4

I am using RHEL 5.4 linux and writing my first few java test programs.

javac and java comes by default, so I ha开发者_StackOverflow中文版ve been able to run a Hello World program.

I want to check what is the current classpath.

Nothing comes in

$ echo $CLASSPATH

or

$ env | grep -i classpath

Does it mean that the classpath variable is optional and we only set it when we want to set a project specific values?

Also, how is it able to find the standard java jars? because I am able to use System.out.println ? Does it mean that classpath is used to specify non-standard java jars, because java already knows where it has installed the standard jars, so it doesn't need CLASSPATH for its internal use..


when you do

echo $CLASSPATH

it will look for system env variables, if its not set it will be blank and by default current DIR would be the classpath.

It will first look into Bootstrap classes then Extension Classes and then User Custom classes

Also See

  • How Classes are Found ?


You can check the classpath in Java:

import java.util.Properties;

public class PrintClasspath
{

    public static void main( String[] arguments )
    {
        System.out.println( System.getProperty( "java.class.path" ) );
    }

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜