gpt4 book ai didi

java - 错误: Could not find or load main class Mac Eclipse

转载 作者:行者123 更新时间:2023-12-02 05:40:08 26 4
gpt4 key购买 nike

因此,我在运行 Mavericks 的 Mac 上使用 Eclipse,并将默认保存位置更改为另一个文件夹,但每次我尝试构建新项目时,都会不断弹出此错误...错误:无法找到或加载主课。如果这有帮助的话,这是我的两个类的代码。

//Employee.java
package Exercise314;
public class Employee
{
String firstName;
String lastName;
double monthlySalary;

public Employee (String fName, String lName, double mSalary)
{
firstName = fName;
lastName = lName;
monthlySalary = mSalary;
}
public void setFirstName (String fName)
{
firstName = fName;
}
public void setLastName (String lName)
{
lastName = lName;
}
public void setMonthlySalary (double mSalary)
{
if(mSalary > -1)
monthlySalary = mSalary;
}
public String getFirstName ()
{
return firstName;
}
public String getLastName ()
{
return lastName;
}
public double getMonthlySalary ()
{
return monthlySalary;
}
}
//EmployeeTest.java
package Exercise314;
public class EmployeeTest
{

public static void main(String[] args)
{
Employee employee1 = new Employee(
"Joe", "Smith", 150000 );
Employee employee2 = new Employee(
"Jane", "Doe", 95000 );
System.out.printf("First name is: %s\n",
employee1.getFirstName() );
System.out.printf("Last name is: %s\n",
employee1.getLastName() );
System.out.printf("Salary is: %f\n\n",
employee1.getMonthlySalary() );
}
}

最佳答案

作为 Mac 用户并且安装了 Eclipse Luna 和 STS,我建议您重新启动 Eclipse。如果这不起作用,请重新启动 Mac。当我遇到同样的错误时,我就是这样做的。

关于java - 错误: Could not find or load main class Mac Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24592167/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com