Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between a System property and environment variable

I am not clear about this. When I run a java App or run an Applet in applet viewer, (in the IDE environment), System.getProperty("java.class.path") gives me the same as System.getenv("CLASSPATH") which is the CLASSPATH defined in my env variable.

But when I deploy my applet to webserver and access it from the same computer as a client, I get different results for the two. (System.getProperty("java.class.path") only points to JRE home and System.getenv("CLASSPATH") returns null).

And here is some other things that make me wonder:

For the applet part, the env var JAVA_HOME, I get the same result when deploying the applet in a browser as well as Applet Viewer.

And if I define myself a env variable at system level, and use getenv("envName") the result is null. Is there anyway I can define one and get it in my Java program?

like image 448
Khue Vu Avatar asked May 19 '10 07:05

Khue Vu


People also ask

What is a system property?

System properties include information about the current user, the current version of the Java runtime, and the character used to separate components of a file path name. The following table describes some of the most important system properties. Key. Meaning.

What are system and environment variables?

An environment variable is a dynamic "object" on a computer, containing an editable value, which may be used by one or more software programs in Windows. Environment variables help programs know what directory to install files in, where to store temporary files, and where to find user profile settings.

What is the difference between system variables and environment variables in Windows?

System environment variables are globally accessed by all users. User environment variables are specific only to the currently logged-in user.

What is a Java system property?

Java™ system properties determine the environment in which you run your Java programs. They are similar to system values or environment variables in IBM® i. Starting an instance of a Java virtual machine (JVM) sets the values for the system properties that affect that JVM.


1 Answers

Environment variables are specific to the operating system. Properties are JVM only.

like image 68
Konrad Garus Avatar answered Sep 18 '22 15:09

Konrad Garus