Contact
Developers

# FAQ

A: JMatLink connects Java to MATLAB using native methods.

Q: Where can I get JMatLink?
A: Go to Stefan's homepage at www.held-mueller.de/JMatLink/.

Q: Where can I get java?
A: Go to Javasoft.

Q: Where can I get MATLAB?
A: Go to The Mathworks.

Q: How can I build JMatLink on Sun Solaris?
A: Here is help from Christian Schaffner. Makefile:
-------------------------------------------------------------
# This makefile builds JMatLink library on  (SunOS 5.5.1).
# Christian Schaffner 12/12/00

CC = gcc
LD = ld

# MATLAB
MATLAB = /usr/pauke/packages/matlab-5.3
MLIB = -L$(MATLAB)/extern/lib/sol2 MINCLUDE = -I$(MATLAB)/extern/include

# JAVA
JAVA = /usr/pack/jdk-1.1.6pr-to/java1.1
JINCLUDE = -I$(JAVA)/include -I$(JAVA)/include/solaris

$(LD) -G$(MLIB) -leng -lmx -o libJMatLink.so JMatLink.o

$(CC) -c -shared$(JINCLUDE) $(MINCLUDE) JMatLink.c ------------------------------------------------------------- Sun Microsystems Inc. SunOS 5.5.1 Generic May 1996 gcc version 2.95.2 19991024 (release) ld: Software Generation Utilities - Solaris/ELF (3.0) java version "1.1.6" matlab Version 5.3.0.10183 (R11) Before starting the following environment variable must be set: setenv LD_LIBRARY_PATH {$LD_LIBRARY_PATH}:/usr/pauke/packages/matlab-5.3/extern/lib/sol2:pwd


Q: I am trying to compile the dll JMatLink.dll but I am missing the file: 'engine.h'
A: The file is in /extern/include/. It is part of matlab. Please include the above mentioned directory for your compiler settings.

Q: How do I start an .m-file with JMatLink?
A: This is done by evaluating the following command.
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("some_script")

Hint: Make sure that MATLAB is running in the right directory. It may be necessary to set the working directory of MATLAB through the engine interface.
E.g.:
engine.engEvalString("cd c:/your/path/to/your/scripts/")


Q:I want to know how to pass variables from Java to Matlab?
A: I want to know how to pass variables from Java to Matlab. I have a function "myfunction.m" and i have a java program "prog.java" within i define a variable "var = 100". When I do :
 var = 100;
engine.engEvalString("cd c:\\test, result =" +
"feval('myfunction'" + Double.toString(var) + ")");
res  = engine.engGetArray("resultat");

Double.toString() should to the job.

Q:I am having problems with the method engGetVector() in Java?
A: The method engGetVector() ist NOT implemented in the any more. Please use engGetVariable() instead.

Q: When I try to compile JMatlink.c The compiler needs the file "engine.h", which I cannot find. Where is it?
A: You'll find it in one of MATLAB's directories. It is in /extern/include/. Make sure that the mentioned directory is in the search path of your compiler.

Q: Can I pass to matlab an expression and get a result in Java?
A:
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("a=111");
engine.engClose();


Q: I tried to run the graphical example
java TestGui
but it did terminate with the following error message:
    ERROR: Could not load the JMatLink library
This error occures, if the path to
matlab's \bin directory is
not set properly.
at TestGui.(TestGui.java:71)
at TestGui.main(TestGui.java:258)

A: JMatLink is using a .DLL-library on Windows the error message says, that the DLL-file cannot be found. Please copy the JMatLink.dll file into the c:\windows or c:\winnt directory.

Q: was able to build a shared library on Linux for JMatLink. This is for JDK 1.4 so I the .h file reflects the new package name for JMatLink: jMatLink. Here is the makefile I used:
A:
CC=cc
LD=ld

# MATLAB
MATLAB=/usr/matlab
MLIB=-L$(MATLAB)/extern/lib/glnx86 MINCLUDE=-I$(MATLAB)/extern/include

# JAVA
JAVA=/usr/java/j2sdk1.4.1_01
JINCLUDE=-I$(JAVA)/include -I$(JAVA)/include/linux

$(LD) -G$(MLIB) -leng -lmx -o libJMatLink.so JMatLink.o

$(CC) -fPIC -shared$(JINCLUDE) \$(MINCLUDE) -c JMatLink.c



Q:
I am trying to use JMatLink with MatLab 6. I could get everything else to work, but engOutputBuffer() does not return any output. The syntax I am using is:
	eng.engOpen();
eng.engEvalString("format compact;");
eng.engEvalString("round(10.22)");
buffer = eng.engOutputBuffer();
eng.engClose();

A:

Q: I get an error message like below:
Number of Java-Threads: 16


Find an example on how to use JMatLink below:

 package your.package.ui; import jmatlink.*; public class SimpleTextGUI01 { public static void main(String[] args) { // create instance of engine JMatLink engine = new JMatLink(); // open engine and start MATLAB engine.engOpen(); // test string: create array of random numbers String testCommand = "a=rand(4)"; engine.engEvalString(testCommand); // terminate MATLAB and close engine engine.engClose(); } } 

Q:
A:

Q:
A:

Q:
A:

Q:
A:

Q:
A:

Q:
A:

Q:
A:

Q:
A: