How to connect Java and Maple using OpenMaple

1. Setup Runtime Environment:

Open your environment file (example in Linux with .bashrc) add these code to initialize environment and library:

. $MAPLE/bin/maple -norun    # for maple config environment
export MAPLE=/home/your_user_name/opt/maple2015
export CLASSPATH=$CLASSPATH:$MAPLE/java/externalcall.jar
export CLASSPATH=$CLASSPATH:$MAPLE/java/jopenmaple.jar

2. Example code.

Create file and add these code.

import com.maplesoft.openmaple.*;
import com.maplesoft.externalcall.MapleException;
class test
   public static void main( String args[] )
       String a[];
       Engine t;
       int i;
       a = new String[1];
       a[0] = "java";
           t = new Engine( a, new EngineCallBacksDefault(), null, null );
           t.evaluate( "int( x,x );" );
       catch ( MapleException e )
           System.out.println( "An exception occurred" );
       System.out.println( "Done" );

Run by type in terminal:

$ javac
$ java Test

Screenshot-from-2017-05-09 22:42:44.png

Notice: With Netbean, Eclipse or other IDEs. If it doesn’t work. You should add Maple library *.jar file above into your project.


Leave a Reply

Your email address will not be published. Required fields are marked *