I have problem with loading Java VM. When I do LoadVM program gives access violation. On other computer it works fine. Here is some code that works but not on my machine:
uses jni;
var
Options: array [0..1] of JavaVMOption;
VM_args: JavaVMInitArgs;
ErrCode: Integer;
AJavaVM: TJavaVM;
AJavaEnvMain: TJNIEnv;
JrePath, ProgramPath, LibPath, File1, File2: string;
begin
ProgramPath := 'd:\testjava\exe\';
JrePath := ProgramPath + 'JRE\bin\client\';
LibPath := ProgramPath + 'JRE\lib\ext\';
File1 := LibPath + 'file1.jar';
File2 := LibPath + 'file2.jar';
AJavaVM := TJavaVM.Create(JNI_VERSION_1_8, JrePath + 'jvm.dll');
FillChar(Options, SizeOf(Options), #0);
Options[0].optionString := PAnsiChar(AnsiString('-D java.class.path=' + File1 + ';' + File2));
VM_args.version := JNI_VERSION_1_8;
VM_args.Options := @Options;
VM_args.nOptions := 1;
ErrCode := AJavaVM.LoadVM(VM_args); **//access violation**
if ErrCode < 0 then
raise Exception.CreateFmt('Initialization error JVM, błąd %d.', [ErrCode]);