001 package org.codehaus.mojo.exec; 002 003 import java.util.Timer; 004 import java.util.TimerTask; 005 006 /** 007 * @author <a href="mailto:jerome@coffeebreaks.org">Jerome Lacoste</a> 008 */ 009 public class FindClassInClasspath 010 { 011 public static final String FOUND_ALL = "OK"; 012 013 /** 014 * @param args the names of classes to search in the classpath 015 * prints 'OK' if all classes found 016 **/ 017 public static void main( String[] args ) 018 { 019 for (int i = 0; i < args.length; i++) 020 { 021 if ( ! isClassInClasspath( args[i] )) 022 { 023 System.out.println( "ERROR: class + " + args[i] + " not found in classpath" ); 024 System.exit( 1 ); 025 } 026 } 027 System.out.println( FOUND_ALL ); 028 } 029 030 private static boolean isClassInClasspath( String className ) 031 { 032 try 033 { 034 Class.forName( className ); 035 return true; 036 } catch ( Exception e ) 037 { 038 System.out.println( "ERROR: " + e.getMessage() ); 039 return false; 040 } 041 } 042 }