Skip to content

Commit f247f7d

Browse files
committed
doc java
1 parent 13b90d2 commit f247f7d

File tree

2 files changed

+59
-42
lines changed

2 files changed

+59
-42
lines changed

Readme.md

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,13 @@ buildtool
1717

1818
[API Documentation](https://geospace-code.github.io/matlab-stdlib)
1919

20-
## Java details
21-
22-
The "matlab-stdlib" package uses Java functions throughout, with the higher-level
23-
[java.nio.Files](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/Files.html)
24-
and the classic
25-
[java.io.File](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/io/File.html) classes.
26-
27-
That is, if Matlab was started with
20+
Many Matlab-Stdlib functions use the factory JRE in Matlab, and have been tested with JVM versions 8 and 17.
21+
For reference, we further
22+
[discuss Java implementation details](./Readme_java.md).
23+
If Matlab was started with
2824
[-nojvm](https://www.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html),
29-
many of the stdlib filesystem function do not work.
30-
31-
Get the JVM version with
32-
33-
```matlab
34-
version("-java")
35-
```
36-
37-
The Matlab default
38-
[JVM can be configured](https://www.mathworks.com/help/matlab/matlab_external/configure-your-system-to-use-java.html)
39-
to
40-
[compatible JRE](https://www.mathworks.com/support/requirements/language-interfaces.html)
41-
across
42-
[Matlab versions](https://www.mathworks.com/support/requirements/openjdk.html)
43-
by using the
44-
[jenv](https://www.mathworks.com/help/matlab/ref/jenv.html)
45-
Matlab function.
46-
47-
For example, to use the [JDK 17 on macOS](https://www.oracle.com/java/technologies/downloads/#jdk17-mac) download and extract the ARM64 Compressed Archive.
48-
Tell Matlab to use this JDK from the Matlab console by:
49-
50-
```matlab
51-
jenv("/path/to/jdk-17/Contents/Home")
52-
```
53-
54-
To
55-
[revert back to the factory JRE](https://www.mathworks.com/help/matlab/ref/matlab_jenv.html)
56-
if Matlab can't start or has problems, from system Terminal do:
57-
58-
```sh
59-
matlab_jenv factory
60-
```
61-
25+
many Matlab-stdlib functions do not work.
6226

63-
Matlab-stdlib has been tested with JVM versions 8 and 17.
6427

6528
## Acknowledgments
6629

Readme_java.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Matlab-Stdlib Java implementation
2+
3+
Matlab has used Java extensively internally for over a decade.
4+
While the "New Desktop" is HTML and JavaScript based, and already other new GUI elements in Matlab were not using Java, the underlying JRE interface is treated at least like other Matlab external languages such as C++ and Python.
5+
Matlab-Stdlib uses only factory JRE classes.
6+
7+
For reference, it is readily possible in general to use non-factory
8+
[Java classes](https://www.mathworks.com/help/matlab/matlab_external/static-path-of-java-class-path.html)
9+
in Matlab.
10+
11+
The Matlab-Stdlib package uses Java functions throughout, including:
12+
13+
* [java.lang.ProcessBuilder](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/ProcessBuilder.html)
14+
* [java.lang.System](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/System.html)
15+
* [java.nio.file](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/Files.html)
16+
* [java.io.File](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/io/File.html)
17+
* [java.net.InetAddress](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/net/InetAddress.html)
18+
* [java.lang.management.ManagementFactory](https://docs.oracle.com/en/java/javase/21/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html)
19+
* [java.security.MessageDigest](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/security/MessageDigest.html)
20+
21+
## Java version
22+
23+
Get the JVM version with
24+
25+
```matlab
26+
version("-java")
27+
```
28+
29+
The Matlab default
30+
[JVM can be configured](https://www.mathworks.com/help/matlab/matlab_external/configure-your-system-to-use-java.html)
31+
to
32+
[compatible JRE](https://www.mathworks.com/support/requirements/language-interfaces.html)
33+
across
34+
[Matlab versions](https://www.mathworks.com/support/requirements/openjdk.html)
35+
by using the
36+
[jenv](https://www.mathworks.com/help/matlab/ref/jenv.html)
37+
Matlab function.
38+
39+
For example, to use the
40+
[JDK 17 on macOS](https://www.oracle.com/java/technologies/downloads/#jdk17-mac)
41+
download and extract the ARM64 Compressed Archive.
42+
Tell Matlab to use this JDK from the Matlab console by:
43+
44+
```matlab
45+
jenv("/path/to/jdk-17/Contents/Home")
46+
```
47+
48+
To
49+
[revert back to the factory JRE](https://www.mathworks.com/help/matlab/ref/matlab_jenv.html)
50+
if Matlab can't start or has problems, from system Terminal do:
51+
52+
```sh
53+
matlab_jenv factory
54+
```

0 commit comments

Comments
 (0)