Essentially there three ways to (re)use Java code in Smalltalk/X:
Implement / port bindings to Java using JNI as Victor suggested. While not
ported to Smalltalk/X, this has been done by Johan Brichau et al. -
search for "JavaConnect",
then there is a "Java Bridge" to connect to remote JVM and execute code there,
developed and used by eXept in their products. AFAIK, this is a proprietary
package - you may be able to purchase a license for it (or not). For details,
you may want to ask eXept.
and finally, there's the stx:libjava which is a Smalltalk/X API to load Java
classes directly into running Smalltalk/X runtime.
Each of these options have their own pros and cons, as usual. I'm going to
focus on the last one - stx:libjava - this is the one @tukan had in mind.
stx:libjava
Disclaimer: I (re)designed and (re)implemented most of stx:libjava so take
my views with grain of salt as I'm biased.
stx:libjava is a package that allows loading Java code into Smalltalk/X
environment and execute it. Once loaded, there's no difference between Java
code and Java objects and Smalltalk code and Smalltalk objects - they both live
in the same runtime (virtual machine if you prefer). In fact, most of the
runtime does not know (and does not care) whether given object or method is
actually a Smalltalk or Java one. There are only two components inside the runtime
that distinguish - that's a bytecode interpreter (since Smalltalk/X bytecode is
very different from Java bytecode) and JIT-compiler frontend (for the very same
reason). Because of that there's no difference performance-wise between executing
Smalltalk or Java code.
Simple Example
Here's an example of using SAXON XSLT processor implemented in Java from
Smalltalk/X:
[
config := JAVA net sf saxon Configuration new.
config setAllNodesUntyped: true.
factory := JAVA net sf saxon TransformerFactoryImpl new: config.
stylesheet := factory newTemplates:
(JAVA javax xml transform stream StreamSource new:
(JAVA java io File new: 'cd.xsl')).
input :=
(JAVA javax xml transform stream StreamSource new:
(JAVA java io File new: 'cd.xml')).
output :=
(JAVA javax xml transform stream StreamResult new:
(JAVA java io File new: 'cd.html')).
transformer := stylesheet newTransformer.
transformer transform: input to: output.
] on: JAVA java io IOException do:[:ex|
Transcript showCR:'I/O error: ', ex getMessage.
ex printStackTrace.
] on: JAVA javax xml transform TransformerException do:[:ex|
Transcript showCR:'Transform error: ', ex getMessage.
ex printStackTrace.
].
Further references
Following resources may give you better idea what is it about: