線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1655
推到 Plurk!
推到 Facebook!

BCB call JAVA裡的function,字串部分抓不到…

缺席
chen412
一般會員


發表:2
回覆:4
積分:1
註冊:2008-01-30

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-04-18 12:12:07 IP:220.133.xxx.xxx 訂閱
我想要用bcb去call java裡面function,在字串的部分有點問題…

RMI:fundserver、fundclient、fundif

fundserver.java
[code cpp]
public int addNum(int num1, int num2) throws RemoteException{
int total=0;

for (int i = num1; i<=num2; i ) {
total = i;
}
return total;
}

public String hello()throws RemoteException{
return "a return hello!";
}

[/code]

fundclient.java
[code cpp]
public static int addNum(int t2){
try{

//System.setSecurityManager(new RMISecurityManager());
System.getSecurityManager();
FundIF obj = (FundIF) Naming.lookup("rmi://192.168.1.111:31313/FundObj");

int total2 = 0;
total2 = obj.addNum(1,t2);
return total2;

}catch(Exception e){
System.out.println(e.getMessage());
return 0;
}
}
public static String hello(){
try{

//System.setSecurityManager(new RMISecurityManager());
System.getSecurityManager();
FundIF obj = (FundIF) Naming.lookup("rmi://192.168.1.111:31313/FundObj");
String msg;
msg = obj.hello();

return msg;
}catch(Exception e){
System.out.println(e.getMessage());
return "test";
}
}

[/code]

想要用C 程式去call fundclient裡的 addNum()、和hello()
程式如下

[code cpp]
jclass cls = env->FindClass("FundClient");

methodID mid2 = env->GetStaticMethodID(cls, "addNum", "(I)I");
Label2->Caption=env->CallStaticIntMethod(cls,mid2,100);

jmethodID mid4 = env->GetMethodID(cls,"hello","()Ljava/lang/String;");
Label4->Caption = env->CallCharMethod(cls,mid4);

[/code]
我只copy部分程式
他會return addNum的值給我
可是在hello function就不會傳
時在是不知道該怎麼搞了,請大家幫幫忙





系統時間:2024-04-25 6:22:45
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!