0

你好,可以叫我Kenshi。我是一名试图参加在线编程课程的高中生。我会问我的老师,但她几乎把我的笔记本电脑毁坏了,因为她对此一无所知。这是我的问题.... 几周前,我输入了一个程序来查找立方体的表面积。从那时起,当我尝试运行一个程序时,它就会运行立方体程序。我删除了该项目,然后我得到了 Java.lan.NoClassDefFoundError。我听说我必须删除程序的 Cashe,我不得不擦除我的电脑(由于我的老师)并且没有用。我按照 Java 教科书基础上的程序说明进行操作。当我重新输入我的笔记本电脑并运行时,我仍然会出现错误。如果你能帮上忙,这会让这个人非常高兴。下面我将提供整个错误代码。

java.lang.NoClassDefFoundError: studentapps/StudentApps (wrong name: StudentApps/StudentApps)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)

线程“main”Java 结果中的异常:1 BUILD SUCCESSFUL(总时间:1 秒)

再次非常感谢!

编辑:这是类本身的代码。

package StudentApps;

import java.util.Scanner;

public class StudentApps {

public static void main(String[] args) {
Student student1 = new Student();
Student student2 = new Student();
Scanner reader = new Scanner (System.in);

String name;
int score;

System.out.print("Enter the first students Name: ");
name = reader.nextLine();
student1.setName(name);
for (int i = 1; i <= 3; i++){
    System.out.print("Enter the student's Score");
    score = reader.nextInt();
    student1.setScore(i, score);
    }
reader.nextLine();

System.out.print("Enter the second students name: ");
name = reader.nextLine();
student2.setName(name);
for (int i = 1; i <= 3; i++){
    System.out.print("Enter the student's Score");
    score = reader.nextInt();
    student2.setScore(i, score);
    }
System.out.println(student1);
System.out.println(student2);

if (student1.getHighScore() > student2.getHighScore()){
    name = student1.getName();

    score = student1.getHighScore();
}else{
    name = student2.getName();
    score = student2.getHighScore();
}
System.out.println(name + " has the highest score: " + score);

if (student1.getAverage() > student2.getAverage()){
    name = student1.getName();
    score = student1.getHighScore();
}else{
    name = student2.getName();
    score = student2.getAverage();
}
System.out.println(name + " has the highest average score: " + score);
}

}

4

1 回答 1

0

如果没有实际看到您的代码,很难说。但请注意第一行:

studentapps/StudentApps (wrong name: StudentApps/StudentApps

在斜线“/”之前的第一部分中studentapps也有。StudentApps你没有这个错字的地方吗?

于 2012-01-19T22:02:52.053 回答