Why can't I use Java in startup.m?
显示 更早的评论
I have multiple monitors, and in my startup.m script, I'm trying to find out which one the MATLAB GUI is in (because I want to set the default figure location to the other monitor). This answer tells me to use the following Java object to get the location of the MATLAB GUI:
pt = com.mathworks.mlservices.MLEditorServices.getEditorApplication.getActiveEditor.getComponent.getRootPane.getLocationOnScreen;
This works great, except when I put it in my startup.m script. I get this warning on the line of code shared above when I start MATLAB, and the rest of my startup.m script doesn't run:
Warning: Executing startup failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should
be resolved as soon as possible. Error detected was:
MATLAB:structRefFromNonStruct
Dot indexing is not supported for variables of this type.
So is Java not available during MATLAB startup? If not, is there another way to determine which monitor MATLAB is open in?
I'm using MATLAB 9.4.0.813654 (R2018a) on Windows.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!