加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

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

发布时间:2020-12-15 07:36:03 所属栏目:Java 来源:网络整理
导读:我是 Java的初学者,我正在尝试使用IntelliJ运行我的代码,我刚刚安装了JDJ 1.7作为我的IDE.以下代码保持甚至不编译并继续给我错误: Error: Could not find or load main class libTest 码 import java.lang.Integer;import java.lang.String;import java.lan
我是 Java的初学者,我正在尝试使用IntelliJ运行我的代码,我刚刚安装了JDJ 1.7作为我的IDE.以下代码保持甚至不编译并继续给我错误:

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");
   }
}

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

解决方法

这可能有所帮助:

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

2)“运行”菜单 – > “编辑配置” – >删除个人资料 – >添加配置文件(“应用程序”,如果它是Java应用程序),从“主类”下拉菜单中选择您的主类.

3)“构建”菜单 – > “重建项目”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读