-
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
retrieve "C:\TEMP"?
-
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");
PC2
"Shawn" <shawnh@delphiresearch.com> wrote in message
news:3b55f11e$1@news.devx.com...
>
> 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
> retrieve "C:\TEMP"?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks