Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - English


Invoke a method of a Java object


ret = jinvoke(object, methodName [, arg_1 [, arg_2...]])



A mlist typed _JObj or _JClass or a Scilab variable


A string giving the method name


A Scilab variable as method argument


Invoke the Java method (static or not) called methodName of the given object. The result is returned as a mlist typed _JObj.

The polymorphism is handled in using Java Reflection and the autoboxing is handled too so ArrayList.add(1.234) or ArrayList.add("Hello") are allowed. If it exists a method, it is possible to write even if 123 is a Scilab double but, if it exists, will be chosen.


jimport java.lang.System;
jimport java.awt.Color;
jimport java.lang.String;

// Non-static methods
jinvoke("Hello World !!", "length");
str ="Hello");
jinvoke(str,"substring",1, 4)

// Static method
T = jinvoke(System, "getProperty", "java.version");

// Combine
c = jinvoke(Color, "decode", "123456");
cb = jinvoke(c, "brighter");

jcode = jinvoke(cb, "getRGB");

jremove System Color String str T c cb jcode;

See also

  • jautoUnwrap — Unwrap automatically returned values
  • jinvoke_db — Invoke a method of a Java object in using Java direct buffers


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
<< jimport Java from Scilab jinvoke_db >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Mar 07 09:29:08 CET 2023