File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes noclassdeffounderror Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "noclassdeffounderror" Watch "noclassdeffounderror" New topic


Anshul Singhal

Joined: Dec 14, 2009
Posts: 18
I ve made a folder java in my D drive. The folder Java contains a folder pckage1 and I ve written a following code under the name

package pckage1;


class kkt
public void display()
System.out.println("this is kkt");


public class anshul extends kkt

public static void main()
System.out.println("anshul singhal");
anshul an = new anshul();


this program compiles correctly using javac but when i try to run it...(java anshul) it gives me a no class deffound error
my classpath is set to D:\java;

can someone please help..!!!..

Greg Charles

Joined: Oct 01, 2001
Posts: 2969

When you put a class into a package, you have to use that package name when referring to it. In your example, I think all that's wrong is you need to change the command to:

java pckage1.anshul

We also generally define main as:

public static void main(String [] args)

but I can't remember if the way you define it will prevent it from working or not.

One final point, on this bulletin board, we try to use code tags when posting code. It's really easy, and there are instructions on the site. I'm sure someone can provide a link.
Anshul Singhal

Joined: Dec 14, 2009
Posts: 18
I m sorry Charles..for nt putting my code in tags....

and about the soultion which you gave me I altered my main method by putting String args[] and replacing the first line java pckage1.anshul but still it doesn work out..
I agree. Here's the link:
subject: noclassdeffounderror
jQuery in Action, 3rd edition