Results 1 to 9 of 9
  1. #1
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

    Smile Simple error..?

    import java.applet.Applet;
    public class img extends Applet {
    public static void main (String[] args) {
    //some code
    }
    }

    Gives this error:

    Exception in thread "main" java.lang.NoClassDefFoundError: img
    Caused by: java.lang.ClassNotFoundException: img
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
    Could not find the main class: img. Program will exit.

    Very weird since I do have a main class, right?

    Edit:
    javac img.java works fine but java img gives the error..
    Last edited by dudejonne; 11-06-2009 at 01:23 PM.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    835
    Rep Power
    6

    Default

    Chech ur path and classpath settings.
    Ramya:cool:

  3. #3
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

    Default

    My path is set to: C:\Program Files\Java\jdk1.6.0_16\bin\
    To what should I set my classpath?

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    835
    Rep Power
    6

    Default

    u set to lib \Java\jdk1.6.0_16\lib\tools.jar
    Ramya:cool:

  5. #5
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

    Default

    Hm, it doesn't works:

    C:\wamp\www>set classpath=C:\Program Files\Java\jdk1.6.0_16\lib\tools.jar

    C:\wamp\www>javac img.java

    C:\wamp\www>java img
    Exception in thread "main" java.lang.NoClassDefFoundError: img
    Caused by: java.lang.ClassNotFoundException: img
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
    Could not find the main class: img. Program will exit.

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    835
    Rep Power
    6

    Default

    u add .;let us see
    set classpath= .;C:\Program Files\Java\jdk1.6.0_16\lib\tools.jar
    Ramya:cool:

  7. #7
    rdtindsm is offline Member
    Join Date
    Feb 2009
    Posts
    92
    Rep Power
    0

    Default

    class path should point to the directory containing the class file. In this case,
    c:\wamp\www;

    Semicolon may or may not be included. It would normally be included to make it easier to add the next class path item. Unix/linux uses a different delimiter, but the c:/ path indicates windows system.

  8. #8
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    835
    Rep Power
    6

    Default

    He is asking windows classpath.my solution will workout
    Ramya:cool:

  9. #9
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

Similar Threads

  1. Ftpclient abort download
    By Papalazarou in forum New To Java
    Replies: 0
    Last Post: 01-06-2009, 04:18 PM
  2. Download JDK 1.5
    By Nick15 in forum New To Java
    Replies: 4
    Last Post: 01-01-2009, 03:10 AM
  3. What jdk do I download?
    By padutch2 in forum New To Java
    Replies: 3
    Last Post: 11-29-2007, 04:28 AM
  4. problems sun.net.ftp.FtpClient
    By tommy in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 04:01 AM
  5. I could download JDK 1.5
    By Albert in forum New To Java
    Replies: 2
    Last Post: 07-13-2007, 03:36 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
  •