Building and Running Applications - Maple Help

Building and Running a Java OpenMaple Application

Packages

 • The Java OpenMaple classes are provided in the com.maplesoft.openmaple package.  This package is contained within the Maple.jar file. A second package, com.maplesoft.externalcall.MapleException is also required for Java OpenMaple.  This class is in the externalcall.jar file. For documentation on the contents of the com.maplesoft.openmaple package, see OpenMaple/Java/API.  For information about com.maplesoft.externalcall.MapleException, see ExternalCalling/Java/MapleException.
 • These jar files are in the java directory of your Maple installation.  The directory that Maple is installed in can be found by calling kernelopts( mapledir ).
 > kernelopts( mapledir );
 ${"C:\Program Files\Maple 2015"}$ (1)

In the following sections we will refer to this directory as <MAPLEDIR>.  Different platforms and installation locations will effect this directory, so you should call kernelopts( mapledir ) to determine the correct location on your machine.

Building

 • To build a Java OpenMaple application the two required jar files, Maple.jar and externalcall.jar, must be in the classpath. Simply specify these files in a command-line argument to the Java compiler. In general, the -classpath argument should work.  You will need to have write permissions for the current directory as this command will create a new file.

Windows

 javac -classpath "\java\externalcall.jar;\java\Maple.jar" app.java

Apple OS X and Linux

 javac -classpath "/java/externalcall.jar:/java/Maple.jar" app.java

Running

 • Running a Java OpenMaple application requires loading a native library. This native library provides the link between Maple and Java.  The Java Virtual Machine automatically loads the required library; however, it needs to be told where to find this library.  By default, the native library is installed in the Maple binary directory.  To determine this location, call kernelopts( bindir ).
 > kernelopts( bindir );
 ${"C:\Program Files\Maple 2015\bin.win"}$ (2)

Different platforms and installation locations will effect the directory you need to use, so you should call kernelopts( bindir ) to determine the correct location.  We will refer to this directory as <BINDIR> in the following examples.

 • To tell the Java Virtual Machine to look in this directory, you need to add  to a platform specific environment variable.  In addition on Apple OS X and Linux, the MAPLE environment variable needs to be set to the value  we defined above.

Windows

 • In Windows, you need to add  to the PATH environment variable

 set PATH=%PATH%;

Linux

 • On Linux, you need to add at least  to the LD_LIBRARY_PATH environment variable and set the MAPLE environment variable.  For a complete list of directories to add, run getenv(LD_LIBRARY_PATH); in Maple and use that exact value.

 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:" export MAPLE="" Apple OS X  • On Apple OS X, you need to add at least to the DYLD_LIBRARY_PATH environment variable and set the MAPLE environment variable. For a complete list of directories to add, run getenv(DYLD_LIBRARY_PATH); in Maple and use that exact value.  export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:" export MAPLE=""

 • As with the compiler, the Java Virtual Machine must have the Maple.jar and externalcall.jar files added to the classpath, along with the directory containing the test.class file created above. Once again, using the -classpath command-line argument is recommended. This example assumes that the test.class file is stored in the current directory.
 • Additionally the -Xss option must be used to specify the default amount of stack memory Java will allow the Maple calls to use.  The default of 1MB is too low for Maple and may lead to segmentation faults.  The higher the value, the deeper Maple will be allowed to recurse during computations.

Windows

 java -Xss100M -classpath "\java\externalcall.jar;\java\Maple.jar;." test

Apple OS X and Linux

 java -Xss100M -classpath "/java/externalcall.jar:/java/Maple.jar:." test

 • Before beginning development of a Java OpenMaple application, ensure that the simple example from the examples page can be built and executed.  Once this works, a more complex Java OpenMaple application can be built the same way.