Solved

Access to  Win32/NT environment variables in Java?

Posted on 1998-02-06
1
279 Views
Last Modified: 2010-05-18
Is there anyway to access the environment variables of Win32/NT?  Specifically, I'd like to access the "windir" variable as a standard location of an .ini file for my application.  I looked at the output of System.getProperties() and I (at least for my installation of jdk) there is no direct mapping of this variable.

Thanks in advance.
0
Comment
Question by:mwalker
1 Comment
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 1232919
There is no direct way to do this without writing a native method and calling a Windows API.  Here is a more portable way:

You can specify a property to java when you run the interpreter.  If you're running Sun's JDK, you can do it like this:

java -DWINDIR=%WINDIR% myprog.class

Now in your application, you can get the value of WINDIR like:

String windir = System.getProperty("WINDIR");


0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now