我有个3-DES的加密程序是java的代码,我写了个函数,在jsp中可以用,但是我的delphi程序怎么调用呢?
解决方案 »
- 请高手帮我看看什么地方出了问题?
- 请问这个分页用什么方法实现啊?
- [今天奇了~~~怪了~~~]运行时改窗体居然有问题!!!!!!!11
- 哪位能帮我把源delphi程序打个包,高分赠送(急)
- 用javascript 如果获取一个已经下载到本地的activex控件的版本号?
- aiirii(ari-爱的眼睛),请进来领分!-3
- 请问一下在一张图中如何判断颜色是白色的部分的范围,赶着要,谢谢了啊
- 各位,小弟有一个用DELPHI做的办公自动化软件,一直找不到一个好的打包工具。高分相送,不够可以加
- access不支持事务?
- 求助:各位大哥请帮我看看这个字符串问题,谢谢!
- 预览中动态生成QRLabel和QRDBText的问题 小女子先谢谢各位大虾!!(分数不够再加)
- Indy中的TIdFTP如何把下载文件做成线程啊?
procedure TfrmJavaD.btnGenerateClick(Sender: TObject);
var
Cls: JClass;
{ $IFNDEF JNIUTILS }
MID: JMethodID;
{ $ENDIF }
Exc: JThrowable;
FileName: string;
ErrMsg: string;
begin
try
memOutput.Lines.Clear;
ShowStatus('Calling generator method...');
// Find JavaD class
Cls := FJNIEnv.FindClass(
'wood/keith/opentools/javad/JavaD');
if Cls = nil then
raise Exception.Create('Can't find class: ' +
'wood.keith.opentools.javad.JavaD');
// Run it
{ $IFDEF JNIUTILS }
FileName := JNIUtils.CallMethod(FJNIEnv, Cls,
'generateDelphiWrapper',
'String (String, String, boolean)',
[edtClassName.Text, edtDirectory.Text,
chkOverwrite.Checked], True);
{ $ELSE }
MID := FJNIEnv.GetStaticMethodID(Cls,
'generateDelphiWrapper',
'(Ljava/lang/String;Ljava/lang/String;Z)' +
'Ljava/lang/String;');
if MID = nil then
raise Exception.Create('Can't find method: ' +
'generateDelphiWrapper'); FileName := FJNIEnv.JStringToString(
FJNIEnv.CallStaticObjectMethod(Cls, MID,
[edtClassName.Text, edtDirectory.Text,
chkOverwrite.Checked]));
{ $ENDIF }
// Check for exception.
Exc := FJNIEnv.ExceptionOccurred;
if Exc <> nil then
begin
// Clear the exception so we
// can call other methods.
FJNIEnv.ExceptionClear;
// Find out about the exception -
// its class and message.
{ $IFDEF JNIUTILS }
Cls := JNIUtils.CallObjectMethod(
FJNIEnv, Exc, 'getClass', 'Class()', []);
ErrMsg := JNIUtils.CallMethod(
FJNIEnv, Cls, 'getName', 'String()', []) +
#13 + JNIUtils.CallMethod(
FJNIEnv, Exc, 'getMessage', 'String()', []);
{ $ELSE }
MID := FJNIEnv.GetMethodID(
FJNIEnv.GetObjectClass(Exc),
'getClass', '()Ljava/lang/Class;');
if MID = nil then
raise Exception.Create(
'Can't find method: getClass');
Cls := FJNIEnv.CallObjectMethod(Exc, MID, []);
MID := FJNIEnv.GetMethodID(
FJNIEnv.GetObjectClass(Cls),
'getName', '()Ljava/lang/String;');
if MID = nil then
raise Exception.Create(
'Can't find method: getName');
ErrMsg := FJNIEnv.JStringToString(
FJNIEnv.CallObjectMethod(Cls, MID, []));
MID := FJNIEnv.GetMethodID(
FJNIEnv.GetObjectClass(Exc),
'getMessage', '()Ljava/lang/String;');
if MID = nil then
raise Exception.Create(
'Can't find method: getMessage');
ErrMsg := ErrMsg + #13 +
FJNIEnv.JStringToString(
FJNIEnv.CallObjectMethod(Exc, MID, []));
{ $ENDIF }
raise Exception.Create(
'A Java exception occurred'#13 + ErrMsg);
end;
// Load the generated file.
memOutput.Lines.LoadFromFile(FileName);
ShowStatus('Done');
except
on E: Exception do begin
ShowStatus('Error');
MessageDlg('Error: ' + E.Message,
mtError, [mbOK], 0);
end;
end;
end;