What's New in J/Link 2
Changes in version 2.0.1
Fixes a bug that can cause the Java runtime to shut down in some
circumstances
on Java 1.1.x version runtimes (e.g., Mac OS 8/9, or Windows users using
the
Microsoft Java runtime).
Improves behavior of the Mathematica front end on Windows when it is
launched
to provide graphics rendering services for Java programs.
Fixes minor classpath problems on Mac OS 8/9.
Improves color scheme used by the ConsoleWindow class.
Changes in version 2.0.0
Special Notes:
The location of JLink.jar within the JLink directory
structure
was changed in this release. Users of previous versions with CLASSPATH
specifications that point at JLink.jar will need to revise them.
JLink.jar
is now in the JLink directory itself, not
JLink/SystemAdditions.
A number of functions have been renamed. The old names are deprecated,
meaning that they still work but might be removed in the future. All new
code should use the new names. Here are the old and new names:
| old name | new name |
| LoadClass | LoadJavaClass |
| ReleaseObject | ReleaseJavaObject |
| Val | JavaObjectToExpression |
| ByRef | ReturnAsJavaObject |
| GetClassPath | JavaClassPath |
Version 2.0 is a significant upgrade with many new features and
improvements.
Here are the most important ones:
Mac OS X is supported.
Dramatic speed improvements have been made for calling Java methods. This
makes the MethodFunction and FieldFunction optimizations more or less
obsolete.
One of the most difficult parts of J/Link installation was putting
the native
library in the correct location. This is no longer necessary. The native
library should remain where it is, buried deep in the JLink
directory
structure.
The way in which Java is launched by InstallJava is new. One consequence
of
this is that the ClassPath option works differently. The default setting,
Automatic, means that the value of the CLASSPATH environment variable will
be
used. However, if you set a value for ClassPath, that value is used
instead
of the CLASSPATH environment variable.
There is a new component called com.wolfram.jlink.ui.MathSessionPane that
implements a complete In/Out session window, similar to the kernel's raw
"terminal" interface, but with many more features, including: graphics
support,
syntax coloring of input, bracket matching, copy input from above,
customizable colors and fonts, full text editing features within the
current
input "cell" including cut/copy/paste/undo/redo, and more.
A new component called MathGraphicsJPanel is the Swing counterpart to
the existing AWT-based MathCanvas. Use this component to easily display
Mathematica graphics and typeset expressions in your programs.
There is a new Mathematica function, ShowJavaConsole[], that
displays a
window showing Java console output (i.e., theSystem.out and System.err
streams). On Windows, you no longer see a DOS Java console window appear
when Java launches.
The JavaBlock function is improved to give it more control over
what objects
are released when it ends. These improvements make some common programming
idioms easier, without having to resort to manual use of
ReleaseObject. If you
return a Java object as the sole result of a JavaBlock, that
object is not
released. There is also a new KeepObjects option to
JavaBlock that allows you
to specify a list of one or more objects that will not be released at the
end.
The new ImplementJavaInterface function lets you implement any
Java interface
entirely with Mathematica code. Among other uses, this means that
you can
create any "listener"-type object in Mathematica without requiring
a Java
MathXXXHandler class to already exist for that interface.
There is a SetInternetProxy function that allows users to specify
proxy port
and host information, if such settings are necessary to reach the
internet.
There is a new MakeJavaExpr[] function that lets you construct,
from
Mathematica, a Java Expr object from an arbitrary
Mathematica expression.
The AddToClassPath function was added to supersede the
functionality provided
by $ExtraClassPath.
There is a new JLink`Information` context that defines symbols
giving version
information. The symbols are $Version, $VersionNumber,
$ReleaseNumber.
Working with periodical tasks is now more flexible with the new function
SetPeriodicalInterval and the new variable
$ThisPeriodical.
For Java programmers, the MLGetType, MLGetNext methods when applied to a
KernelLink object can now return KernelLink.MLTKOBJECT in addition to
MLTKSTR,
MLTKINT, etc. MLTKOBJECT means that the expression on the link is a Java
object reference and can be read with getObject().
The MathLink connect() method now includes an optional timeout
parameter giving
the number of milliseconds to wait for the connection before throwing an
exception.
The MathLink interface now has a second signature for the getArray
method:
getArray(int type, int depth, String[] heads). This method reads an array
and tells you what the heads were at each level.
A getLastError() method was added to the KernelLink interface. If one of
the
evaluateTo methods returns null, you can call getLastError() to get the
Throwable object that caused the problem.
The methods interruptEvaluation(), abortEvaluation(), abandonEvaluation(),
and
terminateKernel() were added to the KernelLink interface. These methods
free
the programmer from having to deal directly with low-level MathLink
messages.
The Expr class has been extended and made faster and more robust.
|