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.

Fixing Could not find or load main class error
More Posts related to Java,
- How to install Java 11 on Mac
- Get Client IP address from HTTP Response in Java
- SharePoint Open in the client application document opens in browser
- How to verify if java is installed on the computer and get version detail
- Java - Check if array contains the value
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- How to run Java Unit Test cases with Apache Maven?
- What Java version is used for Minecraft 1.18
- List of jar files for Jax-ws (SOAP) based Java Web Services
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- Convert Instant timestamp into LocalDateTime Java Code Example
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds
- Create simple struts2 project using maven commands
- Java - PatternSyntaxException
- List of Online Java compiler with console
- Minecraft Java Edition
- How to declare and initialize Array in Java Programming
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException
- Java XML-RPC 3.1.x based web service example
- Simple Struts 2 Tutorial in eclipse with tomcat 7 server
- Java 8 foreach loop code examples
- Java -Day of the week using Java 8 DayOfWeek Enum
- Java 8 - Convert List to Map Examples
- Java: TimeZone List with GMT/UTC Offset
- list of jars required for hibernate 4.x.x
More Posts:
- How to Gzip a file directory on Mac OS X using Terminal Command - Mac-OS-X
- [Solved] Mic not working on iPhone 7 after iOS 14 upgrade - Apple
- Setting up Cloud feature with Notepad++ - NotepadPlusPlus
- Find Mac version using terminal command - MacOS
- Unable to connect to the Internet : Google Chrome - Chrome
- Enable Spellcheck in eclipse workspace - Eclipse
- ls command sort by file size [Linix/UNIX/macOS/bash] - Linux
- How to enable line numbers in IntelliJ - HowTos