aleroot / DelphiJNI

A Delphi/Kylix JNI implementation .
30 stars 8 forks source link

Java 1.8 problem #1

Closed EPluribusUnum closed 7 years ago

EPluribusUnum commented 7 years ago

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 `

aleroot commented 7 years ago

I don't have access to a Windows machine with Delphi installed to try at the moment, but I remember that I had tried with Java 8 almost two years ago and it was working fine.

You need to check two things :

  1. The jvm.dll is present in sytem path (add %JAVA_HOME%/bin and %JAVA_HOME%/bin/client to the %PATH% environment variable)
  2. The JRE or JDK installed and put in path is the same architecture of your compiled delphi architecture(for Delphi 7 is for sure 32bit while for Delphi XE4 you could decide if 32 or 64bit)
EPluribusUnum commented 7 years ago

It was a path issue. Thank you!