The Wolfram Language can connect to many outside programs. You can use the Wolfram Language's rich programming language to read and write to other supported programming languages. The Wolfram Language can be fully integrated with Java programs using J/Link.
There is some initial setup that must be done before you can start accessing Java programs.
First, load the J/Link package:
InstallJava is the function that launches the Java Runtime Environment and installs it into the Wolfram Language. Because some parts of the Wolfram Language use Java internally, Java is almost always already running, but it is wise to make sure:
Here is how to connect the Wolfram Language to a Java class using J/Link.
For example, create an instance of a Java Frame object:
You can call methods using the @ operator. Set the size of the window to 200×200 pixels:
J/Link has some built-in commands that automatically call Java methods. Show the window:
JavaShow[obj] is more or less equivalent to this Java call:
You can reference static methods and fields using the ` operator. Minimize the window:
You can find out what fields or methods are available for a given class by using Fields or Methods.
Print all the fields that pertain to window alignment:
Because underscores have a special meaning in the Wolfram Language, you must use an uppercase U in their place when referencing a name that contains an underscore:
Try to maximize the window with an underscore in the code. It does not work:
Using U in place of the underscore is the appropriate syntax:
Now close the window:
J/Link User Guide
How to: Connect to Other Systems
InstallJava ReinstallJava UninstallJava JavaNew LoadJavaClass JavaShow Constructors
Calling Java from the Wolfram Language
Java Objects in the Wolfram Language
"How to" Topics