37

When I try to export my project as a runnable jar Eclise gives me the following error:

No resources selected.

The project runs fine within Eclipse, I already tried to clean the project before exporting, but that didn´t work.

Any ideas on how to fix this.

TrashCan
  • 817
  • 4
  • 13
  • 20

14 Answers14

63

The problem is most likely with your run configuration.

  • Go to your Class that contains the main(String[] args) method you wish to automatically run when the jar is called from the command line
  • Right-click->Run As...->Application
  • Make sure it runs to your satisfaction
  • Now go through the export process as before, selecting the newly created launch configuration.

The last step is key.

Robert Christian
  • 18,218
  • 20
  • 74
  • 89
  • 1
    Will you please elaborate on where to find the newly created launch configuration? Everything seems the same. – tricknology Apr 02 '14 at 07:32
  • I think what was meant was that you choose the correct project from the dropdown menu labelled "Launch configuration", that is what worked for me, anyways – CSCH Apr 30 '15 at 18:39
  • 1
    just tried this a few times and still getting the error – Ben Arnao Feb 14 '18 at 22:45
  • 1
    This solution is correct but, for newbs (like me) you should probably add that the :Launch Configuration" value at the top of the popup is a drop down. This should be obvious, I realize, but it took me 3 profanity filled attempts to grasp that and select the correct run configuration. Also; these sort of things seem to crop up when moving projects around from one device to another. – Keith Fosberg Apr 17 '19 at 15:50
14

I found another solution.

I found that there's a bug in JDK 9.

I solved it by downgrade to JDK 8(1.8.1)

Seamoon Lee
  • 141
  • 1
  • 2
3

I fixed the problem, I exported the project as an archive file. Then I opened up a new workspace and imported the the archived project. After that I tried to export the project as a runnable jar, after two tries the jar runs as is it should.

I still don't know what the exact cause was but I hope someone how has run into the same problem finds this helpful.

TrashCan
  • 817
  • 4
  • 13
  • 20
3

Doing a (project->clean) and creating a new run configuration (with correct project and class name with main() method, selected) solved the problem for me.You just have to select the new run configuration while exporting runnable jar :)

MD. Mohiuddin Ahmed
  • 2,092
  • 2
  • 26
  • 35
1

Try this, this is the way to create a jar or runnable jar in eclipse, all your external libraries in the project will be included

File -> Export-> Java ->Runnbale JAR file

Launch configuration : your Class containing the public static void main(String[] args)

Export destination : Target place

Library Handling:

Package required libraries into generated JAR

FINISH
Kumar Vivek Mitra
  • 33,294
  • 6
  • 48
  • 75
  • 1
    Tried that, I am still getting the error, I also compared the build path source tab with a newly created project and found no unexpected things – TrashCan Jul 02 '12 at 08:56
  • I will try to export the project to an archive or filesystem. Then I will try to import the exported project in another workspace and try from there. – TrashCan Jul 02 '12 at 08:59
0

When you click this option in Eclipse you should get a popup that lets you choose what files to export, you need to select the src folder.

Tomer
  • 17,787
  • 15
  • 78
  • 137
  • 1
    I only get this pop-up when I export the project as a regular jar. Not when I export the project as a **runnable** jar. – TrashCan Jul 02 '12 at 08:38
0

I was having this same problem, and I was able to resolve it. Maybe you should cross verify the main class, that you selected in this project. It is possible that some other project's main class may have the same name as the main class you selected. Make sure the main class you selected is the one from the project that you selected.

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
tanrl
  • 1
0

The problem is your package. You probably renamed it, and in the export option, the program was confused, and it was using the first name of your package.

Sumurai8
  • 20,333
  • 11
  • 66
  • 100
0

This is basically happen when you change package name under which you made your program. This will create confusion regarding package, as per program export, main method still written in old package. To resolve it, Just copy it and paste it in same package with different name and then try to export it. Check for log too.

0

I was in the same situation. For me deleting existing eclipse installation(not not the project workspace) and opening the existing eclipse workspace with new installation of eclipse was the only thing that worked.

Ap S
  • 1
0

Just copy the project as a new one. Configure the build path by creating new Run/Debug Settings.this would resolve the problem.

-1

I continued to get the "no resources selected" error. I then did the procedure I am quoting and it gave me a MANIFEST file. Then I was able to create an executable JAR.

Quoting: "I exported the project as an archive file. Then I opened up a new workspace and imported the the archived project. After that I tried to export the project as a runnable jar, after two tries the jar runs as is it should."

Jeannine Menger
  • 177
  • 1
  • 3
-1

I also faced the same issue, in my case, I just closed the project and reopened it, now it's wokring

Assasin
  • 9
  • 4
-3

Check that your project is correct at the time when you select the main class.

If the class non exist, it's the standard error of Eclipse.

vince
  • 1