我是 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 中找到或加载主类
发布评论