IntelliJ IDEA: java.lang.ClassNotFoundException

Check this image I am using Intellij IDEA and getting this error. My code is:

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Pres
{
    public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new FileReader("kk.data"));
    BufferedWriter bw = new BufferedWriter(new FileWriter("samlog.csv"));
    String line;
    while((line=br.readLine())!=null)
    {
        String[] values =line.split(" ",-1);
        bw.write(values[0]+","+values[3]+","+values[5]+"\","+values[6]+ ","+values[8]+"\n");
    }
    br.close();
    bw.close();
}
}

Error window

Exception in thread "main" java.lang.ClassNotFoundException: siimport.Pres
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

Process finished with exit code 1

What could be the problem that causes this error and how can I solve it?

+4
source share
2 answers
Exception in thread "main" java.lang.ClassNotFoundException: Main

In the run / debug configuration, you specified an invalid class name for the Main class field. The class name must be a class that has a method mainto run.

, / . , Edit Configurations → Alt-Shift-F10 . ​​. / .

"" → "" , , @Bajal, "" Ctrl-Shift-F10.

+3

, , " Classpath " ProjectName

" " ProjectName_main

- , , , , gradle/maven, Intellij.

+1

Source: https://habr.com/ru/post/1628705/


All Articles