Javaaddpath to files not in Java folder

6 ビュー (過去 30 日間)
Anke Kügler
Anke Kügler 2016 年 5 月 20 日
回答済み: Elias Gule 2016 年 5 月 20 日
Hi,
I need to add several java files (POI library) in order for my code to work. If I do
javaaddpath('poi_library/poi-3.8-20120326.jar');
with the files being in the java folder in Matlab, it works perfectly fine.
However, I would like to keep the library close to my code, as I need to send it to other people eventually and it seems easier to have it with the code than have people need to copy everything to the java folder.
However, if I specify the path within my folder, it returns an "Invalid file or directoy" warning. It does show the correct path, though.
javaaddpath('folder_name/poi_library/poi-3.8-20120326.jar');
Warning: Invalid file or directory
'/Users/Anke/Documents/MATLAB/folder_name/poi_library/poi-3.8-20120326.jar'.
Does the javaaddpath only work with files in the MATLAB java folder or what am I doing wrong?
Thank you very much.
Anke

回答 (1 件)

Elias Gule
Elias Gule 2016 年 5 月 20 日
Try supplying the full filepath to the javaaddpath function. Something like
poi_dir = "C:/JavaLibs";
poi_lib = "poi_library/poi-3.8-20120326.jar";
javaaddpath(fullfile(poi_dir,poi_lib));

カテゴリ

Help Center および File ExchangeCall Java from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by