• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not able to execute the program.  RSS feed

 
Joy Vergis
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to compile the below program but not able to execute.



Output Error:


 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a good lesson. Don't give your classes the same name as existing classes in the standard Java API, or at least the java.lang and java.util packages.

What's the type of agrs? It's an array of String, but not java.lang.String.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use String for your class name. It is already taken by java.lang.String.

When you execute java String from the command line, JVM first looks for classes in JDK. It finds java.lang.String and it tries to execute its main method.
The class java.lang.String does not have one thus the error.

This is wrong. Stephan van Hulst gave a correct explanation.

Change your class name to something else.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel Pawlowicz wrote:Don't use String for your class name. It is already taken by java.lang.String. . . .
And you see, it adversely affected your other program.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!