Appium 1.6.3 invoking app on ios when started by Terminal command. But getting error from Java code

When I start Appium server manually from terminal the app is getting invoked.

But when I start appium from Java code the app is not invoked and I get the following error-

[Appium] Welcome to Appium v1.6.3
[Appium] Non-default server args:
[Appium] address: ‘127.0.0.1’
[Appium] sessionOverride: true
[Appium] fullReset: true
[Appium] Deprecated server args:
[Appium] --full-reset => --default-capabilities ‘{“fullReset”:true}’
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium] fullReset: true
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
Appium server started.
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“automationName”:“XCUITest”,“app”:"/Users/lntinfotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app",“deviceName”:“iOS”,“platformName”:“iOS”,“udid”:“dea1eeecfba536a2a929ba1b11f7825b1da8c4f4”}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{“automationName”:“XCUITest”,“app”:"/Users/lntinfotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app",“deviceName”:“iOS”,“platformName”:“iOS”,“udid”:“dea1eeecfba536a2a929ba1b11f7825b1da8c4f4”},null,null,null,null]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1490335647669 (11:37:27 GMT+0530 (IST))
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] automationName: ‘XCUITest’
[Appium] app: ‘/Users/lntinfotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app’
[Appium] deviceName: ‘iOS’
[Appium] platformName: ‘iOS’
[Appium] udid: ‘dea1eeecfba536a2a929ba1b11f7825b1da8c4f4’
[Appium] fullReset: true
[debug] [XCUITest] XCUITestDriver version: 2.23.1
[BaseDriver] Session created with session id: 2bed7df4-e796-4928-abc7-eb0b614a846c
[debug] [XCUITest] Xcode version set to ‘8.2.1’ (tools v8.2.0.0.1.1480973914)
[debug] [XCUITest] iOS SDK Version set to ‘10.2’
[debug] [BaseDriver] Event ‘xcodeDetailsRetrieved’ logged at 1490335647804 (11:37:27 GMT+0530 (IST))
[XCUITest] The ‘idevice_id’ program is not installed. If you are running a real device test it is necessary. Install with ‘brew install libimobiledevice --HEAD’
[debug] [XCUITest] Available devices:
[XCUITest] Error: Unknown device or simulator UDID: ‘dea1eeecfba536a2a929ba1b11f7825b1da8c4f4’
at XCUITestDriver.determineDevice$ (…/…/lib/driver.js:577:17)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at run (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:108:47)
at /usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:119:28
at flush (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.microtask.js:19:5)
at combinedTickCallback (internal/process/nexttick.js:67:7)
at process.tickCallback (internal/process/nexttick.js:98:9)
[Error: Unknown device or simulator UDID: ‘dea1eeecfba536a2a929ba1b11f7825b1da8c4f4’]
[MJSONWP] Encountered internal error running command: Error: Unknown device or simulator UDID: ‘dea1eeecfba536a2a929ba1b11f7825b1da8c4f4’
at XCUITestDriver.determineDevice$ (…/…/lib/driver.js:577:17)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at run (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:108:47)
at /usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:119:28
at flush (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.microtask.js:19:5)
at combinedTickCallback (internal/process/nexttick.js:67:7)
at process.tickCallback (internal/process/nexttick.js:98:9)
[HTTP] <-- POST /wd/hub/session 500 257 ms - 213
Exception in thread “main” org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unknown device or simulator UDID: ‘dea1eeecfba536a2a929ba1b11f7825b1da8c4f4’ (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 430 milliseconds
Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:30’
System info: host: ‘Lntinfitechs-mac-mini.local’, ip: ‘192.168.2.1’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.3’, java.version: ‘1.7.0_65’
Driver info: io.appium.java_client.ios.IOSDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:176)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:107)
at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:23)
at IOSWebTest.main(IOSWebTest.java:100)

My Java Code is as follows-

CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
			
			command.addArgument("/usr/local/lib/node_modules/appium/build/lib/main.js",false);

			command.addArgument("--address", false);
			command.addArgument("127.0.0.1");
			command.addArgument("--port", false);
			command.addArgument("4723");

		
			command.addArgument("--session-override", true);
			//command.addArgument("--no-reset", true);
			DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
			DefaultExecutor executor = new DefaultExecutor();
			executor.setExitValue(1);
			try {executor.execute(command, resultHandler);
			Thread.sleep(5000);System.out.println("Appium server started.");}
			catch (IOException e) 
			{e.printStackTrace();}
			catch (InterruptedException e) 
			{e.printStackTrace();}
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
			DesiredCapabilities capabilities = new DesiredCapabilities();
			capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"iOS");
			capabilities.setCapability("udid","dea1eeecfba536a2a929ba1b11f7825b1da8c4f4");
			
			capabilities.setCapability("app","/Users/lntinfotech/Desktop/SafariLauncherAfterUpdate/SafariLauncher.app");
			capabilities.setCapability("automationName","XCUITest");
		
			

			driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);	
			
			try {
				Thread.sleep(20000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			driver.get("http://www.google.com");	
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

you need to add valid device UDID, looking closely at appium logs will give you info about what’s wrong

Also please use latest appium java client version and server version; as both has got lots of fixes.

@VikramVI The same java script is running properly when I start Appium manually from Terminal.
Do you mean I should use Latest Java APIs for appium? And if you observe the error in Java, it is not showing any device in the available devices.