package javax.jnlp is declared in module java.jnlp, which is not in the module graph

不羁岁月 提交于 2019-12-19 06:01:42

问题


I have a project that uses Java webstart technology. I decided to upgrade the Java version from 8 to 9. However, I faced the following error on compiling:

error: package javax.jnlp is not visible
import javax.jnlp.DownloadServiceListener;
        ^
(package javax.jnlp is declared in module java.jnlp, which is not in the module graph)

I tried to include C:\Program Files\Java\jdk-9\lib\javaws.jar to the classpath, but still the same issue remains.


回答1:


It looks like java.jnlp is not resolved by default for code on the class path (much like Java EE modules). The solution is to add it explicitly with --add-modules java.jnlp (both javac and java accepts that parameter).

This option is discussed in JEP 261: Module System or in this blog post.




回答2:


In IntelliJ IDEA: Add javaws.jar to Classpath(File -> Project Structure -> SDKs ->Class) C:\Program Files\Java\jdk-version\lib\javaws.jar



来源:https://stackoverflow.com/questions/45419935/package-javax-jnlp-is-declared-in-module-java-jnlp-which-is-not-in-the-module-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!