Start/Stop Appium Server from Java


I am new to Appium and trying to run few sample test cases using Java + WebDriver + TestNG. Here is what I am doing

  • Start AVD using CMD commands >

    builder = new ProcessBuilder(“cmd.exe”, “/c”, “C: && cd "” + AndroidSDKPath + “\tools" && emulator -avd " + AVDName + " && adb wait-for-device”);
    p = builder.start();

  • Start Appium Server using CMD command

    String nodeModulesPath = “C:\Program Files (x86)\Appium\node_modules”;
    ProcessBuilder builder = new ProcessBuilder(“cmd.exe”, “/c”, “C: && cd "” + nodePath + “" && node appium”);
    Process p = builder.start();

  • Run TestNG test to get sum of two numbers on Calculator Application

Here are the problems I am facing

  1. How can I start the Appium server at 2nd step with parameter? like Server Address, Port, Android SDK Path etc… which are available in Desktop application of Appium Server as shown below.

  2. For now, I am starting the server as mentioned above but getting below error while executing test.

    org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{,, browserName=Android, platformName=Android, deviceName=Nexus_5_API_23, version=6.0}], required capabilities = Capabilities [{}]
    Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
    System info: host: ‘HITEKSHA’, ip: ‘’, ‘Windows 8.1’, os.arch: ‘amd64’, os.version: ‘6.3’, java.version: ‘1.8.0_144’
    Driver info: driver.version: RemoteWebDriver

  3. How to stop Appium Server other than running CMD command “CTRL + C”?

Note: Everything works fine if I start Appium Server from Desktop app of Appium.

Can anyone please help on these issues?

Chandresh Parmar


Chandresh Parmar