External Calling of Java code

In this tutorial we develop a Java/Maple project consisting of:

A Java class, GeometryUtils, with methods circleArea() and rectangleArea(). The class calculates area for the shapes (circle, rectangle). In the tutorial we use super simple Java class to concentrate on the subject.

A Maple module, GeometryModule, with public variables circleArea and rectangleArea which call corresponding Java methods directly from the compiled Java class GeometryUtils using define_external Maple command.

Do not forget to replace CLASSPATH value with the actual output folder path of your Java project where compiled Java classes are located (by default is bin folder of your project).

From a project's pop-up menu (right-click), select Run as > Maple.

Maple runs in the Eclipse console and we can use our Java methods as normal Maple procedures defined in the module.

Future enhancements

For the next update for the Maple IDE, we plan to add three export wizards for Java, C and Fortran projects. The wizards automatically generate a Maple module with external calling commands based on the selected Java class, C or Fortran shared library.

Possible issues

The error means you compiled the Java class with a newer version of Java and are trying to run with an older version, such as compiling with Java 7 but trying to run in Java 5 environment. Currently Maple uses Java 5 environment.