So I took the SOAP example at Working Soap client example , put it into a file SOAPClientSAAJ.java
, and tried compiling it (Openjdk 9 on Debian):
t@h ~/javatest> javac SOAPClientSAAJ.java
SOAPClientSAAJ.java:1: error: package javax.xml.soap is not visible
import javax.xml.soap.*;
^
(package javax.xml.soap is declared in module java.xml.ws, which is not in the module graph)
1 error
After Googling some, I found out that compiling and running as
t@h ~/javatest> javac --add-modules java.xml.ws SOAPClientSAAJ.java
t@h ~/javatest> java --add-modules java.xml.ws SOAPClientSAAJ
works. See also this video for general background: https://www.youtube.com/watch?v=y8bpKYDrF5I&t=20m17s
Now, questions:
- Shouldn't the compiler automatically add the module java.xml.ws ? (since it obviously knows it is needed) Is this a bug in javax.xml.soap ?
- Why is the --add-modules option not documented in my man pages? (openjdk 9 in Debian)
- What should I write in the .java file to automatically add the java.xml.ws module?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…