a few years back in college I wrote TONS of simple little java programs… I haven’t used them in a while and I would like to go back and revist them. I believe I used Netbeans as my IDE (but i also could have used Eclipse… cant remember)..
anyways long story short…. I cant remember how to compile them and I cant open these as projects in any of my IDEs….
I’ve tried using javac and then java to run a few in the command line, however one specifically will not run and gives me this error:
Exception in thread "main" java.lang.NoSuchMethodError: main
I know this is because I don’t have a public static void main method in this program. I can’t remember why I don’t…. but here’s in theory how it should work…. I have 3 program files:
- race.java
- bicyclePanel.java
- controlPanel.java
race extends JApplet and has a method public void init()…. which creates an instance of controlPanel class…. controlPanel class creates an instance of bicyclePanel and so on and so forth….
my question is.. am I supposed to have a main method? How can I rebuild this into an IDE and run? It’s been so many years I cant remember all the in’s & outs of java 🙁
Yes, you are supposed to have the
mainmethod if you plan on running it as a standalone Java application. In Eclipse you can use the Applet runner to run your applets directy as well. It’s Run As -> Java Applet.