aspose file tools*
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "noclassdeffounderror" Watch "noclassdeffounderror" New topic
Author

noclassdeffounderror

Anshul Singhal
Greenhorn

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 anshul.java


package pckage1;

import java.io.*;

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();
an.display();
}

}


this program compiles correctly using javac anshul.java 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
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: noclassdeffounderror