当前位置:   article > 正文

JAVA报Exception in thread "main" java.lang.NoClassDefFoundError的错误_"exception in thread \"main\" java.lang.noclassdef

"exception in thread \"main\" java.lang.noclassdeffounderror: com/sun/jna/point"
  1. package Test;
  2. public class Test{
  3. /**
  4. * @param args
  5. */
  6. public static void main(String[] args) {
  7. // TODO Auto-generated method stub
  8. student student1 = new student("李明",18,"本科");
  9. student1.show();
  10. undergraduate unstudent1 = new undergraduate("计算机");
  11. unstudent1.name = "李丽";
  12. unstudent1.age = 20;
  13. unstudent1.show();
  14. unstudent1.showb();
  15. graduate grastudent1 = new graduate("机器学习");
  16. grastudent1.name = "刘明";
  17. grastudent1.age = 24;
  18. grastudent1.show();
  19. grastudent1.showm();
  20. }
  21. }
  22. class student {
  23. String name;
  24. int age;
  25. String degree;
  26. student(){
  27. }
  28. student(String name,int age){
  29. this.name = name;
  30. this.age = age;
  31. }
  32. student(String name,int age,String degree){
  33. this.name = name;
  34. this.age = age;
  35. this.degree = degree;
  36. }
  37. void show(){
  38. System.out.println("学生信息为:");
  39. System.out.println("姓名:"+name);
  40. System.out.println("年龄:"+age);
  41. System.out.println("学位为:"+degree);
  42. }
  43. }
  44. class undergraduate extends student{
  45. String major;
  46. undergraduate(){
  47. degree = "bachelor";
  48. }
  49. undergraduate(String major){
  50. degree = "bachelor";
  51. this.major = major;
  52. }
  53. void showb(){
  54. System.out.println("专业为:"+major);
  55. }
  56. }
  57. class graduate extends student{
  58. String Research_Area;
  59. graduate(){
  60. degree = "master";
  61. }
  62. graduate(String Research_Area){
  63. degree = "master";
  64. this.Research_Area = Research_Area;
  65. }
  66. void showm(){
  67. System.out.println("研究方向为:"+Research_Area);
  68. }
  69. }

  1. public class Student {
  2. /**
  3. * @param args
  4. */
  5. public static void main(String[] args) {
  6. // TODO Auto-generated method stub
  7. student student1 = new student("李明",18,"本科");
  8. student1.show();
  9. undergraduate unstudent1 = new undergraduate("计算机");
  10. unstudent1.name = "李丽";
  11. unstudent1.age = 20;
  12. unstudent1.show();
  13. unstudent1.showb();
  14. graduate grastudent1 = new graduate("机器学习");
  15. grastudent1.name = "刘明";
  16. grastudent1.age = 24;
  17. grastudent1.show();
  18. grastudent1.showm();
  19. }
  20. }
  21. class student {
  22. String name;
  23. int age;
  24. String degree;
  25. student(){
  26. }
  27. student(String name,int age){
  28. this.name = name;
  29. this.age = age;
  30. }
  31. student(String name,int age,String degree){
  32. this.name = name;
  33. this.age = age;
  34. this.degree = degree;
  35. }
  36. void show(){
  37. System.out.println("学生信息为:");
  38. System.out.println("姓名:"+name);
  39. System.out.println("年龄:"+age);
  40. System.out.println("学位为:"+degree);
  41. }
  42. }
  43. class undergraduate extends student{
  44. String major;
  45. undergraduate(){
  46. degree = "bachelor";
  47. }
  48. undergraduate(String major){
  49. degree = "bachelor";
  50. this.major = major;
  51. }
  52. void showb(){
  53. System.out.println("专业为:"+major);
  54. }
  55. }
  56. class graduate extends student{
  57. String Research_Area;
  58. graduate(){
  59. degree = "master";
  60. }
  61. graduate(String Research_Area){
  62. degree = "master";
  63. this.Research_Area = Research_Area;
  64. }
  65. void showm(){
  66. System.out.println("研究方向为:"+Research_Area);
  67. }
  68. }

前一阵写过一个java小程序,可以正常运行。但是今天再去运行时,发现报出如下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: Student (wrong name: student)

at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)


尝试了很多发方法,终于找到一个方法:就是在该工程下新建一个包,修改类名Student为Test就能正常运行。



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/278826
推荐阅读
相关标签
  

闽ICP备14008679号