PDA

View Full Version : Java Help Please



SixTen
09-09-2004, 02:18 PM
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 {
private SimpleWindow window;
private GrayCircle circle;

public Director() {
window = new SimpleWindow();
circle = new GrayCircle();
circle.place(window);
window.repaint();

}
}
So after I got this I tried a much simpler 'Hello World' and I made sure it had a 'main' method.


public class HelloWorld {
public static void main(String[] args) {


System.out.println("Hello World!");

}
}
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.

Warlock
09-09-2004, 04:28 PM
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

SixTen
09-10-2004, 07:49 AM
EDIT - Nevermind, I figured out what was wrong.

AtmaWeapon
09-10-2004, 09:12 PM
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.