Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Please help! java.lang.NoClassDefFoundError problem

    hi guy,
    I am using JCreator to compile and code java, but when I clicked "run project", it showed that
    --------------------Configuration: <Default>--------------------
    java.lang.NoClassDefFoundError: HelloPrinter
    Caused by: java.lang.ClassNotFoundException: HelloPrinter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Could not find the main class: HelloPrinter. Program will exit.
    Exception in thread "main"
    Process completed.

    I google it before and I changed my environment variables to
    CLASSPATH .;
    JAVA_HOME C:\Program Files\Java\jdk1.6.0_23
    PATH .;%SystemRoot%\system32;%JAVA_HOME%\bin;
    but it still not working.
    Can anyone please help to solve this??
    Thanks.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Classpath is likely wrong, you need to ensure that classpath includes the path to the location of HelloPrinter if it is not in the same directory as where your javac is executing.
    There are older articles, but nothing has changed since version 1.3 in this regard:
    http://download.oracle.com/javase/1....n32/javac.html
    http://download.oracle.com/javase/1....classpath.html

    Either altering the classpath environment or passing it on the cli will work. I'd pass on the CLI. Also, if you are using an IDE, than it should be keeping track of your classpath relative to how it sees your projects and automatically compile with it set.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Classpath is likely wrong, you need to ensure that classpath includes the path to the location of HelloPrinter if it is not in the same directory as where your javac is executing.
    There are older articles, but nothing has changed since version 1.3 in this regard:
    http://download.oracle.com/javase/1....n32/javac.html
    http://download.oracle.com/javase/1....classpath.html

    Either altering the classpath environment or passing it on the cli will work. I'd pass on the CLI. Also, if you are using an IDE, than it should be keeping track of your classpath relative to how it sees your projects and automatically compile with it set.
    I changed the classpath value to CLASSPATH=C:\bin; where I saved my java, but it still not working.

    what should I do? thanks.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    What is your current cli call for javac?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    What is your current cli call for javac?
    what is cli call???

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    command line interface:
    Code:
    C:\path\to\jre\bin>javac -cp .;C:\Path\to\otherlibs somejava.java
    Pretty much the same in linux if your on a nix system.
    I take it you didn't read the articles I posted links for? This sounds more like a problem with your IDE configurations then, and not directly with Java. I've never used JCreator so I can't help you with that.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #7
    New Coder
    Join Date
    Apr 2010
    Location
    New Jersey, USA
    Posts
    19
    Thanks
    2
    Thanked 1 Time in 1 Post
    I've also found that this can happen if you create a project with a main class and then try to rename the main class. If it's not done properly you'll get that exact error. I've encountered this in Netbeans, not exactly JCreator...but figured it was worth mentioning.


  •  

    Posting Permissions

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