Get System Environment Details using Java

In this example, We will show you about, How to Get System Environment Details using Java. The example were tested and output has been shared in the same post.

SystemEnvironmentDetails.java

package com.dineshkrish.utilites;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* 
* @author Dinesh Krishnan
*
*/
public class SystemEnvironmentDetails {
public static void main(String[] args) {
// Getting System Environment Details
Map<String, String> envMap = System.getenv();
// Getting all Keys from Map
Set<String> keys = envMap.keySet();
System.out.println("Available Environment Details");
System.out.println("------------------------------");
// Creating Iterator Objec
Iterator<String> iterator = keys.iterator();
if(iterator != null) {
while(iterator.hasNext()) {
String key = iterator.next();
System.out.println(key+" - "+envMap.get(key));
}
}
}
}

Output

Available Environment Details
——————————
USERDOMAIN_ROAMINGPROFILE – DESKTOP-AVMUB26
LOCALAPPDATA – C:\Users\Dinesh\AppData\Local
PROCESSOR_LEVEL – 6
USERDOMAIN – DESKTOP-AVMUB26
FPS_BROWSER_APP_PROFILE_STRING – Internet Explorer
LOGONSERVER – \\DESKTOP-AVMUB26
SESSIONNAME – Console
ALLUSERSPROFILE – C:\ProgramData
PROCESSOR_ARCHITECTURE – AMD64
ANDROID_HOME – G:\Software\Android\SDK
PSModulePath – C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
SystemDrive – C:
ERLANG_HOME – C:\Program Files\erl8.1
APPDATA – C:\Users\Dinesh\AppData\Roaming
USERNAME – Dinesh
ProgramFiles(x86) – C:\Program Files (x86)
CommonProgramFiles – C:\Program Files\Common Files
Path – C:\Program Files\Java\jdk1.8.0_51\bin
FPS_BROWSER_USER_PROFILE_STRING – Default
PATHEXT – .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
OS – Windows_NT
COMPUTERNAME – DESKTOP-AVMUB26
PROCESSOR_REVISION – 3d04
CommonProgramW6432 – C:\Program Files\Common Files
ComSpec – C:\WINDOWS\system32\cmd.exe
ProgramData – C:\ProgramData
ProgramW6432 – C:\Program Files
HOMEPATH – \Users\Dinesh
SystemRoot – C:\WINDOWS
TEMP – C:\Users\Dinesh\AppData\Local\Temp
HOMEDRIVE – C:
PROCESSOR_IDENTIFIER – Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
USERPROFILE – C:\Users\Dinesh
TMP – C:\Users\Dinesh\AppData\Local\Temp
CommonProgramFiles(x86) – C:\Program Files (x86)\Common Files
ProgramFiles – C:\Program Files
PUBLIC – C:\Users\Public
NUMBER_OF_PROCESSORS – 4
windir – C:\WINDOWS

References

1. Java System Class
2. Java System.getEnv() method

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *