Using Visual Prolog DLL's from Java

This directory contains examples of how to use a Dynamic Link Library (DLL) created with Visual Prolog in a Java program (see Using Visual Prolog DLL’s from other languages for an overview of the examples).

All these examples uses the same Visual Prolog DLL’s that are found in the DLLS directory, so these have to be compiled before any of the examples are compiled and run.

Notes for Java

Please also read the common notes.

There is no common way to use a Visual Prolog DLL from Microsoft Java and Sun Java. In the case of Microsoft Java we use the J/Direct technology, and in the case of Sun Java we use JNI. Both these two technologies are too complex to describe in details here. In this context we will merely map Visual Prolog types to Java types:

Visual Prolog

Java

Integer

Int

Real

Double

Unsigned

short

String

class String

 

Visual Prolog

Java

Integer

int[]

Real

double[]

Unsigned

short[]

String

Int[]

 

The actual value returned is the first stored as the first and only element of the array. In the string case the interger array contains a pointer to the string as its first element.

Known Restrictions

We don’t provide examples that use Visual Prolog DLL with VPI because of: there is no way to obtain in Java a window handle that is required in an export function of such DLL.

We don’t provide examples that use Visual Prolog DLL with callbacks because of: there is no way to declare a pointer to a method at Java that can be used out of JVM context.

Examples

MSVJ example: Microsoft Visual Java program which uses a non-GUI Visual Prolog DLL.

SunJava example: Sun Java program which uses a non-GUI Visual Prolog DLL.