In this article we displayed our system properties via Tomcat. We were curious, though, how to retrieve these directly through Java. Here is how you can do this:
[usr-1@srv-1 java]$ cat FirstProperties.java public class FirstProperties { public static void main(String[] args) { System.out.println("System Information: \n"); System.out.println("Operating System: "); System.out.println(System.getProperty("os.name")); System.out.println("\nArchitecture: "); System.out.println(System.getProperty("os.arch")); System.out.println("\nOperating System Version: "); System.out.println(System.getProperty("os.version")); System.out.println("\nJava Virtual Machine Version: "); System.out.println(System.getProperty("java.vm.version")); } } [usr-1@srv-1 java]$ javac FirstProperties.java [usr-1@srv-1 java]$ java FirstProperties System Information: Operating System: Linux Architecture: i386 Operating System Version: 2.6.9-11.EL Java Virtual Machine Version: 1.5.0_05-b05 [usr-1@srv-1 java]$ |