Try the following:
jarDirectory = 'C:\Temp\httpcomponents-client-4.1.1\lib';
dirResult = dir([jarDirectory, filesep, '*.jar']);
jars = cellfun( @(name)fullfile(jarDirectory, name), ...
{dirResult.name}, 'UniformOutput', false );
javaaddpath( jars );
javaclasspath('-dynamic')
httpclient = org.apache.http.impl.client.DefaultHttpClient()
Since the classes are added to the dynamic classpath, it is not persisted between restarts of MATLAB.
1 Comment
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/5892-use-java-classes-in-matlab#comment_12150
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/5892-use-java-classes-in-matlab#comment_12150
Sign in to comment.