• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String class

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic