Results 1 to 5 of 5
  1. #1
    swaralipi is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Getting NoClassDefFoundError

    Hi,
    I am trying to run a simple Java Application in my system , I am coding on Textpad and using jdk1.6.0_37. I am able to compile my code, but whenever I am trying to run the application I am getting NoClassDefFoundError. I also tried running it from the command prompt explicitly defining the classpath etc. but still getting the same error. Can anybody advise me on where I am doing wrong?

    Thanks

  2. #2
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: Getting NoClassDefFoundError

    It could be a couple of things, no main() in your class, you could be invoking the wrong classfile, wrong class name, classpath issue, etc...

    can you post a sample or all of your code so that we can help find the problem?

    Don't forget to use the [ CODE][/ CODE] (without the spaces) markers to format your code properly. :-)
    Last edited by SnakeDoc; 02-06-2013 at 06:59 AM.

  3. #3
    swaralipi is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Re: Getting NoClassDefFoundError

    hi,
    I am trying with the simplest of Java Codes.. the HelloWorld one :) I guess something is wrong with my environment setup, but can't get into it. I have also set the Environment variables.

    Java Code:
    public class Test{
    	public static void main(String[] args){
    		System.out.println("hello swaralipi");
    	}
    }
    Last edited by pbrockway2; 02-06-2013 at 07:01 AM. Reason: code tags added

  4. #4
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: Getting NoClassDefFoundError

    hmm... ok looks correct...

    so you should be saving the file as:

    Test.java

    This tells your java compiler it's a java source file we are working with...

    Then attempt to compile at the command line as:

    javac Test.java

    this should output your Test.class file...

    which is the java bytecode that runs on the JVM (Java Virtual Machine) and is really part of the magic to java that makes it so portable to so many devices! Google this to learn more!

    you would then run the program by doing:

    java Test

    This invokes the java runtime environment on your computer and fires up the JVM, which then executes your code and displays it's output to your cmd prompt (console).

    :)

    Hope that helps, and welcome to Java!

    EDIT: do all this from the command line and make sure to cd (change directory) to wherever you saved your Test.java file!
    Last edited by SnakeDoc; 02-06-2013 at 07:05 AM.

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Getting NoClassDefFoundError

    Hi swaralipi, I've added "code" tags to your post. When you post code put [code] at the start of the code and [/code] at the end. That way the forum software will display the code in a readable way.

    There is nothing obvious wrong with that code. As you say the problem may lie with the environment - including the commands you are using to compile and run the code. So, say what operating system you are using, the values of java related environment variables (PATH and CLASSPATH) and what commands you are using to compile and run the code. Describe the output that results from running those commands: in fact as much as possible copy and post the commands and their output. (This is another place for the [code] ... [/code] tags to preserve formatting).

Similar Threads

  1. NoClassDefFoundError
    By PeDz in forum Advanced Java
    Replies: 1
    Last Post: 02-04-2012, 03:44 PM
  2. NoClassDefFoundError
    By sriram56 in forum IntelliJ IDEA
    Replies: 0
    Last Post: 11-26-2011, 04:04 AM
  3. NoClassDefFoundError
    By Leeish in forum Advanced Java
    Replies: 10
    Last Post: 09-27-2011, 10:08 AM
  4. NoClassDefFoundError
    By bmeu in forum JDBC
    Replies: 1
    Last Post: 10-30-2010, 09:08 PM
  5. NoClassDefFoundError
    By Josisco in forum JDBC
    Replies: 2
    Last Post: 10-30-2010, 09: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
  •