MATLAB hangs when I try to use the java package jdde, but only for the first time after a system reboot

与世无争的帅哥 提交于 2019-12-12 10:28:48

问题


I'm using the external java package jdde in MATLAB. Please note that for the following example, the DLL file that comes with the package needs to be on the MATLAB librarypath. The method to do this is different depending on your MATLAB Version.

Using jdde in MATLAB works fine, except for the first time after I reboot the computer or I logoff/logon in Windows. When I run the following code for the first time after a computer reboot, MATLAB will stay in busy mode forever (with 0% CPU). When this happens, I kill the MATLAB process in the task manager and restart MATLAB. When I run the same code again, it will execute instantly (not staying busy forever).

javaaddpath('C:\pretty-tools-JDDE-1.0.2.jar')
a =  com.pretty_tools.dde.client.DDEClientConversation;
a.connect('','');

To sum it up, the above code will cause MATLAB to stay busy forever the first time I run it after a system reboot or user logoff/logon. When I run it again after killing the MATLAB process, it will work perfectly fine (not hanging up MATLAB).

I have seen this behavior on different computers, and in different Versions of MATLAB (2010 and 2012). I'm using Windows 7 x64.

In the code example, the a.connect command is the one that causes MATLAB to stay busy forever. Putting this command in a try/catch block would not help, because the a.connect doesn't cause an error, it just never does continue.

I'm not sure if this problem is caused by MATLAB or by the java package. Any ideas how to get rid of this behavior would be much appreciated.

Note: The input argument of a.connect does not matter, it will always hang, so I just gave '' as input in this example.


回答1:


Code hangs without any know reason in DdeInitialize() method. New build JDDE-2.0.3 contains workaround for this problem.




回答2:


Try running the add path command on its own so that there is a second or two before it tries to execute code dependant on the jar. I have found this to often be the problem with intermittent issues having to do with jars in Matlab




回答3:


Switch over to classic mode initially so that u will get rid of that.



来源:https://stackoverflow.com/questions/12911160/matlab-hangs-when-i-try-to-use-the-java-package-jdde-but-only-for-the-first-tim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!