JExternal
Nov.09.2007
 



What is JExternal

JExternal is a plug-in for 4D that enables to execute Java methods from within 4D. A lot of useful libraries written in Java can be used in 4D.

JExternal looks for Java files in "JavaClasses" folder and allows Java methods in those files to be used as if they were 4D plug-ins methods. Besides it allows the Java methods to callback 4D methods.

Create a "JavaClasses" folder and put Java files whose extensions are ".jar" into it. Then Java methods in the files can be executed from within 4D.

In JExternal ver 4.1.1 or later, Java methods called from within 4D are executed in a native thread corresponding to a 4D process. If Java methods are called from two processes at the same time, they are executed in parallel.

JExternal requires JWorld which is the plug-in to launch a Java virtual machine for JExternal.

The JavaClasses folder may be located in the following folders:

(1) The Contens folder of JExternal_xxx.bundle
(2) Folder where the structure file exists
(3) Folder where the application file (4th Dimension, 4D Server ...) exists
(4) 4D folder (or ACI folder)

The JavaClasses folder is searched in above order. The files in the JavaClasses folder found first are added to the classpath in Java.

Note: (1) is added for JExternal version 4.0.1 or later. If you use JExternal with 4D Server 2004, all the files and folders in the Contents folder of JExternal_xxx.bundle are automatically downloaded into the clients. You don't need to download files in the JavaClasses folder by yourself.


System requirements

JExternal works with 4th Dimension, 4D Server v 6.0.6 or later in Mac OS and Windows.

JExternal cannot work with v2004 or earlier versions of 4D on Intel-based Macs, because it cannot work in Rosseta. On Intel-based Macs, you need to use JExternal ver 4.1.1 or later with 4D v11 or later.

In Windows JExternal requires a Java virtual machine from Sun Microsystems.


Java virtual machine ( JVM )
JExternal requires a Java virtual machine (JVM) to run. The Java virtual machine is launched by JWorld which is another 4D plugin.

In Mac OS X, JExternal uses the built-in JVM.

In Windows, JExternal requires Sun's J2SE(Java2 Platform Standard Edition) . You can download the latest J2SE at the following URL.

http://java.sun.com/javase/downloads/


Type mapping
JExternal provides 4D with four plug-in methods. Following methods will be used mainly.


JEX Call class method
This method executes a Java class ( static ) method.
JEX Call object method
This method executes a Java object ( instance ) method.


When these methods pass parameters to Java methods or receive results from them, their data types are converted as follows.
4th Dimension
<-->
Java
C_BOOLEAN
<-->
boolean
C_LONGINT
<-->
int
C_REAL
<-->
double
C_TIME
<-->
com.ronri_kobo.Time
C_DATE
<-->
com.ronri_kobo.Date
C_STRING
<-->
com.ronri_kobo.String255
C_TEXT
<-->
java.lang.String
C_PICTURE
<-->
com.ronri_kobo.Picture
C_BLOB
<-->
byte[]
ARRAY BOOLEAN
<-->
boolean[]
ARRAY INTEGER
<-->
short[]
ARRAY LONGINT
<-->
int[]
ARRAY REAL
<-->
double[]
ARRAY DATE
<-->
com.ronri_kobo.Date[]
ARRAY STRING
<-->
com.ronri_kobo.String255[]
ARRAY TEXT
<-->
java.lang.String[]
ARRAY PICTURE
<-->
com.ronri_kobo.Picture[]

Limitation

User interface components including windows cannot be used in Java methods called by JExternal. If you have to communicate with an user in the Java methods, you should callback 4D methods from the Java methods.


Documentation

If you use Xcode, you can debug Java methods called by JExternal by synchronizing with 4D.



 
Copyright (c) Ronri Kobo, Inc. All rights reserved.
support@ronri-kobo.com