3
votes

I am calling a java function in Delphi 7 using JNI. When start button click the java application loads and when stop button clicks the java application exits. But my problem is that when I click stop button, the java application and the delphi application exits. I need to exit the java application only and not the delphi application.

var
  exit_code: Integer;
  Runtime  : TJavaRuntime;
begin
  exit_code := 0;
  Runtime.CallExit(exit_code);
end
1
Looks like java.lang.System.exit() is terminating the process too. - David Heffernan

1 Answers

4
votes

Runtime.exit() calls Runtime.halt() which forcibly terminates the JVM process. Unfortunately the JVM (jvm.dll) is running in the same process as your application, so the call of Runtime.exit() terminates your application.