The matlab-connector library enables function execution on a remote MATLAB instance.
JSON is used as a platform and language independent.
java -jar matlab-connector-1.1-SNAPSHOT-with-dependencies.jar <port> <threads> <path>
The connector is available on the UncertWeb Maven repository, hosted at the University of Münster. Adding the following snippet to your pom.xml
file will include the repository in your project.
<repositories>
<!-- Other repositories may be here too -->
<repository>
<id>UncertWebMavenRepository</id>
<name>UncertWeb Maven Repository</name>
<url>http://giv-uw.uni-muenster.de/m2/repo</url>
</repository>
</repositories>
The dependency for the connector can then be added.
<dependencies>
<!-- Other dependencies may be here too -->
<dependency>
<groupId>org.uncertweb</groupId>
<artifactId>matlab-connector</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
To execute a function in Java. Host can be localhost, or remote.
// Create handler instance
MLHandler handler = new MLHandler();
// Build request
MLRequest request = new MLRequest("do_a_sum");
request.addParameter(new MLScalar(2));
request.addParameter(new MLScalar(2));
// Send request
MLResult result = handler.sendRequest("localhost", 44444, request)
// Print result
System.out.println(result.toString());
If you wish to build the project from source, the matlabcontrol 4.1.0 library is required. As this is currently unavailable on most Maven repositories, you can instead manually download the JAR file and install locally:
$ mvn install:install-file -Dfile=matlabcontrol-4.1.0.jar -DgroupId=matlabcontrol -DartifactId=matlabcontrol -Dversion=4.1.0 -Dpackaging=jar
Then build:
$ mvn clean package
Tests will fail unless a local MATLAB installation can be found.
Security has also been overlooked in the current version, I'd recommended restricting access to the port the server runs on until access control is implemented.