Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Java Help Please

3 replies · 1,091 views · Started 09 September 2004

I'm having problems when I try to run my program. It compiles just fine, but when I go to run it I get this:

java.lang.NoSuchMethodError: main
Exception in thread "main"
Here is my program:

import aLibrary.*;
public class Director {[indent] private SimpleWindow window;
private GrayCircle circle;
[/indent][indent] public Director() {[indent]window = new SimpleWindow();
circle = new GrayCircle();
circle.place(window);
window.repaint();
[/indent][/indent][indent] }
[/indent]}
So after I got this I tried a much simpler 'Hello World' and I made sure it had a 'main' method.

public class HelloWorld {[indent] public static void main(String[] args) {
[/indent][indent][indent] System.out.println("Hello World!"😉;
[/indent][/indent][indent] }
[/indent]}
This program works, but the other one doesn't. I replaced the 'public Director()' with 'public void main()' but I get the same error. Can anyone tell me how to fix this? The first program runs just fine on the Solaris Machines in class, just not at home.

Your program doesn't have a main function, that might be the problem.. rename the Director function to main and it might work. You may need to make it static too/otherwise, I'm not sure

Main is the entry point for a Java program, and many other languages as well. AFAIK, you cannot write a functioning program without a main method somewhere.