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

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

我是Java的初学者,我正在尝试使用IntelliJ运行我的代码,我刚刚安装了JDJ 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

代码

Code

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.

推荐答案

这可能有所帮助:

1)构建菜单 - >重建项目。 有时Intellij不会重写类,因为它们已经存在,这样你就要求Intellij重写所有内容。

1) "Build" menu -> "Rebuild Project". Sometimes Intellij doesn't rewrite the classes because they already exist, this way you ask Intellij to rewrite everything.

2)运行菜单 - > 编辑配置 - >删除配置文件 - >添加配置文件(应用程序,如果它是Java应用程序),从主类下拉菜单中选择主类。

2) "Run" menu -> "Edit configuration" -> delete the profile -> add back the profile ("Application" if it's a Java application), choose your main class from the "Main Class" dropdown menu.

3)构建菜单 - >重建项目。

3)"Build" menu -> "Rebuild Project".

更多推荐

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

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

发布评论

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

>www.elefans.com

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