|
"Bastian Ebeling" wrote in message <k5ofts$hpg$1@newscl01ah.mathworks.com>...
> Hi Yair,
>
> thanks - it was new to me, that there is a difference on using static or dynamic classpath. I just learned, that the static one also speeds up the hole thing.
>
> "Yair Altman" wrote in message <k5n25h$e2e$1@newscl01ah.mathworks.com>...
> > ...
> > Bastian - JDBC requires using the static rather than dynamic Java classpath.
> > A detailed description of using JDBC with Matlab is included in section 2.2 of My Matlab-Java programming book: http://undocumentedmatlab.com/matlab-java-book/
> >
> > MathWorks' DB Toolbox also uses the same JDBC driver, which is why they also force users to add it to their static Java classpath.
>
> But now the bad news:
> For deploying an apllication I only found out (unter http://www.mathworks.de/support/solutions/en/data/1-3Q6KZW/index.html?solution=1-3Q6KZW) classes will be automatically added to the dynamic path. I did not find a way to get that into the static path.
> Do you have a solution?
> Greetings
>
> Bastian
You can manually add the classpath.txt file to the "Other files" section when compiling, and/or place this file in the deployed folder. Since classpath.txt does *NOT* accept relative filepaths but only absolute filepaths, this means that you must ensure that in all your deployed environments the relevant JDBC JAR file is located in the same absolute path.
One way to do this dynamically is to place the JAR file in your deployed folder, and add the following pseodo-code to the beginning of your Matlab app:
function varargout = myApp(varargin)
staticPaths = lower(javaclasspath('-static'));
if all(cellfun('isempty',strfind(staticPaths,lower(jarFilename))))
% Not in static classpath, so add it to the classpath and restart the app
deployFolder = fileparts(mfilename('fullpath'));
fid = fopen('classpath.txt','at')
fprintf(fid,'%s/%s\n',deployFolder,jarFilename);
fclose(fid);
[varargout{:}] = myApp(varargin{:});
exit;
end
% continue with the regular processing...
end
More information about this and other Matlab-Java topics can be found in my website and my Matlab-Java programming book.
Yair Altman
http://UndocumentedMatlab.com
|