LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
jmtGetPath.m
1function jmtPath = jmtGetPath
2% JMTPATH = JMTGETPATH
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7% Get path to common folder
8% This function is at dev/src/solvers/JMT/jmtGetPath.m
9% Navigate up to the line-dev.git root directory
10current_dir = fileparts(mfilename('fullpath')); % dev/src/solvers/JMT
11root_dir = fileparts(fileparts(fileparts(fileparts(current_dir)))); % line-dev.git
12common_dir = fullfile(root_dir, 'common');
13jmt_jar = fullfile(common_dir, 'JMT.jar');
14
15if exist(jmt_jar, 'file')
16 jmtPath = common_dir;
17else
18 line_printf('\nJava Modelling Tools cannot be found. LINE will try to download the latest JMT version (download approx. 50MB).\n')
19 m='Y';
20 if m=='Y'
21 try
22 line_printf('\nDownload started, please wait - this may take several minutes.')
23 if exist('websave')==2
24 % Check if file exists but is locked/permission issue
25 if exist(jmt_jar, 'file')
26 fprintf('JMT.jar already exists at %s, attempting to use existing file.\n', jmt_jar);
27 jmtPath = common_dir;
28 return;
29 end
30
31 % Ensure common directory exists
32 if ~exist(common_dir, 'dir')
33 mkdir(common_dir);
34 end
35
36 jmt_url = 'https://line-solver.sourceforge.net/latest/JMT.jar';
37 outfilename = websave(jmt_jar, jmt_url);
38 line_printf('\nDownload completed. JMT jar now located at: %s',outfilename);
39 else
40 line_error(mfilename,'The MATLAB version is too old and JMT cannot be downloaded automatically. Please download https://line-solver.sourceforge.net/latest/JMT.jar and put it in the common folder.');
41 end
42 jmtPath = common_dir;
43 catch ME
44 if exist(jmt_jar, 'file')
45 delete(jmt_jar);
46 end
47 error_msg = sprintf('Failed to download JMT: %s\nPlease manually download https://line-solver.sourceforge.net/latest/JMT.jar and place it in %s', ME.message, common_dir);
48 line_error(mfilename, error_msg);
49 end
50 else
51 error_msg = sprintf('Java Modelling Tools was not found. Please download https://line-solver.sourceforge.net/latest/JMT.jar and put it in %s\n', common_dir);
52 line_error(mfilename, error_msg);
53 end
54end
55end