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.
More Posts related to Java,
- Deep Dive into Java 8 Predicate Interface
- Read and Parse XML file using Java DOM Parser [Java Tutorial]
- Java 8 Predicate Functional Interface isEqual() Method Example
- Convert Multidimensional Array toString In Java
- How to read int value using Scanner Class Java
- Spring Boot AI + LLM + Java Code Example
- Write to a File using Java Stream API
- Implementing Bubble Sort Algorithm using Java Program
- How to Fix XmlBeanDefinitionStoreException in Java SpringBoot ApplicationConfig.xml
- YAML Parser using Java Jackson Library Example
- [Fix] java: integer number too large compilation error
- Convert JSON String to Java GSON Object Example
- Read a file using Java 8 Stream
- Java Spring Boot 3 Web Hello World with Gradle in IntelliJ
- Ways Compare Dates in Java Programming with Examples
- Pretty Print JSON String in Java Console Output
- Java JDBC with Join Queries Example
- How to Check For Updates on Windows 11 (Step-by-Step)
- [Fix] java.net.MalformedURLException: unknown protocol
- How to display date and time in GMT Timezone in Java
- Error: LinkageError occurred while loading main class UnsupportedClassVersionError [Eclipse Java]
- How to convert a String to Java 8 Stream of Char?
- RabbitMQ Queue Listener Java Spring Boot Code Example
- 5+ Fibonacci number Series Java Program Examples [ 0 1 1 2 3 ..]
- Handling NullPointerException with Java Predicate
More Posts:
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException - Java
- Add or remove users from sudo group - Ubuntu - Ubuntu
- [Solution] macOS could not be installed on your computer OSInstall.mpkg appears to be missing or damaged - MacOS
- Python: If Else Statements in One Single Line - Python
- How to copy file name and path to clipboard in Notepad++ - NotepadPlusPlus
- Create Custom Toast Android Programming - Android
- Fix: Make makefile:31 Error 127 (GCC) - Ubuntu
- How to Create a Git Branch in 6 Different ways - Git