Short answer: Right-click on the class that contains the main method. Click on “Run As”. Click on “Java Application”. The keyboard shortcut is: Shift+Alt+X J (while holding Shift and Alt, press X; then release Shift and Alt and press J).
Long answer: To be honest, I am not 100% sure why this problem happens. It might be because of using a different jdk. I faced the same error. The solution was easier than I imagined. I was used to running my code using Ctrl + F11. But when I ran it as a java application (the way I described in “short answer”), the problem was resolved. I am not sure if it solves other people’s problems as well, but it is worthwhile to try. 🙂
Related Posts:
- A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1
- Failed to load the JNI shared Library (JDK)
- How to resolve Unable to load authentication plugin ‘caching_sha2_password’ issue
- How to uninstall Eclipse?
- Eclipse/Maven error: “No compiler is provided in this environment”
- Is there a way to convert all comments into javadoc comments? [Eclipse/Java]
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- Failed to write core dump. minidumps are not enabled by default on client version of windows
- How to uninstall Eclipse?
- Editor does not contain a main type in Eclipse [duplicate]
- getting error HTTP Status 405 – HTTP method GET is not supported by this URL but not used `get` ever?
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- Editor does not contain a main type in Eclipse [duplicate]
- Converting characters to integers in Java
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- JRE Missing when installing eclipse
- Can’t find mysqladmin on Mac OSX 10.6.8
- Server Tomcat v9.0 Server at localhost failed to start
- Cannot find “Package Explorer” view in Eclipse
- Why Maven project is tied to J2SE-1.5 by default?
- JVM Crash – “EXCEPTION_ACCESS_VIOLATION”
- what does Dead Code mean under Eclipse IDE Problems Section
- what does Dead Code mean under Eclipse IDE Problems Section
- Eclipse: Java was started but returned error code=13
- Server Tomcat v9.0 Server at localhost failed to start
- How to change a package name in Eclipse?
- what is this ANT build?
- Eclipse “Error: Could not find or load main class”
- Error: Selection does not contain a main type
- Integrate Ant builder into Eclipse: Error “Variable references empty selection”
- Cannot change version of project facet Dynamic Web Module to 3.0?
- Can JavaScript connect with MySQL?
- “Could not find Java SE Runtime Environment.” after installing Java
- Eclipse does not start when I run the exe?
- The declared package does not match the expected package “”
- eclipse won’t start – no java virtual machine was found
- Eclipse Java error: This selection cannot be launched and there are no recent launches
- How can I avoid this Ant Build error?
- Access restriction: The type ‘Application’ is not API (restriction on required library rt.jar)
- Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
- Eclipse error, “The selection cannot be launched, and there are no recent launches”
- channel 3: open failed: connect failed: Connection refused
- Java can’t find file when running through Eclipse
- Eclipse java debugging: source not found
- java.sql.SQLException: No database selected – why?
- No appenders could be found for logger(log4j)?
- Syntax error on token(s), misplaced construct(s)
- “The public type <
> must be defined in its own file” error in Eclipse [duplicate] - Corrupt jar file
- Installing WindowBuilder on Eclipse Neon
- How to clear console in Java – Eclipse
- The import javafx cannot be resolved
- Fatal error compiling: tools.jar not found:
- Unreachable code in eclipse
- how to make jni.h be found?
- Cannot issue data manipulation statements with executeQuery()
- Java project in Eclipse: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- How to import a jar in Eclipse
- “The import org.springframework cannot be resolved.”
- Connection Java – MySQL : Public Key Retrieval is not allowed
- Node cannot be resolved to a type
- How to fix an UnsatisfiedLinkError (Can’t find dependent libraries) in a JNI project
- Resource leak: ‘in’ is never closed
- Android Emulator: Unfortunately App has stopped
- Java console program
- implicit super constructor object() is undefined. must explicitly invoke another constructor
- “Source folder is not a Java project” error in eclipse
- Cannot be resolved to a variable error in Eclipse
- Using JavaFX in JRE 8, “Access restriction” error
- Eclipse Problems View not showing Errors anymore
- ‘No JUnit tests found’ in Eclipse
- “Cannot be resolved to a type” when attempting to use Scanner
- Resolving File paths – ‘File not found’ error in Eclipse
- java eclipse red exclamation mark
- Eclipse is executing the wrong Java file
- Eclipse: JVM terminated. Exit code=2
- “insufficient memory for the Java Runtime Environment ” message in eclipse
- Unknown version of Tomcat was specified in Eclipse
- Which Eclipse IDE version to choose?
- Eclipse IDE – Error: Build path specifies execution environment Java SE 1.7
- Eclipse IDE – Error: Build path specifies execution environment Java SE 1.7
- How can i fix this equals on primitive type(int)
- A JRE or JDK must be available in order to run Eclipse. No JVM was found after searching the following locations
- Error :- java runtime environment JRE or java development kit must be available in order to run eclipse
- The import org.junit cannot be resolved
- Wrong project is being run in Eclipse
- How fix Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
- Maven dependency update on commandline
- The import javax.servlet can’t be resolvedÂ
- How to enable the Java keyword assert in Eclipse program-wise?
- Why “no projects found to import”?
- Error message ‘Cannot be resolved or is not a field’
- Can’t load IA 32-bit .dll on a AMD 64-bit platform
- Eclipse executable launcher error: Unable to locate companion shared library
- How do I enable index downloads in Eclipse for Maven dependency search?
- Eclipse message saying List cannot be resolved to a type
- Check if a database is well installed
- remove wordpress post links