Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force Java 8 wsimport command-line to generate 1.6 target compatible code

I'm trying to upgrade an existing build system to use Java 8 instead of a Java 5/6 compiler, however, I still have to generate outputs compatible with Java 5/6. Overall this is trivial (-target 1.6), but I am having difficulty doing so with code generated from wsimport (using the version in JDK 8 bin).

I'm using Java HotSpot 64-bit server VM (build 25.20-b23), JDK 1.8.0_20.

The wsimport command is being called from a command-line to generate code and the outputs packaged directly from there. For legacy reasons I am unable to change this process (such as to use ant), so I need to solve the problem from the command-line.

What I run is: "wsimport WSDL_FILE" (actual file doesn't matter) then run "javap -verbose CLASS | grep major" on any of the classes in the output to check the version: it always comes out 52.

I've tried using -J argument to wsimport to pass options to the javac compiler, however none of the below have worked:

wsimport "-J-target 1.6" WSDL  (fails with unrecognized option -target 1.6" coming from wsimport)
wsimport "-J-Djavac.target=1.6" WSDL  (no effect)
wsimport "-J-Djavac.opt.target=1.6" WSDL (no effect)

Presumably there's either some variation on passing the target through that works or some property settings that should work; if it's one I'm using, then I haven't figured out how to pass it correctly.

like image 938
user1676075 Avatar asked Oct 23 '14 16:10

user1676075


People also ask

How use Wsimport command line?

To run the wsimport , go to the root directory of web services client project and use command prompt. -s -s defines the directory for source files. And pass the wsdl URL of web services end point. The below classes will be generated for web service client for the given WSDL URL.

How wsimport works?

The wsimport tool reads an existing WSDL file and generates the following artifacts: Service Endpoint Interface (SEI) - The SEI is the annotated Java representation of the WSDL file for the web service. This interface is used for implementing JavaBeans endpoints or creating dynamic proxy client instances. javax.

What is Wsimport explain different options of it?

Description. The wsimport command generates the following JAX-WS portable artifacts. These artifacts can be packaged in a WAR file with the Web Services Description Language (WSDL) file and schema documents and the endpoint implementation to be deployed. The wsimport command also provides a wsimport Ant task.


1 Answers

Assuming that wsimport creates Java 6 compatible source code, no reason it shouldn't, but who knows, then the solution is to simply add -Xnocompile to wsimport, and then build the source directly yourself, using whatever mechanism is comfortable for your process.

like image 88
Will Hartung Avatar answered Sep 28 '22 05:09

Will Hartung