;; These are legal and equivalent (call ?vector addElement (new java.lang.String "Foo")) (?vector addElement (new java.lang.String "Foo"))call may not be omitted if the object comes from the return value of another function call:
;; This is illegal ((new java.lang.Vector 10) addElement (new java.lang.String "Foo"))
(import java.io.*)or a single class using
(import java.awt.Button)After that, all functions that can accept a Java class name (new, defclass, call, etc) will refer to the import list to try to find the class that goes with a specific name. Note that java.lang.* is now implicitly imported.
(try (open NoSuchFile.txt r) catch (printout t (call ?ERROR toString) crlf))prints
Rete Exception in routine _open::call. Message: I/O Exception java.io.FileNotFoundException: NoSuchFile.txt.An empty catch block is fine. It just signifies ignoring possible errors. The code in the finally block, if present, is executed after all try and/or catch code has executed, immediately before the try function returns.