View Full Version : Error message after first compile

04-09-2004, 06:47 AM
My code compiles correctly everytime, but if i change anything, i must also change the name of class Lab168 to get the program to run. i get the runtime error of "Exception in thread "main" java.lang.NoSuchMethodError: main". why do i have to change the class name each time?

class Lab168 {
public static void main (String args[]) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a string: ");
Palindrome p = new Palindrome(input.readLine());

class Palindrome {
private String s;
private String p;

public Palindrome (String x) {
s = x;
public void displayData() {
System.out.println("string: " + s);

04-10-2004, 01:46 AM
What do you mean by "change anything". What is it that you changed? The file name must be the same as your class name. So make sure you name your file Lab168.java and then compile it and you should end up with Lab168.class. The same thing applies to your second class. The source file should be named Palindrome.java and then when you compile it you will end up with Palindrome.class.

04-13-2004, 09:40 PM
Yep, that's what I noticed as well. Every class needs to be in its own file (except innerclasses of course..), and the file name should be the same (even case I believe) as the class name.