Java in Brainstorm

Author: Martin Cousineau

Java is a multi-platform and object-oriented programming language. Matlab supports its execution in order to facilitate writing more complex graphical user interfaces and applications.

Java version

You have to keep in mind that not every Matlab versions ship with the same version of the Java Virtual Machine (JVM). See this Wikipedia page for specific JVM versions for each release of Matlab. With the general objective of supporting older Matlab versions (2008 to today), we need therefore to support Java 6 to 8.

Java repository

The main Brainstorm repository only ships with a compiled JAR file as the raw Java code is not of use to regular users. To access to the raw Java code used by Brainstorm, refer to this repository:

It also includes the necessary project files to open the repository as a project in the popular Java IDE Netbeans which we recommend for writing and testing your Java code.

Pushing your changes to Matlab

Once you are satisfied with and tested your changes in your Java IDE, you need to push your changes to MATLAB.

Calling Java functions in Matlab

Calling Java functions is extremely easy from Matlab, as documented here on the official Mathworks website.


import org.brainstorm.dialogs.HotkeyDialog;
import org.brainstorm.dialogs.*;

dialog = HotkeyDialog(12);
res = dialog.getKey();

Creating Java Swing elements for GUIs

To create Java objects for GUIs, Brainstorm already has wrappers in place to simplify and harmonize the process accross the program. Refer to the gui_component() function to do this. Also, have a look at the CreatePanel() function of any panel_ file to see examples of creating Swing GUI elements in Matlab.

Java (last edited 2019-02-11 19:03:06 by ?MartinCousineau)