• Post Reply Bookmark Topic Watch Topic
  • New Topic

String class  RSS feed

 
Smita Chopra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created my own String class in java.lang package.
I expected the compiler to generate an error but it compiled fine.


But when I try to run it, I get the following error.

Exception in thread "main" java.lang.NoSuchMethodError: main

Why is it so? Why does it compile and why doesn't it run?
Thanks
 
Qi Liang
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error is raised by class loader. It must have loaded java.lang.String from JRE.
 
Smita Chopra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying
 
Sagar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
IMHO the main method here is getting overloaded here ..
the public static void main(String args[]) is not found which is the entry point of any code..
That is if you replace the name String with StringBuffer than it runs fine....or to say a Integer ...
(Class loader should create a problem there also)
Now on to the second point ...i think the java.lang.security exception is thrown saying that java.lang is a probhited package name...So we cant use java.lang package ...in any source file.I think if you even use java.anything than also same exception is thrown...

Correct me if i m wrong...N clarify please..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!