Matlab compiled jar cannot run with task scheduler but can run manually

1 view (last 30 days)
Hello everyone,
I have some matlab-code, which included as jar-File (created with matlab compiler sdk) in a java-application. If I start my java-application manually using a bat-file everything works. But if I start the same bat-file using the windows task scheduler the matlab-code cannot be executed. (The other parts of the java-application work in both cases)
... Matlab M-code Stack Trace ...
com.mathworks.toolbox.javabuilder.MWException: An error occurred while initializing the component.
Could not access the MATLAB Runtime component cache. Details: Some error has occurred in the file: b:\matlab\standalone\mclmcr\mcr_cache\mclcomponentcache.cpp, at line: 250.
The error message is:
Failed to completely extract component!
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclInitializeComponentInstance(Native Method)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.access$700(
at com.mathworks.toolbox.javabuilder.internal.MWMCR$6.mclInitializeComponentInstance(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.mathworks.toolbox.javabuilder.internal.MWMCR$5.invoke(
at com.sun.proxy.$Proxy79.mclInitializeComponentInstance(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.newInstance(
I also don't understand why it's accessing drive B. The file and the matlab runtime installation is located on drive C.
Things I already checked:
  • Path variable of the matlab runtine installation
  • Check the cache files (
  • Setting an env-variable MCR_ROOT_CACHE to a temp-folder (didn't found the link again)
  • I tried to compile with -C but it fails:Packaging...Creating the bundle...Failed to create the install bundle[...]\for_testing\de.ctf (The system cannot find the file specified)
  • Matlab 2016b
  • Java 8
  • win server 2012 (64bit)
Would be great, if someone give me a hint. Thanks, Thomas

Accepted Answer

Prannay Jain
Prannay Jain on 6 Apr 2017
I am not sure what might be the issue, but there are few things you might try:
1) It may be a permission issue. Make sure that you have the right permissions to access MCR cache folder. Can you try changing MCR_CACHE_ROOT to some other folder and see if it makes any difference.
2) Is your application accessed/shared by multiple users? (Again look for the permissions for all the users even within your system.)
3) Did you correctly provide 'start-in' directory while creating the task? This discussion might be helpful:
Thomas Schürle
Thomas Schürle on 10 Apr 2017
Appendix: Finally, it works. I'm not really sure, what solved the issue. Probably it was the invalid name of the environment-variable; so thanks again! (I added some other applications on the same server and had some restarts and now it works...)

Sign in to comment.

More Answers (0)


Find more on Application Deployment in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by