Solved

Access to  Win32/NT environment variables in Java?

Posted on 1998-02-06
1
290 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

863 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

26 Experts available now in Live!

Get 1:1 Help Now