0

When I import java 11 maven project with modules to latest versions of Eclipse I got a whole bunch of hardly visible error, that seems to be whole inconsistency. Indeed when opening in Intellij IDEA or NetBeans it does imports correctly. The first ample error is "The project was not built since its build path is incomplete" - "Cannot find the class file for java.lang.Object. Fix the build path then try building this project." This error appears in two child modules. (This project is docker-based, multimoduled although import of another simple module-infos project also cannot be imported correctly in Eclipse). Next 2 errors are produced in two classes of aforementioned maven modules: " The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files. "
Manipulation with adding JDK 11 to submodules buildpath just leads to the thousands of problems. Such big bunch of errors also appears when I use Eclipse-File-Maven-Update. Moreover when I try to edit most of existing classes or add new ones I got red underline that tells

"Implicit super constructor Object() is undefined for default 
constructor. Must define an explicit constructor"

So almost no opportunity to use Eclipse in this case. But I noted that such issue is produced just when project uses modules (module-info files introduced in java9). When I import project on jdk 8 (even not installed on system), or even on jdk11 without module-info files, all is fine in Eclipse after import. One visible settings difference in Eclipse is that of when I use old no-module project the Build Path is composed with jre environment 8 and maven dependency items, but when using "module-info" project the Build path contains -module path, and -classpath. So I even do not know where to add jre 11, indeed adding does not resolve issue, just make more errors. So what is the resolution of the case??? What settings to do in Eclipse? Maybe override some project files that maybe inherently created in Intellij IDEA.

art
  • 59
  • 1
  • 7
  • Please show a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). In your case, at least the `pom.xml`, the `module-info.java` and regular Java file. Please also tell the exact way how you imported the project into Eclipse (there are different ways leading to different results). – howlger May 10 '21 at 22:46
  • I used to import this project in Eclipse 2019 and 2021 as existing maven project. In former case - there were errors that child sub-modules was not connected in some way to parent one, but it was not the issue I wrote about. In 2021 version this inconsistency was absent - but errors I wrote in topic left. But I would be glad to see what alternatives are for importing java 11 "modules" project, and some guide how to do it in Eclipse correctly?! As the result I use Inteelij IDEA community version. But I tried to import another java 11 modules project and I remember it also failed to import – art May 12 '21 at 22:29
  • And it is difficult to refer to pom.xml, module-info files (as it could not be organized for all modules or folders - if you mean module-info of higher level maybe it is possible). But as first error tells that build path is incomplete, and structur. it is different from java 8 build path. And error says even class Object cannot be found - so I do understand even basic Java 11 libs is not "linked" to IDE. And I have already wrote that Buidl paths classpath and modulepath, but not jre environment and maven dependendency as in case of java 8 project or even maybe java 11 project without modules – art May 12 '21 at 22:43
  • Each Java module (with its own `module-info.java` file) has to be a separate Java project. Please do not add comments, but improve your question by adding a minimal reproducible example. On Stack Overflow it's off-topic to ask for a guide, book, tool, etc. – howlger May 13 '21 at 14:05
  • Sorry, as I see, looking for at online git repo - there is no module-info files in this project, indeed several weeks ago it seems to have a few such files when I searched in IDE. Maybe absence of such files is the reason that Eclipse cannot import it correctly (or maybe java modules are not configured correctly). Although this project is multi-module in maven context as it has section in pom.xml, and every module has its own pox.xml. And it uses openjdk-11-slim docker version. – art May 16 '21 at 20:53
  • The absence of `module-info.java` files is not a problem, it's even simpler. When you open the directory with the parent POM via _File > Open Projects from File System..._ make sure the option _Search for nested projects_ is enabled (assuming the Maven modules are sub-folders of where the parent POM is). – howlger May 16 '21 at 21:19
  • I will try once it will be possible. You think it is so simple solution? As far as I remember - as mentioned, I tried to download some casual java 11 with module-info's project and it also did not worked in Eclipse in Ubuntu. Indeed this project seems to be without module-info files, and does not work. I would like to download such aforementioned casual project to my Eclipse in Windows 32, but it does not work with jdk 11 so it would not be relevant check. – art May 22 '21 at 21:46
  • There are more pitfalls and things to watch when having a `module-info.java` file. Please show a minimal reproducible example. One would need to know the `pom.xml` files and the project structure. What do you mean by _Windows 32_? 32 bit? – howlger May 23 '21 at 06:18
  • I cannot produce pom as it is commercial one. Yes I meant 32bit Windows Eclipse version. But in my rather old Eclipse version I see just File-Open File, no Open Projects from File System. And I used File-Import for it, indeed at start of this one -https://stackoverflow.com/questions/2061094/importing-maven-project-into-eclipse - I see some alternative ways of importing maven project to Eclipse. Again - I checked at gitlab - the contemplated project has no module-info file – art May 23 '21 at 14:44
  • Why an outdated Eclipse? – howlger May 23 '21 at 18:02

0 Answers0