|
Using Jikes and the Microsoft VM
As all of you know, installing and configuring
the Java Development Kit is difficult and time consuming, whether you use
the Sun, IBM, or even the Microsoft version. Wouldn't it be nice if there
was a way to download a "JDK lite", that was smaller and easier to install?
Well, how would you like a complete JDK that consists of three files, weighing
less than 800K? Impossible, you say? Well, if you're running Windows and
MS Internet Explorer, maybe not.
In the past week, I've been trying this technique out, and it seems
to work. The only requirements are that you have a recent MS Java Virtual
Machine, like the one you get with Internet Explorer 4 and up.
Here are the three easy steps to follow to see if it will work for you:
-
Check and configure your Microsoft Virtual Machine.
-
Download and place the the three files jikes.exe, Sc1.exe,
and SciTEGlobal.properties in your Windows directory.
-
Test your application.
Step 1: Check the MSJVM
The Microsoft Java Virtual Machine [MSJVM]
is usually installed when you install Microsoft Internet Explorer. The
first step in this process is to make sure you have the MSJVM installed.
Once that's finished, you must tell Windows to create the classes.zip file
you'll need to use the jikes compiler.
Here are the necessary incantations:
A. Is MSJVM Installed?
Start an "MS-DOS Prompt". In Windows 95/98/NT, you can do that from the
Start button as shown here. In Windows ME and Windows 2000 they renamed
the MS DOS Prompt the "Command Window", and moved it to the Accessories
menu.
At the command prompt type jview, and press the Enter key.
If you see the message "Bad command or filename" then you don't have the
MS VM installed, and you can't go any further. Click
here to download the current MSVM from Microsoft. If you see a list
of jview options, as shown here,
then you are ready for the next step--creating the classes.zip file
required by your Java compiler.
B. Creating the Classes
To do this, type clspack -auto at the command prompt and press the
Enter
key.
The clspack program will build a copy of classes.zip and
place it in your C:\Windows\java\classes directory. [On Windows
NT and 2K, it will be placed in the C:\WINNT\System32\java\classes
directory instead.] While clspack is creating the file it will display
a progress dialog that looks like this:
Step 2: Install the Compiler
and Editor
If all has gone well, then copy the three files
jikes.exe [520K], Sc1.exe
[158K], and SciTEGlobal.properties
[3K] into your C:\Windows directory. [With Windows NT and
Windows 2000, you should copy the files to the C:\WINNT\System32
directory instead.]
A. Drag the Shortcut
Once the files are safely downloaded, use Windows Explorer to drag Sc1.exe
to the desktop. This creates a shortcut as shown here:
B. Change the Name
When the shortcut appears on the desktop, you probably want to change its
name.
C. Working Directory
Once that's done, right-click the icon, and choose Properties from
the menu.
When the Jikes Properties dialog appears, change the "Start In"
directory to the directory where you keep your Java source code. In the
illustration, I've change it from C:\Windows to C:\MyFiles.
[You must make sure that the directory exists, though!]
Step 3: Try It Out
It's always a good idea to spend a few minutes
testing your installation. Let's go through each part step by step.
A. The Working Directory
Double-click your new desktop icon, and let's make sure the working directory
is set correctly. Choose Open from the File menu. You should
be shown a list of files in your working directory, (the
directory where you keep your source code files), as shown here:

If, instead of your working directory, you see the Windows directory, go
back to Step 2C and make sure the Jikes Properties Start In field is correctly
filled out. If you enter the name of a non-existent directory, for instance,
your entry will be ignored.
B. Creating a Java Application
Create a new Java application using the text shown here. Save your file
as FirstApp.java. [Click here to download FirstApp.java.]
You use the New, Open, and Save toolbar icons just
like you would with any Windows editor, or you can use the menu instead.

C. Compiling
Once you've entered and saved FirstApp.java, choose Compile
from the Tools menu, or press Ctrl+F7, and the editor will
launch the jikes compiler.

At the bottom of the editor window you'll see the command-line that is
passed to jikes. This command-line is designed to work with Windows
95/98. You'll have to change it to work with Windows NT or Windows 2000.
If you are using one of those operating systems, skip ahead to Section
H. Properties, and make the necessary changes.

If all went well, you'll see an exit code of 0 printed. That means your
code had no syntax errors.
D. Running
You can run Java applications from within the editor by choosing Go
from the Tools menu, or by pressing F5. The editor is set
to run console mode applications that produce output. If you want to launch
GUI applications [not applets], then make changes to the editor's properties
file as detailed in Section H.

The output will appear in the same window used by your compiler messages.
The blue output is produced by the editor, and the black output is produced
by your program.

A word of warning, however. You cannot run console-mode programs
that expect input from the keyboard in this way. The program will appear
to hang, but you won't be given an input window where you can supply the
necessary information. When this occurs, you can select Stop Executing
from the Tools menu or press Ctrl+Break.
If you want to run console-mode applications that take input from the
keyboard, you'll need to start them from the command-line as detailed in
Section G.
E. Syntax Errors
Syntax errors are inevitable. The jikes compiler will give you fairly
good error messages, and the Sc1 editor will help you out by showing
you where your errors occur. Let's see how that works by changing
the public in FirstApp.java to Public, as shown below.
When you compile your code, Sc1 will display the error message
from jikes in the compile window at the bottom of the screen. When
you double-click one of the error messages, Sc1 will place your
cursor on the offending line, as you can see.

F. Applets
You can write and compile applets as well as applications
using the Sc1 editor. You can also automatically launch the appletviewer
to display your applet as well. Start by entering the code for FirstApplet.java
as shown here. [Click here if you want to download
FirstApplet.java instead.]

Next, create a separate HTML file to display the applet. A minimal HTML
file, like that shown here should suffice.
<applet code=FirstApplet.class width=200 height=100>
</applet>

Once you've saved your file, while FirstApplet.html is still selected,
open the Tools menu. You should see the Appletviewer appear on the menu
as shown here.

Selecting Appletviewer from the Tools menu, or pressing Ctrl+0
[Control + zero], will launch Microsoft's version of the appletviewer
program. It also launches Jview in a separate command-window to start up
the appletviewer as well.

G. The Command Line
Sometimes, you might want to run a command-line program that requires input
from the keyboard, or you might want to run an application or applet without
starting up the Sc1 editor. To do this, open any MS-DOS Prompt and
use Microsoft's jview command.
Here's an example that runs the FirstApp application from the
command-line:
C:\MyFiles> jview FirstApp
Here's an example that runs the FirstApplet applet from the command-line:
C:\MyFiles> jview /a FirstApplet.html
Here's a picture of both application and applet running together.

Compiling your programs from the command-line is a little more difficult,
however. You will need to set the CLASSPATH environmental variable
or use the same incantation used by the Sc1 editor to compile your
code. [Of course, you can always put that incantation in a batch file,
and then use the batch file to compile your code.]
H. Changing Properties
The Sc1 editor uses the file SciTEGlobal.properties which
you placed in your C:\Windows directory to control many of its operations.
You can open the file by selection Open Global Options File from
the Options menu.

I've placed various notes at the beginning of the initializtion file showing
the different things you might want to change. The Sc1 editor is
extremely configurable, however. If you want a more complete listing of
your available options, you can click
here to read the Sc1 docs online.

Let Me Know
I have a limited number of systems to test this information on. If you've
tried this on different versions of Windows [NT, ME, 2000], let me know
about your experiences. If you had to make changes, send me a screenshot
of what you needed to do. [To make screenshots, just press Alt+PrintScreen
and then paste the resulting image into a WordPad document.]
For those of you who are interested
Materials
on this web site © 1995-2001,
Stephen
Gilbert. All rights reserved.
Any materials may be reproduced
for non-profit purposes so long as
(1) this notice remains intact
and (2) you notify me of your use.
|