How to start the Appium server in iOS Machine automatically through Java Code

I need to automate the appium server via Java code in Mac machine.

In windows I have used the following code.

public void startAppiumServer() throws IOException, InterruptedException {

    CommandLine command = new CommandLine("cmd");
    command.addArgument("--address", false);  
    command.addArgument("--port", false);  
    command.addArgument("--full-reset", false);  

    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();  
    DefaultExecutor executor = new DefaultExecutor();  
    executor.execute(command, resultHandler);

public static void startApplication() throws Exception{

	System.out.println("application has started...................");

	System.out.println("Into iOS");
	DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");	
	driver = new RemoteWebDriver(new URL(""), capabilities); 
	System.out.println("Appium SetUp for Android is successful and Appium Driver is launched successfully");

public static void main(String as[]) throws Exception
    try{Thread.sleep(5000);}catch(Exception e){}
    System.out.println("Stopping Server");
    System.out.println("Server Stopped");


How it could be done for MAC machine

@Hassan_Radi Can you give your suggestions please

I’m using two shell scripts to start and stop server after each test.
There must be better way to do that at least I could get things done )

Here is the gist:
I’m not a shell script expert so feel free to :smile:

@ashokkumarg @Aki
I developed a Java library as a support library for Appium, you can find details on how to use it to start/stop the server here.

Please tell me if you encounter any issues.

Hope it helps.

I don’t see this post available, can you please resent the post.

Looks like there is some problem in the link, the link is getting redirected to “5 Things Great Managers Do Every Day
and it says sorry this post is not available

Yes it is re-directed to the wrong page. :confused:

In Google, search like Appium support library Hasan radi. You will get it

It is working fine from my end… not sure why it is redirecting to another page from your side !!!

@Hassan_Radi I’m getting an error like Browser start up failure or Invalid remote server address
In windows I have used the above code which was in the description:

@0x1mason suggestions please