public static Throwable setSystemPropertyClassValue ( String property , String className ) { // Validation if ( property == null || property . trim ( ) . length ( ) == 0 ) throw new IllegalArgumentException ( "Null or empty property" ) ; if ( className == null || className . trim ( ) . length ( ) == 0 ) throw new IllegalArgumentException ( "Null or empty class name" ) ; // Is the class available? try { Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( Throwable problem ) { return problem ; } // The class is there, set the property. System . setProperty ( property , className ) ; return null ; }
Sets the system property to a class when the class is available .