Forum : Execution of java program with multiple class
Brief description  about Online courses   join in Online courses
View Abhilasha  Singh 's Profile

Execution of java program with multiple class

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.
Asked by Abhilasha Singh | Mar 17, 2010 |  Reply now
Replies (1)
View arun kumar das 's Profile
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)
Mar 19, 2010