simple java issue: java.lang.NoSuchMethodError: main (it's a LIE!)
I have been writing in Java for a few months now; however, I still consider myself fairly new to it because all of my experience in Java has been writing Beans. I have reached the point in developing the project that I am on where I have to write a small and simple Java program in order to try to debug a portion of the Bean that I'm working on. I can't do this from within a Bean because I need to rely on console debugging output.
I thought that I would be able to throw this together relatively quickly, but I can't get this to run due to an error of:
dgetsman@linuxdamon:~/src/java$ java -cp . Main
Exception in thread "main" java.lang.NoSuchMethodError: main
at this point.
The code is simple and I am fairly confident that it is fine except for main() not being found. I would appreciate any assistance, comments, or pointers to relevant material about this issue. Here is the code:
main(String args) must be static
The issue's resolution was fairly simple. I've been programming in Beans, as I've mentioned, and that was my learning environment, so I pretty much completely skipped stand-alone Java apps. When main(STRING args) is your entry point it must be declared static.
That means that it can only play with static variables and methods; that held me back for a few minutes, too, because I got the purpose of static confused with the purpose of final. Everything is working now, though.
There were way too many different causes for this error on the google hits that I found. Hope some people can find this if they have the same newbie error I had here. :thumbsup:
|All times are GMT +1. The time now is 12:21 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.