As I understood from the image you shared, you are starting a new JVM inside the original one. That's why when you call the destroy function, the Java process and all of its child processes are destroyed. In my case, I was starting the Appium server from the original JVM which means that all of its spawned processes won't be destroyed until the original Java JVM terminates.
P.S: I am running more than one server instance simultaneously and I can't wait to clear up memory at the end when the JVM terminates.
Hi Everyone,
When I tried to launch the server, I am geeting this below error:
" /Applications/Appium.app/Contents/Resources/node/bin/node: cannot execute binary file "
My code is this, Can anyone please help on this ?
CommandLine command = new CommandLine("/bin/sh");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
command.addArgument("--address");
command.addArgument("127.0.0.1");
command.addArgument("--port");
command.addArgument("4723");
command.addArgument("--no-reset");
command.addArgument("--log");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
Thanks in advance.
@Hassan_Radi : Still getting the same error.
I am using Appium version : 1.3.1 (Ophiuchus)
below is my entire code-
public static void main(String[] args) throws ExecuteException, IOException {
CommandLine command = new CommandLine("/bin/sh");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
command.addArgument("--address");
command.addArgument("127.0.0.1");
command.addArgument("--port");
command.addArgument("4723");
command.addArgument("--no-reset");
command.addArgument("--log");
command.addArgument("argument", false);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
}
I saw this line in your post,
"command.addArgument("/c");"
what does it do exactly ?
@Hassan_Radi: LOL !!
But still getting the same error, do you think its because of any device incompatibility ?
Because all I get in searching internet about this is 32-bit vs 64-bit issues only.
OS X : Version 10.8.5
Appium version : 1.3.1 (Ophiuchus)
I am running below code pn my mac no error but appium is not started as well.
Where as if i involve from terminal this command : /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js --address 127.0.0.1 --port 4723 --no-reset --local-timezone
code::
CommandLine command = new CommandLine("/bin/sh -c");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node",false);
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js",false);
command.addArgument("--address",false);
command.addArgument("127.0.0.1");
command.addArgument("--port",false);
command.addArgument("4723");
command.addArgument("--no-reset",false);
command.addArgument("--log");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {
executor.execute(command, resultHandler);
} catch (ExecuteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I guess I missed "-c" while invoking CommandLine. Its not showing the error, but like @Sachin_Chauhan on running the code nothing is happening.
I left the hope with command line. Now I am using process builder and its working ok.
List list = new ArrayList();
list.add("/Applications/Appium.app/Contents/Resources/node/bin/node");
list.add("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js");
list.add("--address");
list.add("127.0.0.1");
list.add("--port");
list.add("4723");
list.add("--no-reset");
// create the process builder
ProcessBuilder pb = new ProcessBuilder(list);
try {
pb.start();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
I just tried with CommandLine and it worked after I changed:
CommandLine command = new CommandLine("/bin/sh -c");
command.addArgument("/Applications/Appium.app/Contents/Resources/node/bin/node",false);
to be:
CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
I am not sure what has changed since the last time, but it's working now without invoking the shell app.
Give it a try and let me know how it works.
@BeforeMethod
public void setUp() throws Exception {
Runtime.getRuntime().exec("/bin/bash export ANDROID_HOME=$HOME/Downloads/adt-bundle-mac-x86_64/sdk/");
CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js", false);
command.addArgument("--address", false);
command.addArgument("127.0.0.1");
command.addArgument("--port", false);
command.addArgument("4723");
command.addArgument("--no-reset", false);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "7.1");
capabilities.setCapability("deviceName", "iPhone 6 Plus");
capabilities.setCapability("app", "/Users/Prithivi/Documents/Sample.app");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.name("Continue")).click();
This works for me very well...
Note: I used java-client-1.3.0.jar, in latest version AppiumDriver was changed into interface.