Migration tool is used to deploy/retrieve saleforce artifacts stored locally in the machine using command line interface. The documents provides information on prior setup and steps to follow to deploy using command line in windows 10.

Before using command line for deployment we need to setup java jdk, ant file and Install the Migration Tool in your windows 10 machine. So we will describe the steps to be followed for above 3 setups.

Install java jdk :

– Download the java jdk file from In our case we have downloaded ‘jdk-9.0.1_windows-x64_bin.exe’ as the machine is of 64bit

– After downloading double click on the .exe file for installation.

– After installation we need to setup windows environment variables. This can be done by navigating Control Panel -> System -> Advanced System Settings -> Environment variables.

First create a new User variable called ‘JAVA_HOME’ with path pointing to the jdk file installed. In out case it will be,

JAVA_HOME = ‘C:\Program Files\Java\jdk-9.0.1’ i.e, path of jdk file located. Update ‘PATH’ System Variable to point ‘bin’ folder. In our case it will be,

PATH = ‘%JAVA_HOME%\bin’ where %JAVA_HOME% will point to jdk

– To check java has been installed successfully follow below steps. – Open command prompt

– Navigate to bin directory, i.e. cd /d C:\Program Files\Java\jdk-9.0.1\bin

– Type ‘java -version’ and press enter. This will show up the version of the java installed in the machine if successfully installed.

Install apache ant :

– Download the zip file ‘’ from

– Unzip the folder and place it any specific drive in system.

– Note the path to bin folder as we need specify ‘ANT_HOME’ environment variable

– Follow the above mentioned steps to navigate to Environment Variables

– Create a new User Variable ‘ANT_HOME’ to point Ant folder

– In our case it will be ANT_HOME = ‘D:\apache’ , i.e, I have stored unzip file inside ‘apache’ folder of D drive.

– Now ‘Path’ system variable to ‘%ANT_HOME%/bin’

– To verify ant has been installed successfully follow similar steps followed to check java

– Open command prompt and navigate to ant bin directory , i.e. cd /d D:Apache\bin

– Type ‘ant -version’ and press enter. The version of the ant installed will be displayed on successful installation.

Download Migration Tool :

– Download the zip file from

– unzip the folders and copy the ‘ant-salesforce’ file and paste into ant ‘lib’ folder

– This completes all the initial setup need to be done.

Now we will see the steps need to be followed for deployment.

Deployment using ant tool :

– First we need to form the folder structure for the artifacts we need to deploy. For now we will see how we can deploy an apex class.

– Create a folder named ‘Target’ (Can be named as needed). As we are deploying only a single class create a  folder name ‘classes’ inside Target folder.

– Place the apex class file inside the ‘classes’ folder.

– Place package.xml file inside ‘Target’ folder. package.xml file should contain the detail about the class need to deployed. Below is the sample package.xml file containing detail about the artifacts need to be deployed,

Package.xml :

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="">

Make sure the ‘Target’ folder is placed inside the ‘bin’ folder of ant

– Now we need to place ‘build.xml’ and ‘’ file inside the ‘bin’ folder

– properties of file will hold the information credential of the Org to which artifacts need to be deployed.

– build.xml file will contain the data regarding the type of deployment and authentication. :

sf.username =
sf.password = xxxxxxxxttttttttttttttttttttttttt
sf.serverurl =
sf.maxPoll = 20

– sf.username should contain the username of the org.

– sf.password should contain password with 25 digit security token appended to the right ride

– sf.serverurl should contain the login url of either production/sandbox

– sf.maxPoll is optional.


<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
    <property file=""/>
    <property environment="env"/>
    <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
            <pathelement location="../ant-salesforce.jar" />
    <target name="deployUnpackaged">
      <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="Target" rollbackOnError="true"/>

– Make sure ‘deployRoot’ property should hold the value as ‘Target’ which is the folder we created in above steps

– Also note the target name value which is ‘delpoyUnpackaged’ (It can be anything)
– Both of these files should be placed inside ‘bin’ folder

– Open Command prompt and navigate to bin folder i.e, cd \d D:apache\bin

Type ‘ant delpoyUnpackaged’ and press enter (deployUnpackaged is the target name provided in build.xml file)

– Once we press enter the deployment will start and it will show the deployment status.

We can also retrieve, delete , deploy files using this method. Refer for more usage migration tools.