1

Earlier this year I code Java GUI to work in Matlab environment for image acquisition purposes. I was able to call Java_Gui.jar inside the matlab, as well as to use some of the classes from the .jar file. The GUI was tested on WinXP 32bit, and Matlab2006b and Matlab 2008a. Matlab code for calling Java classes:

clc,clear all,close all

javaaddpath('C:\Users\...\JavaGUI.jar');

JavaGUI.main([]);
pause(1)
JavaGUI.main2();

However, when tried same program with Win7 on 64bit and Matlab2011a the familiar problem occurred:

??? Java exception occurred:
java.lang.UnsatisfiedLinkError: no sserial in java.library.path

Any idea why is this happening? Maybe I should compile my jar file on 64bit version? The code is still working on 32bit Win, just checked it.

ANSWER: Works with 32-bit version of Matlab on 64-bit Windows 7!

Makaroni
  • 880
  • 3
  • 15
  • 34

2 Answers2

2

Probably your JAR uses JNI.

JNI won't be able to load into a process of a different bitness than the DLL containing the native portions. You'd need a 64-bit version of the library (the Java code is no different, the native DLLs are) in that case.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • You are right. The following error in Matlab occurred:`D:\Matlab2011_full\sys\java\jre\win64\jre\bin\sserial.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform`. However, what is strange for me is that JavaGUI outside Matlab is working properly with the same dll. – Makaroni Jul 13 '12 at 17:05
  • 2
    @Makaroni: It depends on the bitness of the process, not the bitness of Windows. So you might have a 32-bit application working fine, while 64-bit Matlab fails. (And my 32-bit student copy of MatLab would load it fine also, even on 64-bit Windows). – Ben Voigt Jul 13 '12 at 17:10
2

The problem is that you are using a library in java that makes calls to a native library for which you need the 64-bit version in order to run it in the 64 bit JRE. You need to either switch to a 32 bit version of Matlab, or track down the library that makes native calls to sserial and update to the 64 bit version for 64 bit systems.

LINEMAN78
  • 2,562
  • 16
  • 19