[Top] [Prev] [Next] [Bottom] [Contents]

Sapphire/Web and your Applet

Now you have seen the Java applet that we have supplied, pre-compiled, in the tutorials Java subdirectory of your installation. The next thing to do is to create a new Sapphire/Web project and incorporate the applet into it.

1. Start Sapphire/Web and create a new project, called JavaT1.

Figure 2-1 New Project window

2. Open the Document Manager and create a new HTML document. Use home.html as the file name. Click Style and choose default.html for the template.

3. When the editor is started with home.html, change it to the following:

<HTML>
<HEAD><TITLE>Java Example 1</TITLE></HEAD>
<BODY>
<applet code = 	"HelloWorld.class"
				codebase="/saclasses/tutorials"
				width=400
				height=300>
</applet>
<BR>
Press <A HREF="PageTwo">here</A> for Page Two !
</BODY>
</HTML>
4. Save your work and close your editor.

5. Make sure that your Java class HelloWorld.class is located in htmlroot/saclasses/tutorials. If it is not, the browser will be looking in the wrong place for the Java applet and you'll just get a message saying "applet not found."

6. Create an HTML document called end.html.

7. Use a NULL binding to link home.html and end.html.

Figure 2-2 The NULL binding

Without a binding in the project, Sapphire/Web will not create any code and you will get an error message

8. Test your project. You should see a browser display like this.

Figure 2-3 The HelloWorld applet at work

The grey area is the 400 x 300 pixel area that you reserved for your applet's operation within the HTML display space, and you can see what was drawn on the screen in red.

You can play around with the parameters to alter the size of the area allocated to the applet, and change the paths to see how you can change the location of the applet. If you have the Java Development Kit (JDK), you can change the applet itself to see how the browser handles an applet's output.

Troubleshooting

Now is the time to be sure that your applets are where you think they are. If HelloWorld.class did not load correctly, it is probably because the codebase part of your <applet> statement does not accurately describe the location of your applets.

HelloWorld.class should be located in the directory htmlroot/saclasses/tutorials , where htmlroot is your Web server root. Your first step is to make sure that HelloWorld.class is truly in this directory. If it is in the correct directory and your browser still can't find it, you may need to give your server a more precise description of the location.

In home.html, change the line

codebase="/saclasses/tutorials"

to

codebase="completeurl"

where completeurl is the URL of the directory that contains HelloWorld.class. For example, my codebase statement reads

codebase="http://deiweb/~dei/saclasses/tutorials"

and HelloWorld.class is in the directory

~dei/public_html/saclasses/tutorials.



[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.