Java Support

The Smalltalk/X Unified Virtual Machine

Table of Contents

1. Installation & Configuration
1.1. Loading Java support
1.2. Configuring Java
1.3. Initializing Java
2. Hello World!
2.1. Implementing the "Hello World!"
2.2. Commiting project
2.3. Loading Hello World package
2.4. Topics not covered
3. Programming with Java
3.1. Structure of the mixed Smalltalk/Java package
4. Tools
5. Legal Info


The Smalltalk/X virtual machine (runtime system) allows for Java code to be executed within the Smalltalk environment. This integration is virtually seamless - from a programmers point of view, there is no difference between a Smalltalk object and a Java object. Java classes inherit from Object - much like most other Smalltalk classes. This allows for Java classes to be loaded into the system and used in the same way as Smalltalk classes, giving Smalltalk/X user access to vast amount of Java libraries.

1. Installation & Configuration


1.1. Loading Java support

STX:LIBJAVA is a part of Smalltalk/X. To load it into a Smalltalk/X environment, execute following:

Smalltalk loadPackage: #'stx:libjava'.
Smalltalk loadPackage: #'stx:libjava/tools'.

1.2. Configuring Java

1.3. Initializing Java

Before any user Java code can be loaded and executed, the STX:LIBJAVA has to be initialized. During the initialization, basic classes are loaded and initialized - such as java.lang.Object , java.lang.String . To initializa Java in running Smalltalk/X, execute:

JavaVM boot.

You may later shutdown or reboot Java by:

JavaVM shutdown.
JavaVM reboot.


During shutdown, all pure-Java threads are uncoditionally terminated and Java classes are unloaded. This may have funny consequences, especially when a Smalltalk thread is actually executing a Java code and it may be manifested in weird way. The shutdown is here mainly for development purposes - in an application, you shouldn't do a Java shutdown. If you do, result is undefined.