Error:
/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=53049:
/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 Scratch
Error: Could not find or load main class HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
Process finished with exit code 1
Class File:
public class HelloWorld {
public static void main(String... args) {
System.out.println("Hello");
}
}
As you can see the above class does not have any complication issues or syntax errors. There can be multiple reasons that you may get the error, below are some of the solutions that may work for you!
- Make sure that the class name is correct.
- Go to Menu: Build -> Re-Build Project.
- Remove .idea directory from your project and restart IDE.
- Go to Files: Invalidate Cache/ Restart...
- Check your project has a out folder, if not create one, example: /Users/code2care/IdeaProjects/java-examples/out
- Edit Build/Run Configurations and check if you have selected the correct Java class that has a main method.

- Error: Can not find the tag library descriptor for
- Create a Database Table using JDBC PreparedStatement
- Java JDBC Select Multiple Records from table as List using PreparedStatement
- Java Jackson with Maven Example
- [fix] Java JDBC ConnectException: Connection refused
- Spring Boot: Transactions Management with JDBCTemplate Example
- Java Get Current Date for a Specific Time Zone
- What are the 8 Primitive Data Types in Java
- Java JDBC: Insert Java 8 LocalDate and Time using PreparedStatement
- Maven Eclipse (M2e) No archetypes currently available
- How to Sort a LinkedList in Java
- [Fatal Error] XML The markup in the document following the root element must be well-formed.
- Split a String in Java with Examples
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- Truncate table using Java JDBC Example
- Java: Generate random numbers within a range
- Parse XML file in Java using DOM Parser
- How to get Client IP address using Java Code Example
- JDBCTemplate Querying Examples with Spring Boot 3
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- String Boot + Redis - SET and GET String Commands Examples
- Setting up Spring Boot 3 + Maven + MySQL + JDBC Example
- Spring Boot: JdbcTemplate Update Query With Parameters Example
- Java Split String by Spaces
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- Error: Safari quit unexpectedly. Problem Report for Safari - MacOS
- Run IntelliJ Java main method without Gradle build - Gradle
- Android Constant and Resource Type Mismatches Lint - Android
- java.lang.ClassNotFoundException android.support.v7.widget.Toolbar [Fix] - Android
- Convert Collection List to Set using Java 8 Stream API - Java
- How to turn off Dark theme in Excel for Mac - Microsoft
- sudo is not recognized as an internal or external command - Windows
- Calculate Area of Parallelogram - C-Program