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:
This is a result of the new Java 9 modules. The javax.xml.soap
package is actually a Java EE package, and so now isn't visible. The current workaround is to either use the --add-modules
, as you've done, or to modularize your code.
Modularizing your code requires restructuring it into modules, and including a module-info.java
file that specifies the modules you're using. In your case, specifying java.se.ee
would give access to all the EE modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With