程序入口点- Eclipse Java启动错误:选择不包含主类型



这是我的第一个java程序,我尝试在Eclipse和Netbeans中启动它。我收到启动错误:"选择不包含主类型。"下面是我的主要函数的代码。完整的代码可以从http://www.fractalwebdesigns.com/classes.java

下载
    class test {
      public static void main(String[] args) {
    //Checking Account Test 
    CheckingAccount checking1 = new CheckingAccount(); 
        CheckingAccount checking2 = new CheckingAccount();
         CheckingAccount checking3 = new CheckingAccount();
        CheckingAccount checking4 = new CheckingAccount();
    checking1.open(1234);                   //Open a checking account with an account number 1234
    checking2.open(1235);                   //Open a checking account with an account number 1235
    checking3.open(1236);                   //Open a checking account with an account number 1236
    checking4.open(1237);                   //Open a checking account with an account number 1237
    checking1.credit(3000);                 //Credit 3000 to the account 1234
    checking2.credit(200);                  //Credit 200 to the account 1235
    checking3.credit(5000);                 //Credit 5000 to the account 1236
    checking4.credit(2000);                 //Credit 2000 to the account 1237
    checking1.debit(500);                   //Debit 500 from the account 1234
    checking3.debit(300);                   //Debit 300 from the account 1236
    checking4.debit(2500);                  //Debit 2500 from the account 1237
    checking1.readBalance();                //Read the balance of the account 1234
    checking2.readBalance();                //Read the balance of the account 1235
    checking1.readLastDepositAmount();      //Read last deposit amount of the account 1234
    checking4.readLastDepositAmount();      //Read last deposit amount of the account 1237
    //Saving Account Test
    SavingsAccount savings1= new SavingsAccount();
    SavingsAccount savings2= new SavingsAccount();
    SavingsAccount savings3= new SavingsAccount();
    SavingsAccount savings4= new SavingsAccount();
    savings1.open(5431);                    //Open a savings account with an account number 5431
    savings2.open(5432);                    //Open a savings account with an account number 5432
    savings3.open(5433);                    //Open a savings account with an account number 5433
    savings4.open(5434);                    //Open a savings account with an account number 5434
    savings1.credit(2000);                  //Credit 2000 to the account 5431
    savings2.credit(4000);                  //Credit 4000 to the account 5432
    savings3.credit(1000);                  //Credit 1000 to the account 5433 
    savings4.credit(5000);                  //Credit 5000 to the account 5434
    savings3.debit(2000);                   //Debit 2000 from the account 5433
    savings2.credit(1000);                  //Credit 1000 to the account 5432
    savings2.debit(2000);                   //Debit 2000 from the account 5432
    savings2.debit(500);                    //Debit 500 from the account 5432
    savings2.debit(300);                    //Debit 300 from the account 5432
    savings2.debit(600);                    //Debit 600 from the account 5432
    savings2.debit(100);                    //Debit 100 from the account 5432
    savings2.readBalance();                 //Read the balance of account 5432
    savings1.addInterest(.1);               //Add interest to the account 5431 with the interest rate 10%
    savings2.addInterest(.1);               //Add interest to the account 5432 with the interest rate 10%
    savings3.addInterest(.1);               //Add interest to the account 5433 with the interest rate 10%
    savings2.readCumulativeInterest();      //Read the cumulative interest of the account 5432
    savings2.readBalance();                 //Read the balance of account 5432. 
    }
}

这是一个什么样的项目?它应该是一个Java项目。源文件也应该在项目的Java构建路径中的源文件夹中。我还建议不要使用"default"包。

切换工作空间可能会导致此问题。尝试更改您的工作区,然后导入您创建的项目。这对我很有效。希望对大家有所帮助

最新更新