Skip to content

Commit 4a50fa9

Browse files
committed
add matlab_bin_path()
1 parent 699d4ff commit 4a50fa9

File tree

4 files changed

+43
-19
lines changed

4 files changed

+43
-19
lines changed

+stdlib/matlab_bin_path.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
%% MATLAB_BIN_PATH give binary paths relevant to Matlab Mex and Engine runs
2+
% These can be used with LIBRARY_PATH, LD_LIBRARY_PATH, PATH, etc.
3+
%
4+
% For testing, these can be used with EnvironmentVariableFixture as shown at
5+
% https://github.com/scivision/matlab-buildtool-mex/blob/main/engine/TestEngine.m
6+
7+
function mpaths = matlab_bin_path()
8+
9+
mpaths.arch = computer("arch");
10+
mpaths.root = matlabroot;
11+
12+
mpaths.bin = fullfile(matlabroot, "bin");
13+
14+
mpaths.extern_bin = fullfile(matlabroot, "extern/bin", mpaths.arch);
15+
16+
mpaths.arch_bin = fullfile(mpaths.bin, mpaths.arch);
17+
18+
end

+stdlib/platform_tell.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
'hdf5', stdlib.h5get_version(), ...
1515
'netcdf', stdlib.nc_get_version());
1616

17+
m = stdlib.matlab_bin_path();
18+
raw.matlab_extern_bin = m.extern_bin;
19+
raw.matlab_root = m.root;
20+
raw.matlab_arch_bin = m.arch_bin;
21+
raw.matlab_bin = m.bin;
22+
1723
if stdlib.has_java()
1824
raw.java_vendor = stdlib.java_vendor();
1925
raw.java_version = stdlib.java_version();

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ The
3636
"backend" column tells which functions have selectable backend implementations.
3737
By default, when the "backend" is not specified to a function having selectable backend, the algorithm searches for the first available backend and uses that.
3838
The user can specify the backend as listed in the API for those functions by specifying say "java" etc. as available per-function.
39-
Normally the user will not specify the backend as we prioritize faster backends.
39+
Normally the user does not specify the backend as we prioritize faster backends.
4040

4141
* [.NET](https://www.mathworks.com/help/matlab/call-net-from-matlab.html)
4242
* Windows: all supported Matlab releases
4343
* Linux / macOS: R2024b and newer
44-
* [Java](https://www.mathworks.com/help/matlab/using-java-libraries-in-matlab.html): all supported Matlab releases
44+
* [Java](./Readme_java.md): all supported Matlab releases
4545
* [Perl](https://www.mathworks.com/help/matlab/ref/perl.html): all supported Matlab releases. This uses a system() call to Perl, which is bundled with Matlab on Windows and generally available on Linux and macOS
4646
* [Python](https://www.mathworks.com/help/matlab/call-python-libraries.html): Matlab R2022b and newer
4747
* System shell calls: all supported Matlab releases. As a backup when the platform doesn't have the primary (faster) methods available, the system shell can be called for some functions.

Readme_java.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
# Matlab-Stdlib Java functions
1+
# Using Java in standard library for Matlab
22

3-
Some Matlab-Stdlib functions use the factory JRE, and have been tested with JVM versions 8 and 17 and newer.
3+
Java is not required for this project, but some functions are implemented with an optional Java backend.
4+
They are tested with and should work with Java versions 8, 11, 17, 21, and more.
45

5-
In general, Java's java.io.File() and java.nio.file don't work with Windows App Execution Aliases.
6-
However, Matlab's intrinsic file functions do work with Windows App Execution Aliases.
7-
8-
Matlab's Java interface was
6+
Matlab's
7+
[Java language interface](https://www.mathworks.com/help/matlab/using-java-libraries-in-matlab.html)
8+
was
99
[introduced in Matlab 6.0 R12](http://www.ece.northwestern.edu/local-apps/matlabhelp/base/relnotes/matlab/matlab124.html#20684)
1010
in the year 2000.
11-
Matlab-Stdlib uses only factory JRE classes where intrinsic Matlab code isn't easily capable of provided the needed algorithms.
11+
Our optional Java backend functions use only factory Java class--no third-party Java libraries are used.
12+
13+
## Java backend diagnostic functions
1214

1315
Tell JVM version:
1416

@@ -34,7 +36,14 @@ Get the Java version:
3436
stdlib.java_version()
3537
```
3638

37-
Matlab factory Java version 1.8 is adequate for all Matlab-stdlib functionality.
39+
Tell JVM details:
40+
41+
```matlab
42+
je = jenv
43+
44+
% Tell the JAVA_HOME directory
45+
disp(je.Home)
46+
```
3847

3948
As general information (not used by Matlab-stdlib), non-factory Java classes can be used in
4049
[Matlab](https://www.mathworks.com/help/matlab/matlab_external/static-path-of-java-class-path.html).
@@ -50,15 +59,6 @@ Matlab function.
5059
Matlab vs. Java
5160
[version compatibility table](https://www.mathworks.com/support/requirements/openjdk.html).
5261

53-
Tell JVM details:
54-
55-
```matlab
56-
je = jenv
57-
58-
% Tell the JAVA_HOME directory
59-
disp(je.Home)
60-
```
61-
6262
For example, to use the
6363
[JDK 17 on macOS](https://www.oracle.com/java/technologies/downloads/#jdk17-mac)
6464
download and extract the ARM64 Compressed Archive.

0 commit comments

Comments
 (0)