错误:无法在 intelliJ IDE 中找到或加载主类

编程入门 行业动态 更新时间:2024-10-25 22:28:06
本文介绍了错误:无法在 intelliJ IDE 中找到或加载主类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是 Java 的初学者,正在尝试使用 IntelliJ 运行我的代码,我刚刚安装了 JDK 1.7 作为我的 IDE.下面的一段代码甚至没有编译,并不断给我错误:

I'm a beginner in Java and am trying to run my code using IntelliJ that I just installed as my IDE with JDK 1.7. The following piece of code keeps does not even compile and keeps giving me the error:

Error: Could not find or load main class libTest

代码

import java.lang.Integer; import java.lang.String; import java.lang.System; import java.util.*; class book { private String name = "trial"; private int bookCode=1; private int issued=0; public void Issue(){ if(issued==0) { issued=1; System.out.println("You have succesfully issued the book"); } else { System.out.println("The book is already issued. Please contact the librarian for further details"); } } public int checkCode() { return bookCode; } String readName() { return name; } public void setName(String newName){ name=newName; } public void setBookCode(int newCode){ bookCode=newCode; } } class library { private ArrayList books=new ArrayList(); public void getList(){ for(int bk:books){ String bName=books(bk).readName(); System.out.println((bk+1)+") "+bName); } } } public class libTest{ public static void main(String[] args){ library newLib= new library(); System.out.println("code working"); } }

我必须在编译器设置中进行任何更改吗??或者是代码.

Is there any change that i have to make in the compiler settings?? Or is it the code.

推荐答案

如果以上答案都不适合您,只需关闭您的 IntelliJ IDE 并从项目的根目录中删除 IntelliJ IDE 文件和文件夹:

If none of the above answers worked for you, just close your IntelliJ IDE and remove the IntelliJ IDE file and folder from the root of your project:

rm -rf .idea *.iml

然后用 IntelliJ 打开项目.它现在必须工作.

Then open the project with IntelliJ. It must work now.

更多推荐

错误:无法在 intelliJ IDE 中找到或加载主类

本文发布于:2023-11-25 05:51:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628573.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   错误   中找到   IDE   intelliJ

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!