The java::call Command


Usage:

java::call ?-noconvert? class signature ?arg arg ...?

The java::call command is used to invoke accessible static methods on Java classes from Tcl code. The class argument specifies the name of the declaring class of the method to invoke. The signature argument specifies which class method to invoke. Signatures are covered in the Signatures section.

Additional parameters to the java::call command are converted to Java objects or primitive Java types before being passed to the Java method. The Conversions section describes the result and possible error conditions of the java::call command, including the effect of the optional -noconvert flag.

Example:

A Java method can be invoked directly from Tcl code using the java::call command. In this example, the static method toBinaryString(int) in the class java.lang.Integer is invoked from Tcl.
# Call the method java.lang.Integer.toBinaryString(int)
set string [java::call Integer toBinaryString 5]

# This will print "result is 101", the binary representation of 5
puts "result is $string"

Copyright © 1997-1998 Sun Microsystems, Inc.