View Javadoc

1   package org.codehaus.mojo.exec;
2   
3   import java.util.Timer;
4   import java.util.TimerTask;
5   
6   /**
7    * @author <a href="mailto:jerome@coffeebreaks.org">Jerome Lacoste</a>
8    */
9   public class FindClassInClasspath
10  {
11      public static final String FOUND_ALL = "OK";
12  
13      /**
14       * @param args the names of classes to search in the classpath
15       * prints 'OK' if all classes found
16       **/
17      public static void main( String[] args )
18      {
19        for (int i = 0; i < args.length; i++)
20        {
21          if ( ! isClassInClasspath( args[i] ))
22          {
23            System.out.println( "ERROR: class + " + args[i] + " not found in classpath" );
24            System.exit( 1 );
25          }
26        }
27        System.out.println( FOUND_ALL );
28      }
29  
30      private static boolean isClassInClasspath( String className )
31      {
32        try
33        {
34          Class.forName( className );
35          return true;
36        } catch ( Exception e )
37        {
38          System.out.println( "ERROR: " + e.getMessage() );
39          return false;
40        }
41      }
42  }