• Post Reply Bookmark Topic Watch Topic
  • New Topic

main() method mystery  RSS feed

 
Vishal Srivastav
Ranch Hand
Posts: 47
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made a program which is as follows -



This was under a single file named as Sample.java.

When I try to run it through the command prompt, the java launcher tool waits for a while and then it gives an error as follows -



And many more lines...

But when I try to run it using NetBeans IDE 6.5, by choosing any of the class as main class, the program is successfully giving respective output.

What is the mystery behind it? I also tried by making any one class public while running it through command prompt, but result was same.

Please help.
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like the problem is not in your java code, but in your virtual machine. You can try to compile and run 100% valid java code and result will be the same, I guess.
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just reinstall JDK, seems like some of the library jars are corrupt. BTW this code is also 100% correct ...
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that is correct, I did not even look at the sample code after seeing error. :)
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Vishal,

The code is fine and even running fine at my end. I put the file at c:\ compiled it using javac command and ran it using java command.
as you can see in the attached screen shot.



 
Davie Lin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't quite understand something here, why is this question in the programmer certification forum?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to "Beginning Java".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!