JIMS — Java Interaction Mechanism in Scilab

JIMS — Java Interaction Mechanism in Scilab

The Java Interaction Mechanism in Scilab (JIMS) provides a native-level interface between the two Virtual Machines.
It gives Scilab programs full access to Java class libraries, allowing them to load and manage complex and advanced Java objects using Scilab's classical data types.

This toolbox is released under CeCILL license:


A first example to display a puffin in a JFrame

//Swing test
jimport java.awt.BorderLayout;
jimport java.net.URL;
jimport javax.imageio.ImageIO;
jimport javax.swing.ImageIcon;
jimport javax.swing.JFrame;
jimport javax.swing.JLabel;

url = URL.new("http://www.scilab.org/var/ezwebin_site/storage/images/media/images/puffin/1948-1-eng-GB/puffin.png");
image = ImageIO.read(url);

frame = JFrame.new();
icon = ImageIcon.new(image);
label = JLabel.new(icon);
pane = frame.getContentPane();
pane.add(label, BorderLayout.CENTER);

jremove frame icon label pane url image BorderLayout URL ImageIO ImageIcon JFrame JLabel

The command jimport java.net.URL will create a variable named URL on the stack, to avoid conflicts with a variable already named URL, you could use the syntax:

myurlclass = jimport("java.net.URL", %f);
url = myurlclass.new("http://www.scilab.org");

Create a new instance or invoke a method can be done with the commands jnewInstance and jinvoke:

url = jnewInstance("java.net.URL", "http://www.scilab.org");
forge = jnewInstance(myurlclass, "http://forge.scilab.org");
protocol = jinvoke(url, "getProtocol")
eq = jinvoke(url, "equals", forge)

Powered by InDefero,
a Céondo Ltd initiative.