MATLAB: Does MATLAB crash when I call a MEX-file that includes a Java DLL file in MATLAB 7.0 (R14)

dllincompatibilityjavaMATLAB

I am calling a MEX-file that includes a Java DLL file named OOIDrv32.dll. The DLL file uses a different version of the Java VM than MATLAB. I receive the following error message:
Can't create Java VM for OOIDrvJ
Unable to open JoeDriver
MATLAB also crashes, with the following stack trace:
------------------------------------------------------------------------
Segmentation violation detected at Thu May 26 12:02:13 2005
------------------------------------------------------------------------
Configuration:
MATLAB Version: 7.0.0.19920 (R14)
Operating System: Microsoft Windows 2000
Window System: Version 5.0 (Build 2195: Service Pack 4)
Processor ID: x86 Family 15 Model 2 Stepping 9, GenuineIntel
Virtual Machine: Java 1.4.2 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Default Charset: ibm-5348_P100-1997
Register State:
EAX = 00000000 EBX = 00000000
ECX = 27983d30 EDX = 00000000
ESI = 00000001 EDI = 00000e40
EBP = 00cd5f30 ESP = 00cd5f10
EIP = 305db848 FLG = 00010246
Stack Trace:
[0] OOIDRV32.dll:0x305db848(1, 0x00cddfc8 "4àÍ", 0, 0)
[1] OOIDRV32.dll:0x305e975e(0x00cd5fa4, 0x00cde034 "PàÍ", 0, 0)
[2] pixel.dll:0x305a5f03(0x019c6660, 0x019c66a0, 0x00cde71c, 0)
[3] pixel.dll:0x3059120f(1, 0x00cde71c, 1, 0x00cde77c)
[4] libmex.dll:_mexRunMexFile(1, 0x00cde71c, 1, 0x00cde77c) + 71 bytes
[5] libmex.dll:public: virtual void __thiscall Mfh_mex::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(1, 0x00cde71c, 1, 0x00cde77c) + 157 bytes
<snip>
MATLAB also crashes when, instead of using a MEX-file, I use the CALLLIB function.

Best Answer

This enhancement has been incorporated in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
The ability to call a MEX-file that includes a Java DLL that uses a different version of the Java VM is not available in MATLAB 7.0 (R14) and later versions.
To work around this issue, change the version of MATLAB's Java VM to be compatible with the external library's Java VM version.
For information on how to change the MATLAB's Java VM version, type the following command at the MATLAB prompt:
web([docroot,'/techdoc/matlab_external/f122001.html'])
Another workaround is to launch MATLAB with the '-nojvm' option. However, MathWorks does not support this option, and using it suppresses many GUI features such as GUIDE.