This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Add-ons & Links / J/Link / Part 1. Installable Java: Calling Java from Mathematica /

Part 1. "Installable Java": Calling Java from Mathematica

J/Link provides Mathematica users with the ability to interact with arbitrary Java classes directly from Mathematica. You can create objects and call methods directly in the Mathematica language. You do not need to write any Java code, or prepare in any way the Java classes you want to use. You also do not need to know anything about MathLink. In effect, all of Java becomes a transparent extension to Mathematica, almost as if every existing and future Java class were written in the Mathematica language itself.

We call this facility "installable Java" because it generalizes the ability that Mathematica has always had to plug in extensions written in other languages through the Install function. We will see later how J/Link vastly simplifies this procedure for Java compared to languages like C or C++. In fact, J/Link makes the procedure go away completely, which is why we say that Java becomes a transparent extension to Mathematica.

Although Java is often referred to as an interpreted language, this is really a misnomer. To use Java you must write a complete program, compile it, and then execute it (some environments exist that let you interactively execute lines of Java code, but these are special tools, and similar tools exist for traditional languages like C). Mathematica users have the luxury of working in a true interpreted, interactive environment that lets them experiment with functions and build and test programs a line at a time. J/Link brings this same productive environment to Java programmers. You could say that Mathematica becomes a scripting language for Java.

To Mathematica users, then, the "installable Java" feature of J/Link opens up the expanding universe of Java classes as an extension to Mathematica; for Java users, it allows the extraordinarily powerful and versatile Mathematica environment to be used as a shell for interactively developing, experimenting with, and testing Java classes.