How To Generate Java Stub Jar from Salesforce WSDL?
If you are looking to build java applications using salesforce data. Salesforce being an API first platform, provides several APIs for integration purposes. In this article we will be covering how to generate Java stub jar from Salesforce WSDL using Salesforce webservice connector library.
Install the Java Developer Kit (JDK)
Java JDK is a pre-requisite to use Salesforce APIs in our Java application. You need to first install the Java Developer Kit (JDK) at version 11.0 or later. You can do that by visiting Oracle java downloads. If you have already installed Java on your machine, you can verify the same by running following command in your command line :
java -version
if you get a response stating java version it means Java JDK is installed.
Download WSC pre-built .jar files
You would need Salesforce webservice connector jar file to work with java. You can download the latest from the Maven repository which shows all of the versions available.
Navigate to the page for the version that matches the API version of Salesforce that you’re using. Please make sure you download the api version files which you are going to use. In our example, we’ll use 58.0.0.

Under Files, click on View All. It will take you to the actual .jar
files.

Download the following four files to your local machine:
force-wsc-58.0.0-javadoc.jar
force-wsc-58.0.0-sources.jar
force-wsc-58.0.0-uber.jar
force-wsc-58.0.0.jar
We will use these files to generate stub files with the WSDLs from our Salesforce org.
Download the WSDL for Your Salesforce Org
You need to generate a WSDL to generate java .jar stub files. Please refer ‘Choose WSDL‘ to decide which wsdl would be suitable for your usecase. We are using to Enterprise WSDL in this article. Please follow following steps to download the same:
- Log into your Salesforce developer organization.
- Navigate to setup and search for ‘API’ in the quick find or you can navigate to Platform Tools >Integrations>API for the same.
- Click on “Generate Enterprise WSDL.

- It will open WSDL file in a new tab.
- Save this file to your local machine with the name
enterprise.wsdl
. Put it in the same folder where you downloaded the WSC .jar files.
Generate Java stub file
To use the SOAP API with Java, we need to generate .jar stub files for our application project. We run the following command to generate the stub file:
- Open your command line. Change your directory to the folder where you have stored enterprise.wsdl and wsc jars.
- Run following command where enterprise_stub.jar is the name of your output Java stub jar file.
$ java -classpath force-wsc-58.0.0-uber.jar com.sforce.ws.tools.wsdlc enterprise.wsdl enterprise_stub.jar
You will be able to see ‘enterprise_stub.jar’ created.
Leave a Reply