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

2

9

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.

Smuggle answered 31/7, 2017 at 15:33 Comment(3)
Did you add requires javaws; to your module-info.java? If so could you add the build version and your module-info.java file please.Colchicum
@nullpointer I was not using module-info.java at all. All other packages were included by default except javaws. I think the reason behind this is what @Nicolai explained in his answer. Anyway, the problem has been resolved by using modules. ThanksSmuggle
Similar: “package javax.xml.soap is declared in module java.xml.ws, which is not in the module graph”Scrip
S
10

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.

Soteriology answered 31/7, 2017 at 17:21 Comment(2)
Nicolai is correct, more details in "Root modules" section of JEP 261. The original question also mentioned lib/javaws.jar - that JAR file is used when JDK 8 or older releases use the deploy bits in JDK 9, it's not intended to be used on the class path.Konyn
--add-modules xxxx is not a solution, it is a workaround.Diluent
C
0

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

Cordierite answered 19/3, 2018 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.