Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Can't run java project with module warning(Depending on SWT jar which seeems to not be modular.)
Can't run java project with module warning [message #1831055] Tue, 11 August 2020 00:10 Go to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 211
Registered: July 2009
Senior Member
I have a simple java project that has a lib folder with swt.jar in it. It was added to the modulepath in the project's Properties > Java build path > Libraries dialog. When I import and use an swt class in my class, I'm prompted to add an entry to my module-info file. It adds "swt" with a warning:

Name of automatic module 'swt' is unstable, it is derived from the module's file name.


When I try to run the project as a java application I get this error in console and nothing runs:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module swt not found, required by ca.footeware.swt.converter


If I export the project as a runnable jar with dependencies enclosed, it works with a similar warning. The exported jar does run (but it's not a convenient development cycle :)

On another note, if instead of adding the jar to a lib folder, I add it as a user library, the export wizard fails to package the dependency in the jar and it doesn't run. But I'll save that one for another day.

I'm running eclipse 4.16 with OpenJDK-14.

Any help appreciated,
Craig
Re: Can't run java project with module warning [message #1831121 is a reply to message #1831055] Tue, 11 August 2020 22:38 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 211
Registered: July 2009
Senior Member
Update: I read somewhere that for non-modular jars a MANIFEST.MF header, Automatic-Module-Name, can be used. I cracked open the swt.jar and added the header with value org.eclipse.swt, the root package of the jar. I removed the Requires swt; from my module-info.java and again was prompted to add an entry from my class with an swt import. This time though it entered Requires org.eclipse.swt; and no warning was produced. When I tried running the project however I got the same error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.eclipse.swt not found, required by ca.footeware.swt.converter


Any ideas anyone,
Craig
Re: Can't run java project with module warning [message #1831265 is a reply to message #1831121] Sun, 16 August 2020 06:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31543
Registered: July 2009
Senior Member
I'm not expert at this but since no one seems inclined to answer you, perhaps this answer is helpful:

https://stackoverflow.com/questions/46713289/how-to-use-3rd-party-library-in-java9-module


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Can't run java project with module warning [message #1831285 is a reply to message #1831265] Sun, 16 August 2020 17:03 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 211
Registered: July 2009
Senior Member
Thanks Ed, I'll look it over.
Re: Can't run java project with module warning [message #1831444 is a reply to message #1831285] Thu, 20 August 2020 01:14 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 211
Registered: July 2009
Senior Member
Well after reading a great deal I'm convinced my error running a modular project, depending on swt, in eclipse is due to my Run Configuration.

My project and module-info.java:
index.php/fa/38795/0/

My Run Configuration's VM args:
--module-path /home/craig/Downloads/swt.jar;/home/craig/workspace/ca.footeware.converter


I tried dropping the .jar to reference only the module name in the jar but I get the same error, i.e.:
--module-path /home/craig/Downloads/swt;/home/craig/workspace/ca.footeware.converter


My runtime error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module swt not found, required by ca.footeware.converter


So I believe it finds my ca.footeware.converter module but not the swt module, the automatically named module it requires.

Here's my Java Build Path Libraries and Modules pages:
index.php/fa/38796/0/

index.php/fa/38797/0/

Any ideas? Lots of simple examples out there but nothing that addresses my situation very well.
Craig
Re: Can't run java project with module warning [message #1831487 is a reply to message #1831444] Thu, 20 August 2020 15:53 Go to previous message
Craig Foote is currently offline Craig FooteFriend
Messages: 211
Registered: July 2009
Senior Member
Got it working! I'm on linux so my --module-path delimiter should have been : not ;
My final VM args:

--module-path ca.footeware.converter:ca.footeware.converter.temperature:/home/craig/Downloads/swt.jar -m ca.footeware.converter/ca.footeware.converter.Converter
Previous Topic:Suspending auto-build
Next Topic:How to add newline to template?
Goto Forum:
  


Current Time: Thu Oct 22 22:08:23 GMT 2020

Powered by FUDForum. Page generated in 0.02105 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top