public static void main(String[] args) {
    List<String>	list;
    List<String>	packages;
    int         	i;
    StringTokenizer	tok;

    if ((args.length == 1) && (args[0].equals("packages"))) {
      list = getSingleton().findPackages();
      for (i = 0; i < list.size(); i++)
	System.out.println(list.get(i));
    }
    else if (args.length == 2) {
      // packages
      packages = new ArrayList<>();
      tok = new StringTokenizer(args[1], ",");
      while (tok.hasMoreTokens())
        packages.add(tok.nextToken());

      // search
      list = getSingleton().findNames(
	args[0],
	packages.toArray(new String[packages.size()]));

      // print result, if any
      System.out.println(
          "Searching for '" + args[0] + "' in '" + args[1] + "':\n"
          + "  " + list.size() + " found.");
      for (i = 0; i < list.size(); i++)
        System.out.println("  " + (i+1) + ". " + list.get(i));
    }
    else {
      System.out.println("\nUsage:");
      System.out.println(
	  ClassLocator.class.getName() + " packages");
      System.out.println("\tlists all packages in the classpath");
      System.out.println(
	  ClassLocator.class.getName() + " <classname> <packagename(s)>");
      System.out.println("\tlists classes derived from/implementing 'classname' that");
      System.out.println("\tcan be found in 'packagename(s)' (comma-separated list)");
      System.out.println();
      System.exit(1);
    }
  }
public static void main ( String [ ] args ) { List < String > list ; List < String > packages ; int i ; StringTokenizer tok ; if ( ( args . length == 1 ) && ( args [ 0 ] . equals ( "packages" ) ) ) { list = getSingleton ( ) . findPackages ( ) ; for ( i = 0 ; i < list . size ( ) ; i ++ ) System . out . println ( list . get ( i ) ) ; } else if ( args . length == 2 ) { packages = new ArrayList < > ( ) ; tok = new StringTokenizer ( args [ 1 ] , "," ) ; while ( tok . hasMoreTokens ( ) ) packages . add ( tok . nextToken ( ) ) ; list = getSingleton ( ) . findNames ( args [ 0 ] , packages . toArray ( new String [ packages . size ( ) ] ) ) ; System . out . println ( "Searching for '" + args [ 0 ] + "' in '" + args [ 1 ] + "':\n" + "  " + list . size ( ) + " found." ) ; for ( i = 0 ; i < list . size ( ) ; i ++ ) System . out . println ( "  " + ( i + 1 ) + ". " + list . get ( i ) ) ; } else { System . out . println ( "\nUsage:" ) ; System . out . println ( ClassLocator . class . getName ( ) + " packages" ) ; System . out . println ( "\tlists all packages in the classpath" ) ; System . out . println ( ClassLocator . class . getName ( ) + " <classname> <packagename(s)>" ) ; System . out . println ( "\tlists classes derived from/implementing 'classname' that" ) ; System . out . println ( "\tcan be found in 'packagename(s)' (comma-separated list)" ) ; System . out . println ( ) ; System . exit ( 1 ) ; } }
Possible calls:
<ul>
<li>
adams.core.ClassLocator &lt;packages&gt;<br>
Prints all the packages in the current classpath
</li>
<li>
adams.core.ClassLocator &lt;classname&gt; &lt;packagename(s)&gt;<br>
Prints the classes it found.
</li>
</ul>

@param args	the commandline arguments