6

I want to migrate to Java 11 and JFX11 using netbeans. JFX11 must be used as module, so I have added the JavaFX jars and added the following in my module-info.java under the default package folder.

requires javafx.controls;
requires javafx.base;
requires javafx.fxml;
requires javafx.graphics;
requires javafx.swing;

requires java.logging;
requires java.desktop;
requires java.sql;
requires java.xml;

This causes all of my other dependencies to display the following errors when I try a clean and build in netbeans 9.

pacakges 'xyz' is not visible ... (package 'xyz' is declared in the unnamed 
    module, but module 'xyz' does not read it)

Can I not mix modules and libraries? What am I missing?

Gray
  • 115,027
  • 24
  • 293
  • 354
Dodd10x
  • 3,344
  • 1
  • 18
  • 27
  • 1
    "JFX11 must be used as module", is not the case, you can use classpath as well. See this [question](https://stackoverflow.com/questions/51987518/javafx-deployment-library-not-found-in-active-jdk) for both cases – José Pereda Oct 04 '18 at 17:32
  • Adding the module path to the VM arguments worked. If you add that as an answer I'll accept it. – Dodd10x Oct 04 '18 at 19:09
  • Did you end up doing a module or just classpath? – José Pereda Oct 04 '18 at 19:19
  • I added the JavaFX jars as libraries which allowed the build to compile. Then I added "java --module-path PATH_TO_FX --add-modules=javafx.controls" to the VM arguments section in netbeans which let the build actually execute. – Dodd10x Oct 04 '18 at 19:47
  • @nullpointer I don't think this is a duplicate question. This question is, "Can I not mix modules and libraries?", with specific reference to the error message in the title (which is how I got here). The other question that this is marked a duplicate of does not address that issue. – swpalmer Dec 15 '18 at 15:53
  • @swpalmer the linked question suggests exactly how a modular application needs the dependencies to be on the `modulepath` and not `classpath`. – Naman Dec 15 '18 at 16:29
  • @nullpointer Sure, but that doesn't solve the problem with this error message. The error message itself is very confusing, How can a module not read itself? I encountered this in a different context and have yet to figure it out. The module system is currently a big mess IMO. From what I can tell, the modules removed in JDK 11 cannot be added as modules to a new runtime using jlink because the replacement projects are not yet fully modularized. I got this error trying to use a non-modular jar in my project on the classpath. – swpalmer Dec 16 '18 at 20:54
  • @swpalmer *How can a module not read itself?* .... `xyz` in the question is both the name of a ***package** which is not read by a **module*** at the same time. To what you're pointing out further is possibly using automatic modules with `jlink` which is true. But not sure about your exact use case without prior knowledge over it. – Naman Dec 17 '18 at 01:16
  • @nullpointer I guess the big mystery is where did module X come from, given that package X is in a non-modular Jar that is only on the classpath. It has no module-info or automatic module name in the manifest. I guess you can't have a modular app that uses the unnamed module from the classpath, but this is a strange error message. – swpalmer Dec 17 '18 at 03:22
  • @swpalmer Agreed, the mystery would remain unless the question is clear enough and has further details. But there definitely must have been a module that's present on the modulepath is what I could infer certainly. – Naman Dec 17 '18 at 03:24

0 Answers0