run time error....?

i m running a program in Java but i getting an error when i run it ...

the error is

java.lang.NoSuchMethodError: main

Exception in thread "main"

Java Result: 1

The code for the program is

public class PrintClass {

int x=0;

int y=1;

void printMe() {

System.out.println("X is " + x + ", Y is " + y);

System.out.println("I am an instance of the class " +

this.getClass().getName());

}

}

/** Creates a new instance of PrintClass */

class PrintSubClass2 extends PrintClass {

int z = 3;

void printMe() {

System.out.println("x is " + x + ", y is " + y +

", z is " + z);

System.out.println("I am an instance of the class " +

this.getClass().getName());

}

public static void main(String args[]){

PrintSubClass2 obj = new PrintSubClass2();

obj.printMe();

}

}

I need some help ...

[953 byte] By [rasika] at [2007-11-27 8:20:44]
# 1
Your public class PrintClass doesn't have a main method. Your non-public class PrintSubClass2 does. Since you can't run a non-public class, the vm can't find any main method.
hunter9000a at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 2
Actually the keyword " extends " connects the PrintSubClass2 to PrintClass...So it behaves as a public class now , i guess... So please check once ?Thanks...
rasika at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 3

> Actually the keyword " extends " connects the

> PrintSubClass2 to PrintClass...

> o it behaves as a public class now , i guess... So

> please check once ?

> Thanks...

Wrong. Classes don't inherit access modifiers, so the subclass is only as accessible as it's declared, meaning it's package-private in your example. If you want to run the subclass, you'll have to make it public.

hunter9000a at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 4
it will be a gr888 help if u modify the program to run it correctly ....?thanks...
rasika at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 5
> it will be a gr888 help if u modify the program to> run it correctly ....?> thanks...Uhhh, no. All you have to do is add one word to one class, which you've already done to a different class.
hunter9000a at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 6
> gr888 So Tony The Tiger text messages, does he?
Hippolytea at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 7
srry , i didn't get u... can u clarify it ...
rasika at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 8
> srry , i didn't get u... can u clarify it ...Theyrrrrrrrrrrrrrrrrrrrrrrre Great!
PottedFearna at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 9
> srry , i didn't get u... can u clarify it ...Here you go:1) do your own work. If you don't do it, you won't learn it.2) type in standard english. for many here, english is a second language.Clear enough?
petes1234a at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 10

> > srry , i didn't get u... can u clarify it ...

>

> Here you go:

> 1) do your own work. If you don't do it, you won't

> learn it.

> 2) type in standard english. for many here, english

> is a second language.

>

3) always eat a balanced breakfast

PottedFearna at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 11

class PrintClass

{

int x=0;

int y=1;

void printMe()

{

System.out.println("X is " + x + ", Y is " + y);

System.out.println("I am an instance of the class " +this.getClass().getName());

}

}

public class PrintSubClass2 extends PrintClass

{

int z = 3;

void printMe()

{

System.out.println("x is " + x + ", y is " + y +", z is " + z);

System.out.println("I am an instance of the class " +this.getClass().getName());

}

public static void main(String args[])

{

PrintSubClass2 obj = new PrintSubClass2();

obj.printMe();

}

}

try this way i think it will work

surkuma at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 12
it should be name as PrintSubClass2.java
surkuma at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 13
I got it. Thanks.
rasika at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 14
> I got it. > Thanks.No you didn't! You just pouted and whined until someone did it for you. Try learning and understanding in future.
floundera at 2007-7-12 20:09:06 > top of Java-index,Java Essentials,New To Java...
# 15
> srry , i didn't get u... can u clarify it ...cn u wrt nglsh?
jverda at 2007-7-21 22:36:56 > top of Java-index,Java Essentials,New To Java...
# 16

> Actually the keyword " extends " connects the

> PrintSubClass2 to PrintClass...

> o it behaves as a public class now , i guess

Three seconds of logical thinking would tell you that this is cannot be so.

All classes descend from Object. Object is public. Therefore, if what you said were true, all classes would always be public.

jverda at 2007-7-21 22:36:56 > top of Java-index,Java Essentials,New To Java...
# 17

> > srry , i didn't get u... can u clarify it ...

>

> Here you go:

> 1) do your own work. If you don't do it, you won't

> learn it.

> 2) type in standard english. for many here, english

> is a second language.

>

> Clear enough?

It seems surkum hasn't learned rule number 1 yet. He's a walking ID-Ten-T Error.

petes1234a at 2007-7-21 22:36:56 > top of Java-index,Java Essentials,New To Java...