Symbian
Symbian OS Library

FAQ-0269 How do I launch a native application from Java?

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: General
Created: 08/26/99 Modified: 06/22/2001
Number: FAQ-0269
Platform: ER5

Question:
I have tried using

Runtime.getRuntime().exec("z:\\System\\Programs\\RunApp.exe z:\\System\\Apps\\Data\\Data.app")

to launch the data app from within Java on an ER5 EPOC machine. But it fails with error message:

Program closed
==============
Program Main
Reason code EIKON
Reason number 2

What is going wrong?


Answer:
This is a known defect arising under ER5 when Runapp.exe is called in this way.
The error message is EEikPanicNoLibraryOnCommandLine and arises because the command line is being incorrectly parsed by the function popen3() which is called from STDLIB. RunApp.exe is correctly identified as the executable but the arguments passed to ConstructAppFromCommandLineL() are passed with a leading space. AppArc is then unable to recognize the argument passed to it as an app (which is a type of dll, hence the "NoLibrary").

This defect of Runtime.exec()is likely to affect any command line wherein an executable is passed arguments. It has been fixed for v6 of the symbian OS.

Under ER5, a work around is possible with the use of JNI code. For example, an EPOC app can be launched using RApaLsSession.StartApp() as described in the C++ Knowledge Base under "How do I launch another app from within a C++ program?". Note however, that this code, when run under JNI, needs to be launched from inside a TRAP macro. For details consult the C++ Symbian Developer Library.