Symbian程序如何安装jar,并启动java程序参考资料

本文档汇总了Nokia论坛的技术资源,详细介绍如何在Symbian手机上安装和启动Java应用程序(jar文件)。通过OpenFileEmbeddedL函数和RApaLsSession调用midp2.exe实现安装,以及利用kmidrun.exe和S60 3rd Edition的API启动MIDlets。同时,提供UIQ和S60平台上的示例代码,演示了查找并启动Java程序的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Nokia论坛技术资料Symbian解决方案-中文版:

http://discussion.forum.nokia.com/forum/showthread.php?t=60202&highlight=RApaLsSession

 

可参考帖子如下:

http://discussion.forum.nokia.com/forum/showthread.php?t=98014

http://discussion.forum.nokia.com/forum/showthread.php?t=87919

http://discussion.forum.nokia.com/forum/showthread.php?t=73399

 

http://discussion.forum.nokia.com/forum/showthread.php?t=16862&highlight=kmidrun

To see how DocumentHandler works - check FileList example application or the SDK help.

 

TSS000465 - Launching MIDlets programmatically on S60 3rd Edition

http://wiki.forum.nokia.com/index.php/TSS000465_-_Launching_MIDlets_programmatically_on_S60_3rd_Edition

http://discussion.forum.nokia.com/forum/showthread.php?t=116102
 http://wiki.forum.nokia.com/index.php/Launching_a_midlet_from_symbian_C++_code

 

稍微总结一下:

1.安装:

OpenFileEmbeddedL函数

 

通过 RApaLsSession 调用 midp2.exe程序,然后达到给一系列的参数调用目标jar文件
jar 程序是通过midp2线程调用的,在真机上的调用格式是:
midp2.exe -jar "c:/system/midlets/[***]/**.jar -msid 2 -msin 1 -mid1
在3.0机器上就是midp2.exe -jar /private/102033E6/MIDlets/[***]/**.jar -msid 2 -msin 1 -mid1 是么?

是的,所有的jar程序也就是java都是用kvm调用的,当它运行时,你会看到midp2被载入了内存。

 

 

kmidrun.exe方法调用java程序是针对S60 1st来说的,而在S60 2nd中就要使用新的方法,因为在第二版中,java都是做为一个独立程序来安装的,安装后的路径就在/system/apps中,而它的app名就是一个UID数字,如[101aaebb].app,而你需要做的就是通过调用app程序的方法去调用它,这样就能启动这个java程序了。

具体调用app程序的方法,请参考:
#include <EikDll.h>
#include <apacmdln.h>
...
_LIT(KMyAppName, "c://system//Apps//MyApp//MyApp.app");
_LIT(KMyDocName, "c://Documents//MyApp.dat");

CApaCommandLine * cmd=CApaCommandLine::NewL();
cmd->SetLibraryNameL(KMyAppName);
cmd->SetDocumentNameL(KMyDocName);
cmd->SetCommandL(EApaCommandRun);
EikDll::StartAppL(*cmd);

 

OK,解决了.之前不行是因为我用EikDll::StartAppL(*cmd);
改成
RApaLsSession ras;
.
.
.
ras.StartApp( *cmd );
就可以了.谢谢各位了

 

http://discussion.forum.nokia.com/forum/showthread.php?t=16862&highlight=kmidrun

Here's how I do it in UIQ, should be the same for S60:


---------------------------------
RApaLsSession appSession;

if( appSession.Connect() == KErrNone &&
appSession.GetAllApps() == KErrNone ){
TApaAppInfo appInfo;
TInt result = KErrNone;
TInt handeled = 0;
TInt count = 0;
TBuf<256> appPath( _L("") );
TBuf<64> appName;

// Find the path to the midlets app file, that gets created
// when the midlet is installed
while( result != RApaLsSession::ENoMoreAppsInList ){
if( result == KErrNone )
result = appSession.GetNextApp( appInfo );

// GetNextApp ocasionally fails, hence the use of
// handeled and count.
if( result == KErrNone && count == handeled ){
handeled++;
count++;
appName.Copy( appInfo.iCaption );
if( appName.Compare( _L("<Midlet app name") ) == 0 ){
// Found the app we we're looking for.
appPath.Copy( appInfo.iFullName );
result = RApaLsSession::ENoMoreAppsInList;
}
}
else if( result == RApaLsSession::EAppListInvalid ){
// Something failed, so the session is restarted.
count = 0;
appSession.Close();
if( appSession.Connect() == KErrNone &&
appSession.GetAllApps() == KErrNone )
result = KErrNone;
}
}
CApaCommandLine * cmd=CApaCommandLine::NewL();
cmd->SetLibraryNameL( appPath );
cmd->SetCommandL(EApaCommandRun);
// Start the midlet
if( appSession.StartApp(*cmd) == KErrNotFound )
ShowErrorDialog( _L("MIDLET not found") );
}
else{
ShowErrorDialog( _L("Failed to search for MIDLET") );
}
appSession.Close();

-----------------------------------------------------------------------------

 

 

Our application after downloading the JAD file will save it to the local folder and passes it for the Midlet installation using CdocumentHandler. This works fine when the JAD file contains the full path for the JAR.

 

/*

Here is a simple example code for executable (.exe) application that launches a
midlet and exits. This is done by starting a new process for virtual machine.
The information about the midlet to be launched is passed to the VM as a command
line parameter which has a specific format.

The command line consists of tcp/ip port reserved for the midlet, a midlet uid,
midlet name, and the location (drive,path and name) of midlet jar and jad files.
These are separated by asterisks ('*'). If the jad/jar contains more than one
midlets, the one to be launched is determined by the midlet name parameter.

In this example, the launched midlet (Helloworld) files are located in
c://system//apps//MidLaunch//

NOTES:

- This is NOT a recommended way to launch midlets from native applications,
but currently the only way.

- The example code here works only in the target device, NOT in the emulator.


The main problems with this method are:

- A new instance of virtual machine is started for each midlet. Normally, the
MidpUI application uses the same KVM instance for all midlets from the same
midlet suite.

- The port used for midlet is hardcoded. Normally, the launching application
(MidpUI) runs a search to find a free port.

- This example does not rename the launched process according to convention
used in Midp environment. This may cause problems if other midlets are
launched via MidpUI at the same time.

- Using hardcoded values for KVM location and command line syntax will
probably fail if/when there are changes to the platform.
*/

//------------------------------------------------------------------------------
// A simple example (.exe) launching a midlet (Helloworld) from C++ code

#include <e32base.h>
#include <e32std.h>

const TInt KMaxCommandLine = 1024;
const TInt KMidletPort = 7049;
const TInt KMidletUidValue = 0x100009c4;
const TUid KMidletUid = {KMidletUidValue};

LOCAL_C void doLaunchL();

// midlet name
_LIT(KMidletName, "HelloWorld");

// KVM virtual machine location on ROM drive
_LIT(KMidRunROMLocation, "z://system//programs//kmidrun.exe");

// location of jad + jar
_LIT(KMidletJadLocation, "c://system//apps//MidLaunch//HelloWorld.jad");
_LIT(KMidletJarLocation, "c://system//apps//MidLaunch//HelloWorld.jar");


// main function called by E32
GLDEF_C TInt E32Main()
{
_LIT(KE32Main, "KE32Main");

__UHEAP_MARK;
CTrapCleanup* cleanup=CTrapCleanup::New(); // get a clean-up stack
TRAPD(error,doLaunchL());

__ASSERT_ALWAYS(!error,User::Panic(KE32Main,error));
delete cleanup; // destroy cleanup stack
__UHEAP_MARKEND;

return 0;
}


// actual launching of a midlet
LOCAL_C void doLaunchL()
{
TBuf<KMaxCommandLine> cmdLine;
_LIT(KSeparator, "*");

// cmd line syntax: PortNumber*MIDletUid*MIDletName*JarLocation*JadLocation*

cmdLine.AppendNum(KMidletPort);
cmdLine.Append(KSeparator);

// append a midlet uid in decimal format to the command line
TBuf<16> uidNum;
uidNum.Num(KMidletUid.iUid,EDecimal);
cmdLine.Append(uidNum);
cmdLine.Append(KSeparator);

// append a midlet name to the command line
cmdLine.Append(KMidletName);
cmdLine.Append(KSeparator);

// append a jar file location to the command line
cmdLine.Append(KMidletJarLocation);
cmdLine.Append(KSeparator);

// append a jad file location to the command line
cmdLine.Append(KMidletJadLocation);
cmdLine.Append(KSeparator);

// create a new process
RProcess process;

TInt error = process.Create(KMidRunROMLocation,cmdLine);
User::LeaveIfError(error);

// TODO: process should be renamed according to convention used with KVM

process.Resume();
process.Close();
}

这是一段完整的调用JAVA的代码,但是是1.0-2.0版本的。请说明一下具体哪些地方需要针对3.0作出修改。

最简单的安装方法:首先,读卡器或数据线“大容量存储模式”连接: 1:电脑上操作:将程序COPY到存储卡的others(其他); 2:手机上操作:应用程序---文件管理---选择存储卡---其他---找到该程序后点击它安装即可。 3:安装好的程序在这里:应用程序 JAVA游戏的安装须知:【 新手必看】  1:安装JAR程序游戏时,JAR文件名不能含有汉字,否则无法运行,请将文件名改成英文或拼音后安装。 2:将某些JAR安装到存储卡时,出现安装进度条到80%停止或死机的情况,但可以安装到手机内存。一般是存储卡兼容性不太好,建议格卡或换卡。 另外:关于JAR游戏安装出现“证书错误”时,不妨用这个方法试试: 大家知道,JAR游戏是不需要签名的,但出现“证书错误” ,应该是手机里自带的证书冲突,也就是也许你安装了某个软件在E盘,而他自带了某个证书,而机器只认C盘的证书,所以就发生系统错误了.(但JAR可以装手机里)说明可能是该JAR不支持安装这个机型,另外极有可能就是存储卡的问题, 解决方法如下: 把存储卡连上电脑后,找到存储卡的属性(鼠标右键最后一个)----工具----运行碎片整理一次(一般问题在这里就解决了)就能安装JAR软件了!如果还不行的话,进行多一步,找到存储卡的属性单击右键→属性→工具→有一个查错(选中)→然后把自动修复那项打上勾(另一个不要打!)→然后扫描等他查完 ……应该问题解决了!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值