java cannot find main class 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: 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 !!");
}
}