That would be because you are reading a
Java tutorial and not
Javascript. They are different languages. That said you can access Java classes via Javascript; Javascript was originally created as a way to control Java applets within a web browser. In other words to "script" Java applets -> Javascript...
Anyways if you want to use actual Java you need to build it as a plugin. If you want to use Javascript (which #jsread is for) you can build it similar to the following example.
Note: The biggest difference is in Javascript you have to use to complete class name including package when referencing Java classes. Ex, javax.swing.JFrame where as in Java you would use an
import statement.
Here's a javascript function to create a frame based on your tutorial source.
function createFrame() {
var myFrame = javax.swing.JFrame("Example Frame");
var myLabel = javax.swing.JLabel("Hello, world.");
// Do not use EXIT_ON_CLOSE unless you want UMC to exit completely!
myFrame.setDefaultCloseOperation( javax.swing.WindowConstants.DISPOSE_ON_CLOSE );
myFrame.getContentPane().add(myLabel, java.awt.BorderLayout.CENTER);
myFrame.pack();
myFrame.setVisible(true);
}
After loading that using #jsread you can then call the Javascript function using
#script createFrame()