0

I am trying to get my open source project (JFXtras) running with Java 9 in Eclipse. IntelliJ is working fine, but not a fan.

In JFXtras there is a subproject jfxtras-test-support which contains classes for unit testing. This is not a Java 9 module. The test-support subproject is added correctly to (for example) jfxtras-common in the Eclipse 'Java Build Path' under the Projects tabs as a classpath entry. The other required jars like junit are under the Libraries tabs as classpath entries. Exactly as I would expect.

However, Eclipse is showing errors that it cannot find the JUnit nor the JFXtras test classes. But if I ctrl-click on the import, Eclipse jumps to the correct source file. But starting any of the unit test fail because Eclipse can't find the class file.

tbeernot
  • 2,473
  • 4
  • 24
  • 31
  • The `module-info.java` file is per project, not per source folder. So you have one common module containing the code of `src/main/java/` and `src/test/java/`. But since Oxygen.3, JUnit tests should also work in a modular project (see [Eclipse bug 525948](https://bugs.eclipse.org/bugs/show_bug.cgi?id=525948) and [my video](https://www.youtube.com/watch?v=uJNzMGrbXbI&t=42s)). – howlger May 13 '18 at 12:36
  • I do not quite understand. Each module has a module-info (jfxtras-common, jfxtras-controls, etc), but there is one non module (jfxtras-test-support) which correctly is included in the classpath in each of the jfxtras modules. But, as said, junit classes are not found as well. And it works in IntelliJ. – tbeernot May 13 '18 at 13:15
  • In Eclipse, a Java project has exactly one classpath. For each Java 9/10 module you need a Java project (which is best practice for OSGi bundles or Eclipse plug-ins for years). You can have nested projects. For a [test source folder with a partial different Java build path](https://www.eclipse.org/eclipse/news/4.8/M5/#jdt-test-sources) you have to wait for Eclipse Photon or [use a preview release](http://www.eclipse.org/downloads/index-developer.php). – howlger May 13 '18 at 13:30
  • Yes. From the Gradle build file Eclipse generated separate Java projects for each module. Each with its own Java Build Path. – tbeernot May 14 '18 at 13:08
  • So you have the special case explained in the following answer: [_"There is one special case: ..."_](https://stackoverflow.com/a/50324391/6505250). Does this answer your question? – howlger May 14 '18 at 15:51
  • 1
    It seems like it, yes! I will investigate further. Eclipse Proton... – tbeernot May 14 '18 at 16:46
  • The 4.8M7 version is very barebone, installing either the Gradle or Maven plugin fails because of missing bundles. But it seems Proton will be out in june, so instead of battling the installation I'll wait. – tbeernot May 14 '18 at 19:28
  • 1
    4.8M7 is in the process of being put together. What you get right now is only the "Eclipse SDK", the full simultaneous release version with a lot more plug-ins is due this Friday (May 18). You will find it at https://www.eclipse.org/downloads/index-developer.php - early testing is very much appreciated. – Stephan Herrmann May 14 '18 at 20:51
  • The website still shows the M6 release? – tbeernot May 21 '18 at 06:38
  • I'm now testing with Proton / 4.8M7. This seems to be a big step in the right direction, however there is a difference with Eclipse. Not sure who is right though; one of the modules has units tests that uses classes which are not imported in the module-info (requires javafx.fxml;). The setup without this requires works under IntelliJ and Gradle directly, but Eclipse requires that the dependency is added. I'm not clear why IntelliJ/Gradle do not require that. Test classes are special apparently. – tbeernot Jun 04 '18 at 08:58
  • Also in a Javadoc there is a {@link javax.swing.JInternalFrame} which generates a 'Missing code implementation in the compiler' error. – tbeernot Jun 04 '18 at 09:16
  • And finally: 'The type javafx.util.Callback cannot be resolved. It is indirectly referenced from required .class files DeleteChoiceDialog.java', but adding 'requires javafx.base;' does not solve that. – tbeernot Jun 04 '18 at 09:36
  • Eclipse Photon fixes this issue. Make it an answer and I'll mark it! – tbeernot Jul 29 '18 at 09:58

0 Answers0