title: java "ClassNotFoundException" error
body: <p>I am new to java programming and I am getting the much-maligned error "ClassNotFoundException" error. </p>
  
  <p>The strange thing is is that it compiles fine:  </p>
  
  <pre><code>java -cp /usr/share/java/scribe-1.3.0.jar FacebookProg
  </code></pre>
  
  <p>But when I try to run it, I get the following error:</p>
  
  <pre><code>steve@steve-ThinkPad-T61:~/facebook$ java  FacebookProg  
  Exception in thread "main" java.lang.NoClassDefFoundError:
  org/scribe/builder/ServiceBuilder  
      at FacebookProg.main(FacebookProg.java:8)  
  Caused by: java.lang.ClassNotFoundException: org.scribe.builder.ServiceBuilder  
      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:306)  
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)  
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)  
      ... 1 more  
  </code></pre>
  
  <p>I checked online and it seems that java can't find the library at runtime that it was able to find at compile time. So tried the following variations:</p>
  
  <pre><code>java -cp /usr/share/java/scribe-1.3.0.jar FacebookProg  
  java -cp /usr/share/java/ FacebookProg  
  export CLASSPATH="/usr/share/java"; java FacebookProf  
  export CLASSPATH="/usr/share/java/usr/share/java/scribe-1.3.0.jar"; java FacebookProg  
  </code></pre>
  
  <p>I checked several places on StackOverflow and google and still can't figure out why. I'm new to java, so there's probably a simple solution, but I can't find it. I am using Sun Java 1.6 64-bit on Ubuntu 11.04. The scribe-1.3.0.jar file is in "/usr/share/java" which, I believe, is the canonical place to put java packages.  </p>
  
  <p>The barebones code is here (in case it matters):</p>
  
  <pre><code>import org.scribe.builder.*;
  import org.scribe.builder.api.*;
  import org.scribe.oauth.*;
  
  public class FacebookProg {
      public static void main (String args[]) {
          OAuthService service = new ServiceBuilder()
          .provider(FacebookApi.class)
          .apiKey("blah_blah")
          .apiSecret("blah_blah")
          .build();
      }
  }
  </code></pre>