title: How do I add a .jar file to the classpath on Mac OS X?
body: <p>I'm starting to become pretty irritated, because EVERY time I try to add a JAR file to the classpath to run a program (which compiles fine in Eclipse) I get a "java.lang.NoClassDefFoundError" exception.
  The file swt.jar and GUI.class (main class) are in the same directory. If I issue this command: "java -cp swt.jar GUI", I get this error message:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError: GUI Caused
    by: java.lang.ClassNotFoundException: GUI     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)</p>
  </blockquote>
  
  <p>If I formulate the command like this: "java GUI -cp swt.jar", it'll throw this exception:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError:
    org/eclipse/swt/widgets/Display   at GUI.main(GUI.java:9) Caused by:
    java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Display     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</p>
  </blockquote>
  
  <p>I just want to know how I can add .jar files to the runtime classpath on mac.<br/>
  All of these commands are being issued from the Terminal on a 64-bit MacBook running Mac OS X Lion.</p>