473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to read Enviroment variable in Java?

Hi,

I have a Java program that needs to access the value of variable
PATH (Set in Unix enviroment by setenv or DOS enviroment by PATH
statement). How do I access it in Java?

Thanks in advance,

Nikhil
Jul 17 '05 #1
2 5143

"Nikhil Barthwal" <nb**@iitk.ac.in> wrote in message
news:9d**************************@posting.google.c om...
Hi,

I have a Java program that needs to access the value of variable
PATH (Set in Unix enviroment by setenv or DOS enviroment by PATH
statement). How do I access it in Java?


You may execute (using method Runtime.exec()) the following command line
Windows 95/98/Me: command.com /c set
Windows NT/2000/XP: cmd /c set
Unix: env
and then parse output. It must have format like this:
<variable name>=<variable value>

By the way, Apache Ant uses this aproach. Look at:
org/apache/tools/ant/taskdefs/Execute.java
Jul 17 '05 #2
nb**@iitk.ac.in (Nikhil Barthwal) wrote in message news:<9d**************************@posting.google. com>...
Hi,

I have a Java program that needs to access the value of variable
PATH (Set in Unix enviroment by setenv or DOS enviroment by PATH
statement). How do I access it in Java?

Thanks in advance,

Nikhil


Older Java and the newest 1.5 have getenv() method in the java.lang.System class.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave N | last post by:
I posted this request earlier and was directed to some code that would not work. I am using win2000 Professional. I want to find out who is logged in to the computer and take that ID look it up...
2
by: Andrej Litowka | last post by:
Hi All! If anybody know, how I cann set an enviroment variable (with ANSI C) on Windows similar like on Linux. I tried setenv, but the function doesn't work correct on Windows - it sets env....
19
by: Mark Richards | last post by:
I've been programming for many years, but have only recently taken a deep "C" dive (bad pun, i know) and need a lot of explanation from an expert. My questions center around those mysterious...
4
by: Benne Smith | last post by:
In our company, i have three servers; 1) a development server (mine only - here i make daily changes and test my stuff) 2) a test server (for the users to test milestone builds - changes weekly)...
5
by: kolives | last post by:
Friends i need your help... My lecturer gave me a project o write on encrption and decryption of data (large message body) across a network enviroment. with java using RSA I've been trying some...
3
by: madsornomads | last post by:
Hi all, I have a problem with reading from a Java server after I have written to it - it just hangs. It works fine if I just write to the server and not try to write. I have read the HOWTO on...
3
by: limnath | last post by:
Hello everyone, I am new here and very new to PERL, just reading a book on scripting in PERL. I have a quick need which I hope anyone can kindly help me. I need to invoke a Java program from...
9
by: sulekhasweety | last post by:
dear all, can anyone explain the differences between pointer variable and reference variables ?
9
by: George | last post by:
I am trying to implement postponed initialization (object is not initialize till requested). public class clsStore { volatile List<clsPictureGroup_lstPictureGroups = null; public...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.