tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jodd > Utils > How to get java system properties

How to get java system properties 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to get Java system properties using SystemUtil class.

File Name  :  
com/bethecoder/tutorials/jodd/utils/SystemUtilTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.jodd.utils;

import jodd.util.SystemUtil;

public class SystemUtilTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    System.out.println("Classpath : " + SystemUtil.getClassPath());
    System.out.println("Java Home : " + SystemUtil.getJavaHome());
    System.out.println("Jre Home : " + SystemUtil.getJavaJreHome());
    System.out.println("OS Name : " + SystemUtil.getOsName());
    System.out.println("Working Directory : " + SystemUtil.getWorkingFolder());
    
    System.out.println("Windows ? " + SystemUtil.isHostWindows());
    System.out.println("Linux ? " + SystemUtil.isHostLinux());
    System.out.println("Mac ? " + SystemUtil.isHostMac());
  }

}
   

It gives the following output,
Classpath : C:\WORKSPACES\JODD001\bin;C:\WORKSPACES\JODD001\lib\jodd-3.3.2.jar
Java Home : C:\Program Files\Java\jdk1.6.0_10
Jre Home : C:\Program Files\Java\jdk1.6.0_10\jre
OS Name : Windows XP
Working Directory : C:\WORKSPACES\JODD001
Windows ? true
Linux ? false
Mac ? false



 
  


  
bl  br