• Post Reply Bookmark Topic Watch Topic
  • New Topic

Abstract Classes  RSS feed

 
Shakul Jugran
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had this vague doubt of being able to "RUN" an abstract class.Can we "RUN" an abstract class? Im not talking about instantiating.
Well i tried it out myself but I got two separate results using the Textpad and the Eclipse IDE.
The IDE lets me run it and even gives me an output, whereas the Textpad gives me a java.lang.NoClassDefFoundError.
Both use the same JDK i.e. 1.5.0_06.

Heres the code that I was trying out:




Thanks a lot.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be no problem with running a public static main method in an abstract class. However there is a problem with trying to run a main method in a class which is not public. Your IDE is being overly nice to you - it should have complained about that.
 
Shakul Jugran
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jim,

thanks for replying, but i found out the cause of my NoClassDeFoundException, it was due to the Class Path error... plain stupid huh? I know... it got me confused because it was able to find the Compiler but not the generated Class File.
Anyways, I would like to say that the code works fine even if I do not declare the Abstract Class "public" even if I use the Notepad or the IDE.

Regards.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, OK. I guess I misremembered - the class is not required to be public, but the method is required to be public. All right.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!