This site is maintained for archival purposes only. Eclipse projects have transitioned to GitHub and Eclipse GitLab. Use the Projects search tool to locate your project and access its latest code and issue tracker.
Bug 525711 - [9][jar exporter] exporting runnable jar: "Could not find main method from given launch configuration".
Summary: [9][jar exporter] exporting runnable jar: "Could not find main method from gi...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.7.1a   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.7.2   Edit
Assignee: Kalyan Prasad Tatavarthi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-07 08:13 EDT by Stephan Herrmann CLA
Modified: 2019-04-18 13:05 EDT (History)
8 users (show)

See Also:
noopur_gupta: review+


Attachments
OK and Error export project in ZIP Files (24.25 KB, application/zip)
2019-04-18 13:04 EDT, Ladislav Zahour CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2017-10-07 08:13:14 EDT
See e.g. https://stackoverflow.com/questions/46475709/java-9-eclipse-4-7-portable-export-error-resource-not-found-could-not-find-m?noredirect=1#comment80185686_46475709

I can reproduce on a simple modular toy project plus a launch configuration that has both the project itself and JRE on the module path.
Comment 1 Sarika Sinha CLA 2017-10-07 10:46:38 EDT
I think exporting logic lies in jdt ui. 
@Noopur ?
Comment 2 Stephan Herrmann CLA 2017-10-07 11:20:36 EDT
(In reply to Sarika Sinha from comment #1)
> I think exporting logic lies in jdt ui. 
> @Noopur ?

Sorry, I was misled by the relation to launch configurations.

Indeed the error is raised from org.eclipse.jdt.internal.ui.jarpackagerfat.FatJarPackageWizardPage.getSelectedElementsWithoutContainedChildren(ILaunchConfiguration, JarPackageData, IRunnableContext, MultiStatus)
Comment 3 Stephan Herrmann CLA 2017-10-07 11:30:55 EDT
Problem occurs, because FatJarPackageWizardPage.getClasspath(ILaunchConfiguration) only inspects entries of kind IRuntimeClasspathEntry.USER_CLASSES, not of kind IRuntimeClasspathEntry.MODULE_PATH.

Including MODULE_PATH in the check lets export complete, but then if multiple modules are involved the resulting jar merges them all into the root of the jar and only one module-info.class will survive.

Shouldn't modular jars create separate root folders per module? Do we have a bug for that?
Comment 4 Noopur Gupta CLA 2017-10-09 05:08:26 EDT
(In reply to Stephan Herrmann from comment #3)
> Problem occurs, because
> FatJarPackageWizardPage.getClasspath(ILaunchConfiguration) only inspects
> entries of kind IRuntimeClasspathEntry.USER_CLASSES, not of kind
> IRuntimeClasspathEntry.MODULE_PATH.

Not sure but some failures in bug 515921 could be related.

> Including MODULE_PATH in the check lets export complete, but then if
> multiple modules are involved the resulting jar merges them all into the
> root of the jar and only one module-info.class will survive.
>
> Shouldn't modular jars create separate root folders per module? Do we have a
> bug for that?

There is no bug for this yet. We can check how it is handled for multiple plug-ins currently and do the same for modules in a separate bug.
Comment 5 Noopur Gupta CLA 2017-10-14 13:26:12 EDT
*** Bug 526037 has been marked as a duplicate of this bug. ***
Comment 6 Andrea Sanguineti CLA 2017-10-15 14:02:23 EDT
(In reply to Noopur Gupta from comment #4)
> (In reply to Stephan Herrmann from comment #3)
> > Problem occurs, because
> > FatJarPackageWizardPage.getClasspath(ILaunchConfiguration) only inspects
> > entries of kind IRuntimeClasspathEntry.USER_CLASSES, not of kind
> > IRuntimeClasspathEntry.MODULE_PATH.
> 
> Not sure but some failures in bug 515921 could be related.
> 
> > Including MODULE_PATH in the check lets export complete, but then if
> > multiple modules are involved the resulting jar merges them all into the
> > root of the jar and only one module-info.class will survive.
> >
> > Shouldn't modular jars create separate root folders per module? Do we have a
> > bug for that?
> 
> There is no bug for this yet. We can check how it is handled for multiple
> plug-ins currently and do the same for modules in a separate bug.

Is there any work-around at the moment?
I also tried creating a new project with just a main class and a println but i always get this error
Comment 7 Mason Chou CLA 2017-10-16 20:34:00 EDT
(In reply to Andrea Sanguineti from comment #6)
> (In reply to Noopur Gupta from comment #4)
> > (In reply to Stephan Herrmann from comment #3)
> > > Problem occurs, because
> > > FatJarPackageWizardPage.getClasspath(ILaunchConfiguration) only inspects
> > > entries of kind IRuntimeClasspathEntry.USER_CLASSES, not of kind
> > > IRuntimeClasspathEntry.MODULE_PATH.
> > 
> > Not sure but some failures in bug 515921 could be related.
> > 
> > > Including MODULE_PATH in the check lets export complete, but then if
> > > multiple modules are involved the resulting jar merges them all into the
> > > root of the jar and only one module-info.class will survive.
> > >
> > > Shouldn't modular jars create separate root folders per module? Do we have a
> > > bug for that?
> > 
> > There is no bug for this yet. We can check how it is handled for multiple
> > plug-ins currently and do the same for modules in a separate bug.
> 
> Is there any work-around at the moment?
> I also tried creating a new project with just a main class and a println but
> i always get this error

The easiest workaround at the current moment is to use an older version of the jdk for eclipse. This can be done by going into Window->Preferences->Java->Install JREs and adding the older jdk folder.

I've rolled back to jdk8 and the eclipse's export jar works fine, in most cases.

If you really need to use Java9, then you're best bet is to manually create the jar using javac or using another build system like Gradle.
Comment 8 Andrea Sanguineti CLA 2017-10-17 10:28:44 EDT
(In reply to Mason Chou from comment #7)
> (In reply to Andrea Sanguineti from comment #6)
> > (In reply to Noopur Gupta from comment #4)
> > > (In reply to Stephan Herrmann from comment #3)
> > > > Problem occurs, because
> > > > FatJarPackageWizardPage.getClasspath(ILaunchConfiguration) only inspects
> > > > entries of kind IRuntimeClasspathEntry.USER_CLASSES, not of kind
> > > > IRuntimeClasspathEntry.MODULE_PATH.
> > > 
> > > Not sure but some failures in bug 515921 could be related.
> > > 
> > > > Including MODULE_PATH in the check lets export complete, but then if
> > > > multiple modules are involved the resulting jar merges them all into the
> > > > root of the jar and only one module-info.class will survive.
> > > >
> > > > Shouldn't modular jars create separate root folders per module? Do we have a
> > > > bug for that?
> > > 
> > > There is no bug for this yet. We can check how it is handled for multiple
> > > plug-ins currently and do the same for modules in a separate bug.
> > 
> > Is there any work-around at the moment?
> > I also tried creating a new project with just a main class and a println but
> > i always get this error
> 
> The easiest workaround at the current moment is to use an older version of
> the jdk for eclipse. This can be done by going into
> Window->Preferences->Java->Install JREs and adding the older jdk folder.
> 
> I've rolled back to jdk8 and the eclipse's export jar works fine, in most
> cases.
> 
> If you really need to use Java9, then you're best bet is to manually create
> the jar using javac or using another build system like Gradle.

Ok thanks
Comment 9 Stephan Herrmann CLA 2017-10-21 16:40:58 EDT
*** Bug 526340 has been marked as a duplicate of this bug. ***
Comment 10 Jack TANG CLA 2017-10-25 07:58:22 EDT
When will the release date of this patch? I need it so much because the java 9 runtime cannot run my java program.
Comment 11 Kalyan Prasad Tatavarthi CLA 2017-11-08 03:36:55 EST
(In reply to Stephan Herrmann from comment #3)
> Problem occurs, because
> FatJarPackageWizardPage.getClasspath(ILaunchConfiguration) only inspects
> entries of kind IRuntimeClasspathEntry.USER_CLASSES, not of kind
> IRuntimeClasspathEntry.MODULE_PATH.
> 
> Including MODULE_PATH in the check lets export complete, but then if
> multiple modules are involved the resulting jar merges them all into the
> root of the jar and only one module-info.class will survive.
> 
> Shouldn't modular jars create separate root folders per module? Do we have a
> bug for that?

Are multiple modules allowed in a single jar file?

https://docs.oracle.com/javase/9/docs/specs/jar/jar.html

talks about modular jar files which have module-info.class, in the top-level directory (or root) directory. But does not mention anything about including other modules in the modular jar. There is also no way to specify the module path for the included modules in the Manifest.
Comment 12 Eclipse Genie CLA 2017-11-08 04:45:20 EST
New Gerrit change created: https://git.eclipse.org/r/111199
Comment 13 Kalyan Prasad Tatavarthi CLA 2017-11-08 04:47:58 EST
The new gerrit change along with the the changes for bug 515921 fix the issue of creating modular jar file using java9.

This change also supports creation of a Jar file which includes other modular jars.
Comment 14 Kalyan Prasad Tatavarthi CLA 2017-11-08 05:01:54 EST
(In reply to Kalyan Prasad Tatavarthi from comment #13)
> The new gerrit change along with the the changes for bug 515921 fix the
> issue of creating modular jar file using java9.
> 
> This change also supports creation of a Jar file which includes other
> modular jars.

The New gerrit change along with the the changes for bug 515921 fix the issue of creating modular jar file using java9.

This change also supports creation of a Jar file which includes other
modular jars only if they are packaged. This operation fails if the required libraries are exported due to the same issue of handling multiple modules.
Comment 16 Eclipse Genie CLA 2017-11-08 07:21:22 EST
New Gerrit change created: https://git.eclipse.org/r/111210
Comment 17 Noopur Gupta CLA 2017-11-08 07:25:24 EST
(In reply to Eclipse Genie from comment #16)
> New Gerrit change created: https://git.eclipse.org/r/111210

Kalyan, please verify the fix in the next I-build, after which it can be released in the R4_7_maintenance branch.
Comment 18 Kalyan Prasad Tatavarthi CLA 2017-11-09 02:12:49 EST
(In reply to Noopur Gupta from comment #17)
> (In reply to Eclipse Genie from comment #16)
> > New Gerrit change created: https://git.eclipse.org/r/111210
> 
> Kalyan, please verify the fix in the next I-build, after which it can be
> released in the R4_7_maintenance branch.

Verified the fix in the I-build I20171108-2000.
Comment 19 Eclipse Genie CLA 2017-11-10 07:11:25 EST
Gerrit change https://git.eclipse.org/r/111210 was merged to [R4_7_maintenance].
Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=fa928215e5fcf8ae06b4b5a5bfa82f5efa2f7be2
Comment 20 Noopur Gupta CLA 2017-11-10 07:13:33 EST
Created follow-up bugs: bug 527114 and bug 527113.
Comment 21 Kalyan Prasad Tatavarthi CLA 2017-11-16 01:13:31 EST
Verified as fixed in M20171115-1700.
Comment 22 Clifton Liles CLA 2018-06-11 12:36:56 EDT
If this bug is supposed to be fixed in 
Eclipse Java EE IDE for Web Developers.
Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200

It is not! 
The operation yields a jar file of 1KB and only :
META_INF dir with only a MANIFEST.MF file consisting of:
Manifest-Version: 1.0
Class-Path: .
Comment 23 Kalyan Prasad Tatavarthi CLA 2018-06-13 08:13:56 EDT
(In reply to Clifton Liles from comment #22)
> If this bug is supposed to be fixed in 
> Eclipse Java EE IDE for Web Developers.
> Version: Oxygen.3a Release (4.7.3a)
> Build id: 20180405-1200
> 
> It is not! 
> The operation yields a jar file of 1KB and only :
> META_INF dir with only a MANIFEST.MF file consisting of:
> Manifest-Version: 1.0
> Class-Path: .

This bug fixes the issue of:  
1) Export > Java > JAR file 
2) Export > Java > Runnable JAR file

I have tested and checked if this is fixed in 
Eclipse Java EE IDE for Web Developers.

Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200

and it is fixed.

Is this the same scenario you are using and you are not able to create a jar or a runnable jar file?
if so, please provide a sample project to reproduce this issue.

Or are you using : Export > Java EE > App Client JAR file?

If this is the case, that is a different bug.
Comment 24 Clifton Liles CLA 2018-06-13 15:12:32 EDT
I am using :
1) Export > Java > JAR file 
2) Export > Java > Runnable JAR file
Both fail.
This seams to a general problem. I have tried to do this on serval project and all give the same result, fail.
Note: I have been getting a lot of "Eclipse had an error. 
Sent it?" I have sent them all.  Could it be that my copy of eclipse is corrupted? 
I will try and get togeather a sample project for you.
Cliff
Comment 25 Clifton Liles CLA 2018-06-13 15:13:17 EDT Comment hidden (obsolete)
Comment 26 Clifton Liles CLA 2018-06-13 15:30:50 EDT
(In reply to Kalyan Prasad Tatavarthi from comment #23)
> (In reply to Clifton Liles from comment #22)
> > If this bug is supposed to be fixed in 
> > Eclipse Java EE IDE for Web Developers.
> > Version: Oxygen.3a Release (4.7.3a)
> > Build id: 20180405-1200
> > 
> > It is not! 
> > The operation yields a jar file of 1KB and only :
> > META_INF dir with only a MANIFEST.MF file consisting of:
> > Manifest-Version: 1.0
> > Class-Path: .
> 
> This bug fixes the issue of:  
> 1) Export > Java > JAR file 
> 2) Export > Java > Runnable JAR file
> 
> I have tested and checked if this is fixed in 
> Eclipse Java EE IDE for Web Developers.
> 
> Version: Oxygen.3a Release (4.7.3a)
> Build id: 20180405-1200
> 
> and it is fixed.
> 
> Is this the same scenario you are using and you are not able to create a jar
> or a runnable jar file?
> if so, please provide a sample project to reproduce this issue.
> 
> Or are you using : Export > Java EE > App Client JAR file?
> 
> If this is the case, that is a different bug.

Ups, I entered a comment instead of replying.  Please see comments 25 and 25. Please delete one of then if you have the power.
Comment 27 Clifton Liles CLA 2018-06-13 19:47:47 EDT
OK, I don't know what to say. I made a test project and it worked! I went back to one that failed and it worked.  When I working on making the jar file, eclipse was restarted a few times, I think there was a computer shutdown and restart also. I just switched workspaces and the other failed jar and it also worked.  
Note: I had also tried building a regular jar(not executable) file, with a manifest file added.  It also failed, with an empty manifest at the head and my manifest in the body of the jar.
If there is anything you would like, Please let me know.
Unfortunately the bad jars have been overwritten or deleted.  
Cliff
Comment 28 Stephan Herrmann CLA 2018-06-14 08:06:08 EDT
(In reply to Clifton Liles from comment #27)
> OK, I don't know what to say. I made a test project and it worked! 

Any chance that any of the Eclipse restarts also involved installation of some updates? Other than that I don't see a chance to find out what was going on and your bug just escaped into the wild :)
Comment 29 Clifton Liles CLA 2018-06-14 11:52:38 EDT
(In reply to Stephan Herrmann from comment #28)
> (In reply to Clifton Liles from comment #27)
> > OK, I don't know what to say. I made a test project and it worked! 
> 
> Any chance that any of the Eclipse restarts also involved installation of
> some updates? Other than that I don't see a chance to find out what was
> going on and your bug just escaped into the wild :)

Possible, I guess.  I did not notice any.  I did find a couple of the bad jar files. If you what to have a look at them. I'll send them to you. Maybe Eclipse is self healing!
Comment 30 Ladislav Zahour CLA 2019-04-18 13:04:01 EDT
Created attachment 278337 [details]
OK and Error export project in ZIP Files

First project in YIP file export OK two project eror . Projects is from one system eclipse, creates in this system concurrently.
Comment 31 Ladislav Zahour CLA 2019-04-18 13:05:05 EDT
The same error in configure

-- Configuration Details --
Product: Eclipse IDE 4.11.0.20190314-1200 (org.eclipse.epp.package.jee.product)Installed Features:
 org.eclipse.jdt 3.17.0.v20190307-0500
Versioning Plugin:
 org.eclipse.platform 4.11.0.v20190307-0500