Results 1 to 9 of 9
  1. #1
    BoomPony is offline Member
    Join Date
    Nov 2010
    Posts
    12
    Rep Power
    0

    Default java.lang.NoClassDefFoundError

    I'm trying to run a program using a batch file, but get this the error message in the command line:

    "Exception in thread "main" java.lang.NoClassDefFoundError: tcp/TCPServer
    Caused by: java.lang.ClassNotFoundException: tcp.TCPServer
    at java.net....blah blah

    ...Could not find the main class: tcp.TCPServer. Program will exit."

    I'm working in windows using eclipse, is this something do to with my settings like the class path or something? I'm bamboozled.

    Thanks x

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Do you have a tcp.TCPServer class?

  3. #3
    BoomPony is offline Member
    Join Date
    Nov 2010
    Posts
    12
    Rep Power
    0

    Default

    Yes. the class is called TCPServer, and it's in a folder called tcp, since that's the name of the package that TCPServer is part of.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Where are you running the java command from?
    The directory that contains the tcp directory?

  5. #5
    BoomPony is offline Member
    Join Date
    Nov 2010
    Posts
    12
    Rep Power
    0

    Default

    Yeah that's right. Not the directory where the TCPServer class itself is, one level up from there, where the tcp folder is, and the tcp folder contains the class

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Hmmm.
    What happens if you do something like:
    java tcp.TCPServer
    to run it?
    Rather than using the batch file.
    I know you'll get other class def problems, but if it gets past the TCPServer then that means there's a problem in how your batch file is working.

  7. #7
    BoomPony is offline Member
    Join Date
    Nov 2010
    Posts
    12
    Rep Power
    0

    Default

    I get the same error. That's exactly what my batch file contains anyway so it shouldn't make a difference should it?

    My batch file contains:

    java tcp.TCPServer 7000
    pause

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Try it on the command line directly.
    I doubt it'll make a difference, it has to be said, but it might rule out the batch file.

    Also, are you sure that the tcp directory contains a TCPServer.class?
    It might seem a silly question, but I have seen people try to run the java source code before now.

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by BoomPony View Post
    I get the same error. That's exactly what my batch file contains anyway so it shouldn't make a difference should it?

    My batch file contains:

    java tcp.TCPServer 7000
    pause
    If your current working directory is one level up from the tcp directory (where the TCPserver.class file is stored) try to run it as:

    Java Code:
    java -cp. tcp.TCPServer 7000
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 5
    Last Post: 06-02-2010, 01:05 PM
  2. Replies: 3
    Last Post: 06-01-2010, 03:01 PM
  3. java.lang.NoClassDefFoundError
    By Psyclone in forum NetBeans
    Replies: 1
    Last Post: 02-28-2010, 11:03 PM
  4. java.lang.NoClassDefFoundError
    By AndrewM16921 in forum Java Applets
    Replies: 3
    Last Post: 09-29-2009, 06:54 PM
  5. java.lang.NoClassDefFoundError
    By fred in forum Advanced Java
    Replies: 3
    Last Post: 08-01-2007, 05:00 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
  •