java.lang.ClassNotFoundException错误 - Oracle Java教程

时间:2014-05-28 21:44:25

标签: java eclipse classnotfoundexception

我正在学习这个oracle java教程并试图在Eclipse中使用这个代码。我已经能够创建新类并将代码复制到类中。我似乎无法在Eclipse中使用此代码。 http://docs.oracle.com/javase/tutorial/java/nutsandbolts/examples/StringSwitchDemo.java

我一直收到Class not found错误。我正确地命名了这个班级。

这是一个截图。 http://imgur.com/p74ZqZx

我不明白我需要更改以允许代码运行。

public class StringSwitchDemo {

    public static int getMonthNumber(String month) {

        int monthNumber = 0;

        if (month == null) {
            return monthNumber;
        }

        switch (month.toLowerCase()) {
            case "january":
                monthNumber = 1;
                break;
            case "february":
                monthNumber = 2;
                break;
            case "march":
                monthNumber = 3;
                break;
            case "april":
                monthNumber = 4;
                break;
            case "may":
                monthNumber = 5;
                break;
            case "june":
                monthNumber = 6;
                break;
            case "july":
                monthNumber = 7;
                break;
            case "august":
                monthNumber = 8;
                break;
            case "september":
                monthNumber = 9;
                break;
            case "october":
                monthNumber = 10;
                break;
            case "november":
                monthNumber = 11;
                break;
            case "december":
                monthNumber = 12;
                break;
            default: 
                monthNumber = 0;
                break;
        }

        return monthNumber;
    }

    public static void main(String[] args) {

        String month = "August";

        int returnedMonthNumber =
            StringSwitchDemo.getMonthNumber(month);

        if (returnedMonthNumber == 0) {
            System.out.println("Invalid month");
        } else {
            System.out.println(returnedMonthNumber);
        }
    }
}

我的IDE(Eclipse)中出现了这个错误

enter image description here

0 个答案:

没有答案