Created
August 17, 2016 15:08
-
-
Save trplll/53965857bb351433ad7b062ef993186f to your computer and use it in GitHub Desktop.
Using Java to find information about the local machine and java config in windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package basics; | |
import java.awt.List; | |
import java.io.PrintStream; | |
import java.net.InetAddress; | |
import java.net.UnknownHostException; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Iterator; | |
import java.util.Properties; | |
public class JavaSystemInfoTools { | |
static String hostName; | |
static public void printer(String in){ | |
System.out.println(in+": "+System.getProperty(in)); | |
} | |
public static void main(String[] args) { | |
printer("file.separator" ); | |
printer("Path.seperator" ); | |
printer("line.separator" ); | |
printer( "java.class.path"); | |
printer("java.home" ); | |
printer( "java.vendor"); | |
printer( "java.vendor.url"); | |
printer("os.arch" ); | |
printer("os.name" ); | |
printer("os.version" ); | |
printer("user.dir" ); | |
printer("user.home" ); | |
printer("user.name" ); | |
try | |
{ | |
InetAddress addr; | |
addr = InetAddress.getLocalHost(); | |
hostName = addr.getHostName(); | |
} | |
catch (UnknownHostException ex) | |
{ | |
System.out.println("Hostname can not be resolved"); | |
} | |
ArrayList<String>strs = new ArrayList<String>(); | |
strs.addAll(Arrays.asList(System.getProperties().toString().split(","))); | |
for (String string : strs) { | |
System.out.println(string); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment