Thanks Marko. I have the matlabcontrol-demo-4.1.0 jar in the WEB-INF/lib directory as you stated and also in the buildpath as well. I run the following code to test as a java application in a vaadin project:
public static void main(String args) throws MatlabConnectionException, MatlabInvocationException
{
//Create a proxy, which we will use to control MATLAB
MatlabProxyFactory factory = new MatlabProxyFactory();
MatlabProxy proxy = factory.getProxy();
//Display 'hello world' just like when using the demo
proxy.eval("disp('hello world')");
//Disconnect the proxy from MATLAB
proxy.disconnect();
}
However, i receive an exception which indicates that my matlab is not in a known location. I have produced the exception as below: is there any specific way to configure matlab to fix this problem? Many thanks.
Exception in thread “main” matlabcontrol.MatlabConnectionException: Could not launch MATLAB. This is likely caused by MATLAB not being in a known location or on a known path. MATLAB’s location can be explicitly provided by using matlabcontrol.MatlabProxyFactoryOptions.Builder’s setMatlabLocation(…) method.
OS: Windows 7
Command: [matlab, -r, javaaddpath ‘C:\Users\a\workspace\utadisint\WebContent\WEB-INF\lib\matlabcontrol-4.1.0.jar’; matlabcontrol.MatlabClassLoaderHelper.configureClassLoading(); javarmpath ‘C:\Users\a\workspace\utadisint\WebContent\WEB-INF\lib\matlabcontrol-4.1.0.jar’; matlabcontrol.MatlabConnector.connectFromMatlab(‘PROXY_RECEIVER_3be81980-3680-4cb6-91b3-e365a930d2e8’, 2100);]
Environment: {ProgramData=C:\ProgramData, GECODEDIR=C:\Program Files (x86)\Gecode, TERM=dumb, USERPROFILE=C:\Users\a, PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC, ProgramFiles(x86)=C:\Program Files (x86), SystemDrive=C:, TEMP=C:\Users\a\AppData\Local\Temp, ProgramFiles=C:\Program Files, Path=C:/Program Files/Java/jre6/bin/server;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/amd64;C:\Program Files\Java\jre6\bin;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\DTS\Binn;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Program Files (x86)\Gecode\bin;C:\Program Files\Java\jre6\bin;C:\Users\a\Downloads\eclipse-jee-indigo-SR2-win32-x86_64\eclipse;, HOMEDRIVE=C:, PROCESSOR_REVISION=2a07, USERDOMAIN=B870, ALLUSERSPROFILE=C:\ProgramData, ProgramW6432=C:\Program Files, PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel, SESSIONNAME=Console, TMP=C:\Users\a\AppData\Local\Temp, PROCESSOR_ARCHITECTURE=AMD64, LOGONSERVER=\B870, =::=::, CommonProgramFiles=C:\Program Files\Common Files, OS=Windows_NT, FP_NO_HOST_CHECK=NO, HOMEPATH=\Users\a, PROCESSOR_LEVEL=6, CommonProgramW6432=C:\Program Files\Common Files, LOCALAPPDATA=C:\Users\a\AppData\Local, VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools, COMPUTERNAME=B870, SystemRoot=C:\Windows, windir=C:\Windows, NUMBER_OF_PROCESSORS=4, PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules, PUBLIC=C:\Users\Public, USERNAME=a, CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files, ComSpec=C:\Windows\system32\cmd.exe, APPDATA=C:\Users\a\AppData\Roaming}
at matlabcontrol.RemoteMatlabProxyFactory.createProcess(RemoteMatlabProxyFactory.java:323)
at matlabcontrol.RemoteMatlabProxyFactory.requestProxy(RemoteMatlabProxyFactory.java:125)
at matlabcontrol.RemoteMatlabProxyFactory.getProxy(RemoteMatlabProxyFactory.java:144)
at matlabcontrol.MatlabProxyFactory.getProxy(MatlabProxyFactory.java:81)
at com.example.utadisint.matlabtest.main(matlabtest.java:16)
Caused by: java.io.IOException: Cannot run program “matlab”: CreateProcess error=2, Det går inte att hitta filen
at java.lang.ProcessBuilder.start(Unknown Source)
at matlabcontrol.RemoteMatlabProxyFactory.createProcess(RemoteMatlabProxyFactory.java:303)
… 4 more
Caused by: java.io.IOException: CreateProcess error=2, Det går inte att hitta filen
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
… 6 more