0

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]);
3
  • 2
    Maybe related / already answered here: stackoverflow.com/questions/36250235/… Commented Oct 31, 2022 at 17:22
  • When you see the AV, are you running inside the debugger? Does the AV actually reach your code? If not, then don't worry about it. Commented Oct 31, 2022 at 19:57
  • I'm running inside the debugger. That AV causes not working Java VM. So I can't go further. Commented Nov 4, 2022 at 9:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.