How to use javac to replace deprecated wsgen or apt in JDK 7 or 6?

9.4k views Asked by At

When I use wsgen or apt to generate web service artifacts in JDK 7 with command.

wsgen -s src -cp CLASS_PATH -d OUTPUT_DIRECTORY  com.sun.WebServiceSEI

displays following warning message

The apt tool and its associated API contained in the package com.sun.mirror have been deprecated since JDK 7 and are planned to be removed in the next major JDK release. Use the options available in the javac tool and the APIs contained in the packages javax.annotation.processing and javax.lang.model to process annotations.

How can I generate web service artifacts without using wsgen or apt to remove this warning?

3

There are 3 answers

4
dma_k On BEST ANSWER

The warning is generated because WsgenTool class is using classes from com.sun.mirror.apt package, which seem to be deprecated in JDK7. I think in a while JAX-WS team will release jaxws-ri which does not use this API, but it may happen somewhere closer to JDK8 release.

0
bazuka On

Im afraid, it is not possible. What you can do is switch back to old JDK which was working for you, that is your best bet.

0
Chase On

javac is the replacement. They added a pluggable annotation processing system into javac (JSR 269: Pluggable Annotation Processing API) a while back (Java 6 I think). The annotation processor you are looking for is in jaxws-tools.jar (Metro download). Once you have that jar on your classpath you should be able to run javac with a -processor com.sun.tools.ws.processor.modeler.annotation.WebServiceAp option. There is also a Ant task, com.sun.tools.ws.ant.AnnotationProcessingTask. They talk about it a little here http://jax-ws.java.net/nonav/2.2.6/docs/ch04.html#tools-annotation-processing but don't really explain it. Maybe the required annotation processor ships with the JDK but if so I couldn't find it.