简体   繁体   中英

Intellij does not find main class of java project

I have a simple code with a main class, but it is not identified by ide, I am not identifying the problem.

Main.java

public class Main {
public static void main(String[] args) {
    FileReader leitor = new FileReader("config.txt");
    BufferedReader buffer = new BufferedReader(leitor, 2 * 1024 * 1024);
    String linha = buffer.readLine();
    while (linha != null) {
        System.out.print(linha+"\n");
        linha = buffer.readLine();
        Thread.sleep(1000);
    }
} catch (FileNotFoundException ex) {
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}

I can't select the main class

在此处输入图片说明

Thanks

Intellij did not recognize the java folder as a source folder.

I guess, you did not import the project as a maven project. Checkout the import maven project guide .

To fix this quickly, you can right click on the java folder, select Mark Directory as and choose Sources Root .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM