Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix system variables

Status
Not open for further replies.

Pitone

Programmer
Oct 12, 2004
15
IT
Can someone please help me to find the way to read system's variables (unix) from a java class?
 
As I suggested in your other posts regarding running OS programs, you should use the IO streams of the Process object.

Here is an example :

Code:
import java.io.*;
public class Test {
 public static void main(String args[]) throws Exception {
	Process p = Runtime.getRuntime().exec("env");
	BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
	String line = "";
	while ((line = br.readLine()) != null) {
		System.out.println(line);
	}
 }
}

In the future, please try to restrict one problem to one thread :)

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top