Starting a java application at command prompt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stefan Olsson
    New Member
    • Jan 2011
    • 2

    Starting a java application at command prompt

    Hello

    Windows 7, latest Java installed.

    I have two jar files, on with the main class included which uses classes in the other java class.

    The two jar file names are
    swt.jar (contain org.eclipse. ..... classes)
    HelloWorld.jar (containing the main class)

    When I try to start the java application at the command prompt with the following
    java -jar HelloWorld.jar I get the following exception
    Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Layout
    Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Layout
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: gui.Main. Program will exit.
    How do I, at the command prompt, get the jvm to "look into" swt.jar as well, the CLASSPATH is not set in command window.

    Regards
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Follow this link.

    Regards
    Dheeraj Joshi

    Comment

    • Stefan Olsson
      New Member
      • Jan 2011
      • 2

      #3
      Hi

      Thanks a lot, it has been solved, needed to write the following
      Code:
      java -classpath .;swt.jar;Hello.jar gui.Main
      Regards

      Comment

      Working...