Results 1 to 5 of 5
Thread: Getting NoClassDefFoundError
- 02-06-2013, 06:49 AM #1
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
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
- 02-06-2013, 06:55 AM #2
Senior Member
- Join Date
- Apr 2012
- Posts
- 129
- Rep Power
- 0
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.
- 02-06-2013, 06:58 AM #3
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
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
- 02-06-2013, 07:02 AM #4
Senior Member
- Join Date
- Apr 2012
- Posts
- 129
- Rep Power
- 0
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.
- 02-06-2013, 07:07 AM #5
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,716
- Rep Power
- 17
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
-
NoClassDefFoundError
By PeDz in forum Advanced JavaReplies: 1Last Post: 02-04-2012, 03:44 PM -
NoClassDefFoundError
By sriram56 in forum IntelliJ IDEAReplies: 0Last Post: 11-26-2011, 04:04 AM -
NoClassDefFoundError
By Leeish in forum Advanced JavaReplies: 10Last Post: 09-27-2011, 10:08 AM -
NoClassDefFoundError
By bmeu in forum JDBCReplies: 1Last Post: 10-30-2010, 09:08 PM -
NoClassDefFoundError
By Josisco in forum JDBCReplies: 2Last Post: 10-30-2010, 09:07 PM
Bookmarks