[java] Eclipse Java error: This selection cannot be launched and there are no recent launches

I have looked everywhere on the internet and tried everything the forums say to do and nothing works. This error keeps coming up. I have tried running my java project (not for android) even the drop down run as button doesn't work because it says "none applicable".

This question is related to java eclipse

The answer is


Click on the drop down next to the Run button, After that choose Run Configuration, shows three option, for example i choose java application add class(Name of the class of your project) in that then Click on the ok button ...Run your application :)

Neeraj


Check, you might have written this statement wrong.

public static void main(String Args[])

I have also just started java and was facing the same error and it was occuring as i didn't put [] after args. so check ur statment.


When you create a new class file, try to mark the check box near

public static void main(String[] args) {

this will help you to fix the problem.


click on the project that you want to run on the left side in package explorer and then click the Run button.


Make sure the "m" in main() is lowercase this would also cause java not to see your main method, I've done that several times unfortunately.


Eclipse needs to see a main method in one of your project's source files in order to determine what kind of project it is so that it can offer the proper run options:

public static void main(String[] args)

Without that method signature (or with a malformed version of that method signature), the Run As menu item will not present any run options.


Check if the filename is same as the classname used by your program.

eg.:

class Dfs{ psvm(String[] args){}}

filename should be Dfs.java


Have you checked if:

  1. You created a class file under src folder in your JAVA project?(not file)
  2. Did you name your class as the same name of your class file?

I am a newbie who try to run a helloworld example and just got the same error as yours, and these work for me.


It happens when sometimes we copy or import the project from somewhere. The source folder is a big thing to concern about.

One simple technique is, create a new project, inside the source folder, create a new class and paste the content over there.

It will work...

Hope it helps.