0

I just created a java project and ran it. It ran fine. Then I converted it into a maven project and resolved all errors in POM.XMl file as well. When I try to run the class file , Am getting the error

Error: Could not find or load main class jhj Caused by: java.lang.ClassNotFoundException: jhj

My class looks like this:

public class jhj {

    public static void main(String[] args)
    {
        System.out.println("as");
    }
}

And my Environment variables are properly set.

I have set the M2_home, MAVEN_HOME and JAVA_HOME as well. I tried removing the project from the workspace and re-importing them. Also, I tried with refresh and Maven>>update the project options as well

Dharman
  • 30,962
  • 25
  • 85
  • 135

1 Answers1

0

Check your project build-path and enable specific output folders for each folder. Go one by one though each source-folder of your project and set the output folder that maven would use.

For example, your web project's src/main/java should have target/classes under the web project, test classes should have target/test-classes also under the web project and so.

Using this configuration will allow you to execute unit tests in eclipse.

Just one more advice, if your web project's tests require some configuration files that are under the resources, be sure to include that folder as a source folder and to make the proper build-path configuration.

Hope it helps.

Akzy
  • 1,817
  • 1
  • 7
  • 19