aspose file tools*
The moose likes Java in General and the fly likes Is there any difference between java.classpath and environment variable CLASSPATH?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is there any difference between java.classpath and environment variable CLASSPATH??" Watch "Is there any difference between java.classpath and environment variable CLASSPATH??" New topic
Author

Is there any difference between java.classpath and environment variable CLASSPATH??

Bhairava Surya
Ranch Hand

Joined: Aug 19, 2007
Posts: 45
Hi All,

Is there any difference between java.classpath and environment variable CLASSPATH??

because when I am executing a class


both are showind diff values. I ran this using eclipse.


Thanks & Regards,
Ravi.
Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

The preferred way to extract system-dependent information is the system properties of the java.lang.System.getProperty methods and the corresponding getTypeName methods of the Boolean, Integer, and Long primitive types.
The signature of the method getenv is like this - public static String getenv(String name). To get get the value of the specified environment variable we need to pass the name of the variable as parameter. This method is deprecated since 1.3 because of bugs.
java.class.path is used to find directories and JAR archives containing class file.


dkj4jdk
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

System.getProperty("java.class.path") includes paths added using the -classpath / -cp JVM argument (defaulting to . if you don't specify any). That does definitely not have to be the same as the environment variable.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there any difference between java.classpath and environment variable CLASSPATH??