- ๐ Hi there, Iโm @aleroot
- ๐ Iโm interested in: low level programming, software performance
- ๐ฑ Iโm currently learning Swift
aleroot / delphijni Goto Github PK
View Code? Open in Web Editor NEWA Delphi/Kylix JNI implementation .
A Delphi/Kylix JNI implementation .
Hi!
I cannot use jvm.dll, application crashes upon LoadVM (JNI_CreateJavaVM) call. No error message, no call stack, no log, just crash. If I use JNI_VERSION_1_7, no crash, but LoadVM returns JNI_EVERSION.
Setting Xms, Xmx, Xss JVM parameters does not help.
jvm.dll version : 25.40.0.25 (Java 1.8) (Java HotSpot(TM) Client VM) (x32)
Tried with Delphi 7 @ Win XP and Delphi XE4 @ Win7
What could be the problem?
`
VAR
errorcode : Integer;
JVM : TJavaVM;
Options: array [0..4] of JavaVMOption;
VM_args: JavaVMInitArgs;
JNIEnv : TJNIEnv;
Cls : JClass;
Mid: JMethodID;
begin
JVM := TJavaVM.Create(JNI_VERSION_1_8);
Options[0].optionString := '-Dfile.encoding=utf-8';
Options[1].optionString := '-Djava.class.path=.';
VM_args.version := JNI_VERSION_1_8;
VM_args.options := @options;
VM_args.nOptions := 2;
VM_args.ignoreUnrecognized := TRUE;
errorcode := JVM.LoadVM(VM_args);//crash
`
Hello,
Please note that JNI can't find the class PageGrabber from
PageGrabber.zip
procedure doJNI;
label
Clear;
var
Errcode : Integer;
VM_args : JavaVMInitArgs;
Options : array[1..10] of JavaVMOption;
JavaVM : TJavaVM;
JavaEnv : TJNIEnv;
JavaCls : JClass;
begin
LoadJVM(JavaLibPath);
InitRecord(Options,SizeOf(Options));
VM_args.version := JNI_VERSION_1_8;
VM_args.options := @Options;
VM_args.nOptions := 1;
VM_args.ignoreUnrecognized := True;
Options[1].optionString := '-Djava.class.path=.';
JavaVM := TJavaVM.Create(VM_args.version);
JavaEnv := nil;
try
Errcode := JavaVM.LoadVM(VM_args);
finally
end;
if Errcode<0 then
begin
ShowMessageFmt('LoadVM failed, error code = %d', [Errcode]);
goto Clear;
end;
JavaEnv := TJNIEnv.Create(JavaVM.Env);
if JavaEnv=nil then
begin
MessageBox(Handle,'Create Java Env Error','Delphi Java Class',MB_OK or MB_ICONERROR);
goto Clear;
end;
JavaCls := JavaEnv.FindClass('PageGrabber');
if JavaCls=nil then
begin
MessageBox(Handle,'Create Java Class Error','Delphi Java Class',MB_OK or MB_ICONERROR);
goto Clear;
end;
Clear:
if Assigned(JavaEnv) then FreeAndNil(JavaEnv);
if Assigned(JavaVM) then FreeAndNil(JavaVM);
end;
Best regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.