Java – error: unable to find or load the main class in the IntelliJ ide
•
Java
I'm a beginner in Java. I'm trying to run my code using IntelliJ. I just installed JDJ 1.7 as my ide The following code remains not even compiled and continues to give me errors:
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");
}
}
Do I have to make any changes in the compiler settings? Or code
Solution
This may help:
1) Build menu – > rebuild project Sometimes IntelliJ doesn't override classes because they already exist, so you ask IntelliJ to override everything
2) Run menu – > edit configuration – > delete profile – > Add profile (application, if it is a Java application), select your main class from the main class drop-down menu
3) Build menu – > rebuild project
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
