Results 1 to 5 of 5
  1. #1
    kokorini is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Question I cant run the program outside eclipse, why?

    Hi!

    first of all thank you for your time....
    when I run the program from eclipse just clicking the "green arrow", or debuggin it work great.

    but when I go to the console and try:
    "java main_spy.class"

    I get:

    Exception in thread "main" java.lang.NoClassDefFoundError: main_spy/class
    Caused by: java.lang.ClassNotFoundException: main_spy.class
    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: main_spy.class. Program will exit.


    I'm using ubuntu 8.04

    thank you for help!

  2. #2
    thi
    thi is offline Member
    Join Date
    Jun 2010
    Posts
    2
    Rep Power
    0

    Default

    Hello!
    Try this:

    java -classpath <path to classes> <MainClass>

    for example:

    java -classpath . main_spy

  3. #3
    kokorini is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default

    Hi! thanks for your reply!

    it seems to work, thanks

    but now it seems to have problems connecting to mysql, I'm getting the exception:

    SQLException: No suitable driver found for jdbc:mysql://127.0.0.1/spy?useServerPrepStmts=true
    SQLState: 08001


    once again, running from eclipse it works.

    thank you.

  4. #4
    thi
    thi is offline Member
    Join Date
    Jun 2010
    Posts
    2
    Rep Power
    0

    Default

    And where is your driver jar? Add it to your classpath.

    java -classpath .:<fullPathToYourDriverJarAndTheJarName> main_spy

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,271
    Rep Power
    25

    Default

    NoClassDefFoundError: main_spy/class
    ClassNotFoundException: main_spy.class
    Look at the names in the error message.
    The java command thinks the package name is main_spy and the class name is class.
    The syntax for the java command is just the filename without the extension:
    java main_spy

Similar Threads

  1. A tab in an eclipse RCP program
    By Drun in forum Eclipse
    Replies: 0
    Last Post: 05-20-2010, 03:56 PM
  2. Replies: 0
    Last Post: 10-04-2009, 02:47 PM
  3. Eclipse Bug - Can't Read From A File Using Eclipse?
    By carlodelmundo in forum New To Java
    Replies: 6
    Last Post: 01-26-2009, 04:25 PM
  4. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  5. DB program in Eclipse
    By Unni in forum Eclipse
    Replies: 3
    Last Post: 08-09-2007, 11:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •