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

Baha picture Baha · Feb 5, 2012 · Viewed 8.7k times · Source

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?

Answer

Chase picture Chase · Mar 24, 2013

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.