Could not find or load main class com.company.Main Caused by: java.lang.ClassNotFoundException: com.company.Main code example

Example 1: > Task :run FAILED Error: Could not find or load main class Caused by: java.lang.ClassNotFoundException:

Check your build.gradle file and update the application block:

application {
    // Define the main class for the application.
  	// insert the entire name of the class
    mainClassName = 'packageName.MainClass'
}

Example 2: eclipse Error: Could not find or load main class main java.lang.ClassNotFoundException

// Run configurations -> Run -> Run configurations
// In the Classpath tab select "Advanced"
// Add where Eclipse usually put the *.class for the projects, which is (usually) "bin".

Example 3: Error: Could not find or load main class Hello Caused by: java.lang.ClassNotFoundException: Hello studio visual code

package dto;
/**
 * Simple Java program to demonstrate following error
 * Error :Could not find or load main class
 * 
 * @author Javin Paul
 */
public class HelloHP {

    public static void main(String args[]) {
        System.out.println("My first program in Java, HelloWorld !!");
       
    }

}

Tags:

Java Example