Java 9 can't compile - com.sun.* package access hell
Hi,
I'm trying a lot of things here, (and I'll add more information if needed) but how can I get IDEA to recognize (and compile) java code that need to use non-opened com.sun.javafx packages ?
This is a maven project, using jdk 9, and I have a module-info.java
import com.sun.javafx.scene.control.behavior.ComboBoxBaseBehavior;
I guess I need to do something like this:
--add-exports javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-exports javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED
Which I tried to put in the compiler's option in IDEA settings, and I also have those in my pom.xml
But nothing works, all I get is :
package com.sun.javafx.scene.control.behavior is not visible
(package com.sun.javafx.scene.control.behavior is declared in module javafx.controls, which does not export it to module xxx.xxx)
I can't find any *working* information on how to deal with this. The IDE doesn't help me at all, and show me source code that doesn't recognize the import from that package.
What are the steps needed (module-info, maven compile options in pom.xml, etc ?) to have code that
would compile ? is it possible ?
请先登录再写评论。
ok, I now successfully compiled (maven) that code, exporting the com.sun.javafx packages to my NAMED module and not ALL-UNNAMED.
But intellij still show an error in that source file. Why does intellij doesn't detect the add-exports in the pom.xml file and
know that the packages can be accessed ?
Please report at https://youtrack.jetbrains.com/issues/IDEA with the sample project. Probably IntelliJ IDEA doesn't recognize the way you specify the options in pom.xml yet and there needs to be special handling added.
I'm facing the same issue I can't find the relevant solution.
When I'm building my package outside it is perfectly fine but building inside the ide I'm getting Java:package sun.misc doesn't exist
Rameshhawking could you please share a small sample project to reproduce this issue? Do you use the same JDK version for your Maven command line and IntelliJ IDEA builds?