- Справка Scilab
- Java из Scilab
- Getting started - Beginning
- Getting started - Second step
- jallowClassReloading
- jarray
- jautoTranspose
- jautoUnwrap
- jcast
- jcompile
- jcreatejar
- jdeff
- jdisableTrace
- jenableTrace
- jexists
- jgetclassname
- jgetfield
- jgetfields
- jgetinfo
- jgetmethods
- jimport
- jinvoke
- jinvoke_db
- jnewInstance
- jnull
- jremove
- jsetfield
- junwrap
- junwraprem
- jvoid
- jwrap
- jwrapinchar
- jwrapinfloat
- new
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
jimport
Import a Java class
Syntax
jimport(className) cl = jimport(className, isAClassReturned)
Parameters
- className
A string giving the class name
- isAClassReturned
A boolean to indicate if a class object must be returned
Description
The class must be in the classpath (to add a package or a directory in the Java classpath, just use javaclasspath).
When jimport("java.lang.String")
, a mlist named String is created on the Scilab stack. The created mlist has a type equal to _JClass and can be used to instantiate new objects in using something like str = String.new("A Scilab String");
. It is possible to call the static methods (if exist) of the class
To avoid confusion with already existing Scilab variables, the second argument isAClassReturned can be used
String = "Hello"; foo = jimport("java.lang.String", %f); obj = foo.new("A string...") jremove(obj);
A class can be reloaded if it is allowed by the function jallowReloadClass
.
Examples
jimport javax.swing.JFrame; jimport javax.swing.JLabel; jframe = JFrame.new("Hello World !! Window"); jlabel = JLabel.new("A JLabel containing ""Hello World"""); cp = jframe.getContentPane(); cp.add(jlabel); jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); jframe.pack(); jframe.setVisible(%t); jremove jlabel cp jframe;
See also
- javaclasspath — set and get dynamic Java class path
- jallowClassReloading — Allow the class reloading
- jremove — Remove a Java Object on the Java side
History
Версия | Описание |
5.5.0 | Function introduced. Based on the 'JIMS' module. The main difference in the behavior compared to the JIMS module is that jautoUnwrap is enabled by default. |
Report an issue | ||
<< jgetmethods | Java из Scilab | jinvoke >> |