It was mentioned in comments on another Stackoverflow question that it may be possible to access Java packages from Smalltalk.
However, I have not been able to find any information regarding this on searching the net.
Any insight in this regard will be highly appreciated.
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.
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.
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.
].
Following resources may give you better idea what is it about:
On the integration of Smalltalk and Java https://www.sciencedirect.com/science/article/pii/S0167642313002839?via%3Dihub
Towards a Runtime Code Update in Java - an exploration using STX:LIBJAVA https://pdfs.semanticscholar.org/d7da/968e4ab36d6deca51bd45b9bbb70e73a2afd.pdf?_ga=2.80940304.648336672.1556837288-1980277485.1556837288
A quick tour showing how to develop a simple "Hello World!" application using Smalltalk/X and Java http://swing.fit.cvut.cz/projects/stx/doc/online/english/programming/java-helloworld.html
Dynamic Code Update In STX:LIBJAVA https://www.youtube.com/watch?v=p3J554BNEz8
Having Fun With Java https://youtu.be/p21z3bAt7b0