title: How to set java -classpath for two directories?
body: <p>I am trying to get a little test working in Java. I have two directories <code>root</code> and <code>root/lib</code>. I have a <code>root/lib/Test.java</code> file and a <code>root/Foo.java</code> file. I can compile both with <code>javac lib/Test.java</code> and then <code>javac -classpath lib Foo.java</code> and get:</p>
  
  <pre><code>root/
   Foo.java
   Foo.class
   lib/
    Test.java
    Test.class
  </code></pre>
  
  <p>here is how they look like:</p>
  
  <pre><code>class Foo {
    static public void main(String[] argv) {
      System.out.println(Test.test());
    }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class Test {
    public static int test() {
      return 2;
    }
  }
  </code></pre>
  
  <p>How do I run them so they work together without adding a import statement? I have tried <code>java -classpath ".;lib" Foo</code> but I just get <code>java.lang.NoClassDefFoundError: Foo</code></p>
  
  <pre><code>Lala: jeena$ cd root
  Lala:root jeena$ java -classpath ".;lib" Foo
  Exception in thread "main" java.lang.NoClassDefFoundError: Foo
  Caused by: java.lang.ClassNotFoundException: Foo
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  </code></pre>