Chiamata di Java da MATLAB
È possibile accedere a classi Java esistenti da utilizzare nel workspace di MATLAB. Ad esempio, utilizzare i pacchetti di classi incorporate, come java.util
che sono inclusi nel linguaggio Java. Per la descrizione di questi pacchetti, vedere la documentazione del proprio linguaggio Java. È inoltre possibile accedere alle classi definite in singoli file .class
, pacchetti o file di Java Archive (JAR), comprese le classi sviluppate dall’utente.
È possibile eseguire MATLAB con la versione di sistema dell’ambiente di runtime Java (JRE™). Per informazioni sulle versioni Java compatibili con MATLAB, vedere MATLAB Interfaces to Other Languages (Interfacce di MATLAB ad altri linguaggi). Per impostare il percorso di JRE in MATLAB, chiamare jenv
. Per impostare il percorso dal prompt del sistema operativo, chiamare matlab_jenv
.
Se invece si desidera chiamare le funzioni MATLAB dalle applicazioni Java, vedere Chiamata di MATLAB da Java.
Funzioni
isjava | Determine if input is Java object |
javaaddpath | Add entries to dynamic Java class path |
javaArray | Construct Java array object |
javachk | Error message based on Java feature support |
javaclasspath | Return Java class path or specify dynamic path |
javaMethod | Call Java method |
javaMethodEDT | Call Java method from Event Dispatch Thread (EDT) |
javaObject | Call Java constructor |
javaObjectEDT | Call Java constructor on Event Dispatch Thread (EDT) |
javarmpath | Remove entries from dynamic Java class path |
usejava | Determine if Java feature is available |
jenv | Set Java path for MATLAB (Da R2021b) |
matlab_jenv | Set the Java path for MATLAB from system prompt (Da R2021b) |
Oggetti
JavaEnvironment | Java environment information (Da R2023a) |
Classi
matlab.exception.JavaException | Capture error information for Java exception |
Argomenti
Come iniziare
- Get Started with Java Libraries
Requirements for using the MATLAB Java interface. - Configure Your System to Use Java
How to verify you have installed a supported version of Java. - Java Class Path
Bring Java classes into the MATLAB workspace.
Utilizzo delle librerie Java
- Call Java Method
How to call a method in the Java standard library class
java.util.ArrayList
. - Call Method in Your Own Java Class
Use the dynamic class path to develop your own Java classes. - Call Back into MATLAB from Java
How to write Java programs that call into MATLAB from a running MATLAB. - Simplify Java Class Names Using import Function
Use theimport
function to refer to a class by its class name only. - Java Packages to Be Removed
Add Java packages to MATLAB static path.
Array Java
- How MATLAB Represents Java Arrays
How MATLAB interprets the size, shape, and dimension of a Java array.
Oggetti Java
Metodi Java
- Method Information
Getting information about methods.
Risoluzione dei problemi
How to adjust the Java heap size.
Avoid Calling Java main Methods in MATLAB
How MATLAB handles main
methods.