Using the Java Native Interface with Delphi and Kylix

By: John Kaster

Abstract: Matthew Mead, JEDI author of the Java Native Interface support for Delphi/Kylix, explains how to communicate with Java, Delphi, and Kylix

Newsgroup Nugget: Calling a Delphi DLL from Java

This is a newsgroup nugget about another great header conversion from JEDI. This header conversion allows you to call Java from Delphi, and vice versa. This should also work for you in Kylix. Matthew Mead provides tutorials for using this on his web site at

Date: Tue, 3 Apr 2001 19:58:56 -0700
From: Matthew Mead
Newsgroups: borland.public.delphi.non-technical

jswager wrote:
>> If I write a Delphi DLL, would I be able to call the exported functions from Java? I realize that if there possible, that the only reasonable scenario would be that Java and the DLL are running on a Windows system.<<

To answer your first question: Yes. The technique is known as the Java Native Interface, or JNI. It's pretty much been around since the early days of Java. For C/C++ programmers, this API is in a .h file that comes with the JDK from Sun. Also, the JNI allows you to call in both directions: Java to Delphi or Delphi to Java. So you can extend your Delphi applications with Java classes.

For Delphi programmers, you need to get the Object Pascal translation of this header file. The "formal" distribution is at Project JEDI ( but you can also pick it up from my website (I'm the author of the translation.) The package contains all of the files you need (technically there are 2 files) to get up and running quickly with Delphi and the JNI. There are also tutorials and lots of sample code to help get you started.

To answer your second question (well, it isn't really a question): You are not tied to the Windows platform with the JNI. Since Delphi is now on Linux (and Java has been there) you can do Delphi/JNI programming with Kylix. In fact, the Kylix companion CD includes the Delphi JNI package from Project JEDI. (I haven't actually seen this yet, but I'm told it's on the CD. <g> I'm still saving up for Kylix...) You'll see that with a few {$IFDEF}s in your code, you will be able use the same source on Windows and Linux. Linux uses a different terminology than "DLL", but the functionality is the same.

Matthew Mead (Team JEDI)

Published on: 4/4/2001 12:00:00 AM

Server Response from: ETNASC03

Copyright© 1994 - 2013 Embarcadero Technologies, Inc. All rights reserved.