Windows environment variables
How do I get and set Windows environment variables from within a Java app.?
For example, if I set "TEMP=C:\TEMP" in the system properties, how do I
Re: Windows environment variables
First of all, don't use environment variables to pass information to Java
programs. The Java way to pass small amounts of constant information into a
program is to use a properties file; see the class java.util.Properties.
However, if you need to pass an existing environment variable, you use
the -D parameter on the "java" command, like this in Windows:
java -DTEMP=%TEMP% yourClass
and then in the Java program you get the TEMP system property, like this:
String temp = System.getProperty("TEMP");
"Shawn" <email@example.com> wrote in message
> How do I get and set Windows environment variables from within a Java
> For example, if I set "TEMP=C:\TEMP" in the system properties, how do I
> retrieve "C:\TEMP"?
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center