0

I cloned my project from GitHub and now I am not able to run my project.

package edu.test.algorithm;

import edu.test.algorithm.Global;

public class Main {

public static void main(String[] args) {
    Global global= new Global();
    global.runGlobal("-----url");
  }
}

I am getting this error:

Exception in thread "main" java.lang.ClassNotFoundException: edu.test.algorithm.Global.Main
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)

Any idea what's causing this error?

EDIT

I checked this question Intellij suddenly throwing ClassNotFoundExceptionbefore i posted here and it doesn't give me any solution.. Why marking my question as duplicate since that one isn't solving my problem?

Community
  • 1
  • 1
user3774470
  • 29
  • 2
  • 10

2 Answers2

2

Maybe your Ide is wrong run/debug configuration

Main -> Edit Configuration

enter image description here

Check your IDE run configurations and Class

https://www.jetbrains.com/help/idea/2016.2/creating-and-editing-run-debug-configurations.html

1

The exception message hints that you have used the wrong class name when launching the program.

You are (presumably) using edu.test.algorithm.Global.Main as the class name. However you have actually declared Main in the package edu.test.algorithm which means that its full classname is actually edu.test.algorithm.Main.

If you didn't do this explicitly, it is possible1 that you changed the Main classes package and neglected to change (or remake) the launcher config.


1 - I'm not familiar with Intellij ... but I know you can run into this kind of problem with Eclipse.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216