How to add non-modular JARs with split packages to a modular JavaFX project in Intellij idea?

34 Views Asked by At

My project uses Mapsforge library for displaying maps, and JavaFX for GUI.
There is a way to compile JavaFX with javafx-maven-plugin and stay in the unmodular paradigm, but it seems against the best practices. The problem is that mapsforge has split packages: org.mapsforge.map.rendertheme is accessible from both mapsforge.map, mapsforge.themes modules which makes it impossible to require both of them in module-info:

java: java.lang.reflect.InvocationTargetException
Modules mapsforge.map and mapsforge.themes export package org.mapsforge.map.rendertheme to module org.postgresql.jdbc

After reading answers to similar questions, I realized that you can add libraries as JARs to the classpath but not as module dependencies. The question is - how you do it correctly in Intellij?

I put three mapsforge jars to ROOT/lib folder, and added all of them as project libraries. I also tried Modules -> Dependencies -> Add Jars or Libraries.

The problem is that I still can't reference classes in those jars:

java: package org.mapsforge.core.graphics is not visible (package org.mapsforge.core.graphics is declared in the unnamed module, but module rfinder does not read it)

How can I make the unnamed module with external jars visible to rfinder?

PS: I use maven, and maven-oriented solution would be the best, but I don't know the way to add maven packages to classpath

0

There are 0 best solutions below