Java拒绝检测任何类库
这感觉非常像是另一个问题的重复,但我还没有找到解决方案。在Eclipse(Java)和JGrasp中,无论我做什么,IDE都拒绝编译我使用的类库 我已经尝试使用构建路径配置在Eclipse中手动添加库,在工作区中创建一个文件夹,将类文件复制到其中,然后将该文件夹添加到类路径中 在JGrasp中,我已经读到,只要将类文件与运行程序文件放在同一目录中就足够了Java拒绝检测任何类库,java,class,types,Java,Class,Types,这感觉非常像是另一个问题的重复,但我还没有找到解决方案。在Eclipse(Java)和JGrasp中,无论我做什么,IDE都拒绝编译我使用的类库 我已经尝试使用构建路径配置在Eclipse中手动添加库,在工作区中创建一个文件夹,将类文件复制到其中,然后将该文件夹添加到类路径中 在JGrasp中,我已经读到,只要将类文件与运行程序文件放在同一目录中就足够了 public class PayrollLoop { public static void main(String[] args)
public class PayrollLoop
{
public static void main(String[] args)
{
// Prepare to receive output
Scanner scan = new Scanner(System.in);
// initialize variables
int numberEmployees = 0;
double totalGrossPay = 0;
double averagePay = 0;
Payroll employee = new Payroll();
String repeat = "yes";
// Loop to ask for repeated entry of employees.
// New String method: stringObject.equals(anotherStringObject).
// This method returns a boolean value of True or False.
while ( repeat.equals("yes") )
{
// prompt and scan for employee name
System.out.print("Enter the name: ");
employee.setName( scan.next() );
// prompt and scan for ID number
System.out.print("Enter the id number: ");
employee.setIdNumber( scan.nextInt() );
// prompt and scan for pay rate
System.out.print("Enter the pay rate: ");
employee.setPayRate( scan.nextDouble() );
// prompt and scan for hours worked
System.out.print("Enter the number of hours worked: ");
employee.setHoursWorked(scan.nextDouble());
// what should you do to the numberEmployees variable here?
numberEmployees ++;
// what should you do to the totalGrossPay variable here?
// use the getter methods to print all the employee values
System.out.println("Name " + employee.getName());
System.out.println("Id number " + employee.getIdNumber());
System.out.println("Pay Rate " + employee.getPayRate());
System.out.println("Hours Worked " + employee.getHoursWorked());
System.out.println("Gross Pay " + employee.grossPay());
System.out.println();
// Ask user if entering another and scan for response
System.out.println();
} // end of the while loop
// calculate average pay
averagePay = totalGrossPay / numberEmployees;
// print average pay
System.out.println("The average pay is: " + averagePay);
} // end of main method
}
jGASP错误:
----jGRASP exec: javac -g PayrollLoop.java
---- at: Oct 8, 2019, 1:15:39 PM
----jGRASP wedge: pid for wedge is 2648.
----jGRASP wedge2: pid for wedge2 is 784.
----jGRASP wedge2: CLASSPATH is ";.;;;C:\Program Files (x86)\jGRASP\extensions\classes".
----jGRASP wedge2: working directory is [H:\APCS\2019-2020 AP Computer Science\Unit 2\payrolltest] platform id is 2.
----jGRASP wedge2: actual command sent ["C:\Program Files\jdk-10.0.2\bin\javac.exe" -g PayrollLoop.java].
----jGRASP wedge2: pid for process is 5304.
PayrollLoop.java:35: error: ';' expected
System.out.println("Enter the pay rate: ")
^
1 error
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
类文件已编译。在jGRASP中,打开“设置”>“详细消息”,则编译输出也将显示类路径。你的类路径可能有些奇怪
确保Employee.class的名称正确(大小写正确,没有隐藏的附加扩展名)
如果Employee在包中,则需要将该包结构复制为目录结构,因此如果它在包“company”中,则需要在包含“Main”的目录(或类路径上的其他位置)中有一个名为“company”的目录,Employee.class将位于该目录中
如果您有此库的.jar版本,您可以使用“设置”>“路径/类路径”>“工作区”(或“项目…”,如果您使用的是项目)将其添加到jGRASP中的类路径。请复制/粘贴问题中的准确错误消息。还显示导致错误的行。@Code Peedient我在中编辑了错误,但这与我之前遇到的错误不完全相同。@DevilsHnd employee无法识别请确保已将依赖的jar库文件添加到项目中。1) 右键单击您的项目。2) 选择构建路径。3) 单击configurebuildpath。4) 单击库并选择添加外部JAR。5) 从所需文件夹中选择jar文件。6) 单击应用并确定。您发布的错误发生在名为
Main
的类中,但您发布了名为PayrollLoop
的类。我已将类文件添加到类路径中。我又试了一次。仍然不起作用。好的,请发布一个编译的详细输出。这不是我在问题末尾所说的吗?打开“设置”>“详细消息”,然后发布失败编译的所有输出,而不仅仅是Java错误消息。我看不到设置。我在月食中。