javatools/javacontrolpanel/controlpanel/src/javacaptain.cpp
branchRCL_3
changeset 24 6c158198356e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javatools/javacontrolpanel/controlpanel/src/javacaptain.cpp	Thu Aug 19 09:48:13 2010 +0300
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  JavaCaptain
+*
+*/
+
+
+#include "com_nokia_mj_impl_javacontrolpanel_JavaCaptain.h"
+
+#ifdef __SYMBIAN32__
+#include <spawn.h>
+#else
+#include <stdio.h>
+#endif
+
+#include <cstring>
+#include <errno.h>
+#include "logger.h"
+
+/*
+ * Class:     com_nokia_mj_impl_javacontrolpanel_JavaCaptain
+ * Method:    _start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_nokia_mj_impl_javacontrolpanel_JavaCaptain__1start
+  (JNIEnv *, jobject)
+{
+    int rc = 0;
+    int pid = 0;
+    char* av[2];
+    int index = 0;
+    av[index++] = "javacaptain";
+    av[index] = NULL;
+
+#ifdef __SYMBIAN32__
+    rc = posix_spawn(&pid, "javacaptain", NULL, NULL, av, NULL);
+#else
+    if (!(pid = fork()))
+    {
+        rc = execvp("javacaptain", av);
+        if (rc == -1)
+        {
+            rc = errno;
+        }
+    }
+#endif // __SYMBIAN32__
+
+    if (rc)
+    {
+        ELOG3(EUtils,"%s failed, %s - errno=%d", __PRETTY_FUNCTION__, strerror(rc), rc);
+    }
+
+}
+