How can I disable the JVM on a Windows platform fo

2019-02-11 05:03发布

I found a similar question here that doesn't help me so I'm asking my own. I have a matlab script that perfectly works under linux with nohup command. Unfortunately, I need to run that on windows also. But I can't understand why my command still doesn't work. My script does a certain loop but after the first it stops giving me an error about the java or something. I must tell you that the same problem occur under linux if I don't put the -nodisplay command.

My batch line is the following

matlab -nodisplay -automation -r "run('myfile.m')" -logfile output.txt -minimize

Please help me.

edit: I think I found my issue the problem is when I use -nodisplay under linux the command usejava('awt') works because my java environment is disabled, however this does not happen under windows! Why?

second edit: I think I found something that is quite similar to what I needed.

matlab -noawt -noFigureWindows -r "run('myfile.m')" -logfile output.txt -minimize

The analysis runs, without saying nothing, but the MATLAB command window still opens minimized..uhm I'd rather having anything to open up!

I must add another thing..nohup never waits and go forward until it reaches the end of the script, nevertheless using any other batch command such as start if there is any input request or "wait" it stops until someone gives an input!

1条回答
ら.Afraid
2楼-- · 2019-02-11 06:01

The undocumented -noawt option will prevent the GUI functionality, but let Java run. Combine that with -noFigureWindows, as you discovered, and you should have what you need. Alternatively, you can turn off figure display via your M file with set(0,'DefaultFigureVisible','off').

To see if Java actually loaded, run ver or version -java. Here's what I see with -nojvm.

Windows MATLAB with no Java

Then, using Windows' start /b /min MATLAB.exe ... should launch it minimized and without holding a command window opened.

To make MATLAB invisible try using the tiny NirCmd command line tool as follows,

nircmd.exe exec hide win64\MATLAB.exe -noawt -noFigureWindows -nosplash -minimize ...

I think that should do it, but make sure you start the actual MATLAB.exe in the bin\<architecture> folder, not just bin\matlab.exe because when it launches the actual MATLAB.exe, it will not be hidden.

查看更多
登录 后发表回答