Execution of java program with multiple class
By Abhilasha Singh
For the car program given in the notes.I compiled the program using "javac Car.java" command.The program is getting compiled but when i am giving the command"java Car" to run the program, i am getting the error message"exception in thread"main" java.lang.No such Method error:main".
But when i executed the same program on eclipse"platform for executing java pgm" it is getting executed.Help me with the reason behind it.
Arun Kumar Das replied to Abhilasha Singh Friday, March 19, 2010
Hi Abhi,
If you have a look at Car.java program again you will notice that there is no main() method in that program. We know that main() method is must to execute the program. The main() method for this class is in MyOwnCar.java program. Once you compile Car.java please compile MyOwnCar.java and execute the program will run.
In eclipse IDE you would have stored both programs in the same project which enabled successful execution.
Hope this answered your Query. Please get back if you need any more clarification.
Cheers..
Java Teacher (JT)