I'm trying to set up appium test headless with java:

public void startAppiumServer() throws IOException, InterruptedException {

//        Process process;
    String APPIUMSERVERSTARTCMD = "cmd /c " + "\"C:/Program Files (x86)/Appium/node.exe\" " +
            "\"C:/Program Files (x86)/Appium/node_modules/appium/bin/Appium.js\" " +
            "--address --chromedriver-port 9516 --bootstrap-port 4725 " +
            "--selendroid-port 8082 --no-reset --local-timezone --log G:/log_appium.txt";

    Runtime rt = Runtime.getRuntime();
    Log.debug("Send command : " + APPIUMSERVERSTARTCMD);
    final Process pr = rt.exec(APPIUMSERVERSTARTCMD);

    new Thread(new Runnable() {
        public void run() {
            BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
            String line = null;

            try {
                while ((line = input.readLine()) != null)
            } catch (IOException e) {


But the appium app did not launch. if i except "cmd /c ", appium will run successfully. But the test just run appium, don't do something else. I want to run my test case after appium launched.

public void initAndroidTest() throws IOException, InterruptedException {

    LaunchAppium launchAppium = new LaunchAppium();

    try {

        AppiumRemote remote = new AppiumRemote(driver);

        driver = remote.remoteDevice();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        homePage = CommonFlow.goToMainPage(driver);

    }catch (Exception ex){


public static AndroidDriver getDriver() { return driver; }

public void runLogin(){
    LoginTester login = new LoginTester();
    login.runTest(driver, homePage);

Please help me to solve this problem. Thanks

closed as off-topic by IAmMilinPatel, Bruce McLeod Jan 20 '16 at 4:22

  • This question does not appear to be about software quality assurance or testing within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I'm voting to close this question as off-topic because it is an Appin support request. Please look to the Appium project for support. – Bruce McLeod Jan 20 '16 at 4:22
public void startAppium()throws Exception
    String command = "appium --session-override -p "+port+" --chromedriver-port "+chromePort+" -bp "+bootstrapPort;

    String output = runCommand(command);

        System.out.println("\nAppium is not installed");

public String runCommand(String command) throws InterruptedException, IOException
    p = Runtime.getRuntime().exec(command);

    BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line="";
    String allLine="";

    while((line=r.readLine()) != null){
        if(line.contains("Console LogLevel: debug"))
    return allLine;

This should start appium server. And if you set appium path in your PATH variable then you don't have to pass full appium path. Just call startAppium() in your test class.

Not the answer you're looking for? Browse other questions tagged or ask your own question.