|
|
Program: How to get process environment variables in java at runtime?
Description: |
The ProcessBuilder.environment() method returns you the ProcessBuilder's environemnt.
Below example shows how to read it.
|
Code: |
package com.java2novice.processbuilder;
import java.util.Map;
import java.util.Set;
public class MyEnvDetails {
public static void main(String a[]){
ProcessBuilder pb = new ProcessBuilder();
Map<String, String> envMap = pb.environment();
Set<String> keys = envMap.keySet();
for(String key:keys){
System.out.println(key+" ==> "+envMap.get(key));
}
}
}
|
|
Output: |
SHELL ==> /bin/bash
JAVA_MAIN_CLASS_37131 ==> com.java2novice.processbuilder.MyEnvDetails
APP_ICON_385 ==> ../Resources/Eclipse.icns
com.apple.java.jvmMode ==> client
TMPDIR ==> /var/folders/2n/yf7x2fdx3bv6g31hn4stv1y0_qsrzm/T/
__CF_USER_TEXT_ENCODING ==> 0x157CE3F4:0:0
PATH ==> /usr/bin:/bin:/usr/sbin:/sbin
COMMAND_MODE ==> unix2003
DISPLAY ==> /tmp/launch-DwnV41/org.x:0
USER ==> root
com.apple.java.jvmTask ==> JNI.java
JAVA_STARTED_ON_FIRST_THREAD_385 ==> 1
Apple_Ubiquity_Message ==> /tmp/launch-u3pr6e/Apple_Ubiquity_Message
LOGNAME ==> root
Apple_PubSub_Socket_Render ==> /tmp/launch-nboOhX/Render
|
|
|
|
|
List Of All ProcessBuilder Class Sample Programs:- How to invoke other applicatons in java?
- How to run operating system specific command and read its output?
- How to get process environment variables in java at runtime?
- How to run ProcessBuilder with list of commands?
|
|
|
Preemptive scheduling Vs Time slicing?
Preemptive scheduling: The highest priority task executes until it enters
the waiting or dead states or a higher priority task comes into existence.
Time slicing: A task executes for a predefined slice of time and then reenters
the pool of ready tasks. The scheduler then determines which task should execute
next, based on priority and other factors.
When I do good, I feel good; when I do bad, I feel bad, and that is my religion.
-- Abraham Lincoln
|