public static boolean doesClassExist ( String nameWithPackage , Object instanceToGetClassloaderFrom ) { boolean exists = false ; try { Class . forName ( nameWithPackage , false , instanceToGetClassloaderFrom . getClass ( ) . getClassLoader ( ) ) ; exists = true ; } catch ( ClassNotFoundException e ) { exists = false ; } return exists ; }
Used to check whether a class exists on the classpath .