Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access to  Win32/NT environment variables in Java?

Posted on 1998-02-06
1
Medium Priority
?
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 32

Accepted Solution

by:
jhance earned 400 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 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