Creating a Simple Java Applet
with Symantic Cafe
1. From the Symantic Cafe main menu, select Project/New.
2. The ProjectExpress dialog box will appear.
-
Enter a project name (for example, "simple.prj"). Note, first create
a directory to hold the project. for bookkeeping purposes. You can
do this by selecting the New Directory button. It is
recommended that you use the same name for the directory and project. Select
Next>.
-
Set project type. Check option Release and keep the other options
shown to create an Applet.
-
Select Finish. This closes the ProjectExpress dialog and
you are ready to work on your new project.
3. In the Cafe desktop you should see three windows: the Project window,
the Source window text editor, and the Output window. When
you have completed the Project Express you should see the folder
simple.prj
in the Project window.
4. Write the source code for the Java applet. In the Source window text
editor enter the following code (open a new Source window by selecting
File/New):
5. When finished, select File/SaveAs and save the code as the file
simple.java
in your simple project folder. YOUR FILE NAME MUST BE THE
SAME AS THE CLASS NAME FOR THE JAVA APPLET. It is case
sensitive. Note, select the File menu on the Source window
text editor.
6. Add your Java source code file to the project. Select File/Add
to Project. You should now see this file listed in the Project
window.
7. Create a simple HTML file to view the applet. Select File/New
which opens another Source window text editor. Enter the following
code and save it as simple.html:
<HTML>
<HEAD>
<TITLE>A simple program</TITLE>
</HEAD><BODY>
<APPLET CODE="simple.class" WIDTH=283 HEIGHT=190></APPLET>
</BODY>
</HTML>
Add this file to the project by selecting File/Add to Project. This
file should also appear in the project window.
8. Compile the project. Select Project/Rebuild All. (Note, if
you are making changes to an already compiled project, you can just select
Build.)
9. The Output window displays any errors that occur in compilation.
If everything is OK you should see the message "Successful build."
10. Execute the applet by invoking the applet viewer. Select Project/Execute
Program.
11. When the applet runs successfully you are ready to include the compiled
version (simple.class) in your web page. Be sure to copy the
.class
and
.java files to your home page directory.
RETURN.
Modified 10-6-98. RSL