Results 1 to 2 of 2
  1. #1
    Psyclone is offline Member
    Join Date
    Jan 2010
    Posts
    81
    Rep Power
    0

    Default java.lang.NoClassDefFoundError

    I've been writing code for about a month and have run into this problem a couple times but seemed to have found a way around it until now.

    All of a sudden, any project I compile gives me
    java.lang.ClassNotFoundException: gameinterface.Main errors.

    The build is successful, but when I try to run the program from NetBeans, I get the following error:

    Java Code:
    java.lang.NoClassDefFoundError: gameinterface/Main
    Caused by: java.lang.ClassNotFoundException: gameinterface.Main
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    Could not find the main class: gameinterface.Main.  Program will exit.
    Exception in thread "main" Java Result: 1
    BUILD SUCCESSFUL (total time: 1 second)
    I think I resolved this in the past by making a new project and copy/pasting the code. I know this is not the correct way to resolve the problem though.

    I researched this problem a lot and it seems it has something to do with the CLASSPATH. I can't even find where to change the classpath in NetBeans though.

    I tried using the HELP function in NetBeans which suggests:

    To declare the classpath for a project:

    1) Build the project so that all of the project's build outputs (JAR files and WAR files) exist on your computer.

    2) In the Projects window, right-click the project node and choose Properties.

    3) Click Classpath in the right panel of the Project Properties dialog box.

    The Project Properties - GameInterface window comes up, but there is no mention of Classpath anywhere.

    What am I doing wrong?

  2. #2
    Psyclone is offline Member
    Join Date
    Jan 2010
    Posts
    81
    Rep Power
    0

    Default

    Follow-up:

    I once again created a new project and it works perfectly fine. Clean and Build, then Run. No problems whatsoever. I compared the project properties and everything looks exactly the same.

Similar Threads

  1. java.lang.NoClassDefFoundError
    By AndrewM16921 in forum Java Applets
    Replies: 3
    Last Post: 09-29-2009, 07:54 PM
  2. java.lang.NoClassDefFoundError
    By noobie in forum Java Applets
    Replies: 5
    Last Post: 04-22-2009, 03:35 AM
  3. java.lang.NoClassDefFoundError:
    By jeepcreep11 in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 12:58 PM
  4. java.lang.NoClassDefFoundError
    By J_a_y in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 12:51 PM
  5. java.lang.NoClassDefFoundError
    By fred in forum Advanced Java
    Replies: 3
    Last Post: 08-01-2007, 06: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
  •