JExternal
Mar. 01, 2010
 



Click HERE to know information about JExternal Source Code.
What is JExternal

JExternal is a 4D plug-in to execute Java methods from within 4D. JExternal enables you to use many useful Java libraries 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-in methods. Besides JExternal allows the Java methods to callback 4D methods.

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

Java methods called from within 4D are executed in a 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 another 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) The parent folder of the structure file
(3) The parent folder of the application file (4th Dimension or 4DServer)
(4) 4D folder

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

If JExternal is used with 4D Server, the JavaClasses folder in the Contents folder of JExternal_xxx.bundle is automatically downloaded into the clients.


System requirements

JExternal works with 4th Dimension / 4D Server v 6.0 or later in Mac OS and Windows. On Intel-based Macs, JExternal doesn't work with 4D v2004 or earlier, because it cannot run on Rosetta.

The current version (JExternal 6.0.0) requires 4D v11 or later, and Java 5 (JRE/JDK 1.5) or later on both platforms.


Java virtual machine ( JVM )

JExternal requires a Java virtual machine (JVM) to run. A JVM is launched by JWorld which is another 4D plug-in. In Mac OS, Apple's built-in JVM is launched by JWorld. In Windows, if JWorld 6.0.0 or later is used, JWorld's built-in JVM is launched. If JWorld 5.x.x or earlier version is used in Windows, you have to install a JVM which is downloadable 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
executes a Java class (static) method.
JEX Call object method
executes a Java object (instance) method.


When these methods pass parameters to a Java method or receive results from a Java method, 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_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 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


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