How to Fix Eclipse Error: The Selection Cannot Be Launched
This tutorial demonstrates the Eclipse error The selection cannot be launched, and there are no recent launches
in Java.
Eclipse The selection cannot be launched
Error
When using Eclipse, an error The selection cannot be launched
can occur. While we have a selection of classes and no class has the main
method, this error will occur in Eclipse because Eclipse will only run the set of classes or an application when it finds the main
class.
Eclipse needs to see the main
method in one of the project files. Otherwise, it cannot run the application.
The main
method should be properly defined as below.
public static void main(String[] args)
Without a proper definition of the main
method, Eclipse will throw the The selection cannot be launched
. Here is an example.
package delftstack;
public class Example {
public static void main(String[] args[]) throws IOException {
System.out.println("This is Delftstack.com");
}
}
The code above will throw The selection cannot be launched
because the main
method is not properly defined. Here is the correct version of the code.
package delftstack;
public class Example {
public static void main(String[] args) throws IOException {
System.out.println("This is Delftstack.com");
}
}
The []
is given to the String
keyword in the main
method statement. Now, this code will work properly.
See output:
This is Delftstack.com
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn FacebookRelated Article - Java Eclipse
Related Article - Java Error
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix the Missing Server JVM Error in Java
- How to Fix the 'No Java Virtual Machine Was Found' Error in Eclipse
- How to Fix Javax.Net.SSL.SSLHandShakeException: Remote Host Closed Connection During Handshake
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix Java.Lang.VerifyError: Bad Type on Operand Stack