javac FilledBox.java
Here are a few tips that may help you get started. First, applet classes must always be declared public or they will not get compiled. Also, remember that Java is case-sensitive; Filledbox.java is not the same as FilledBox.java and will not be compiled.
If the Java code is acceptable to the compiler, the only message you will see is about a deprecated API:
Note: FilledBox.java uses a deprecated API. Recompile with "-deprecation" for details. 1 warning.
For now ignore the warning. As long as there were no error messages, the file FilledBox.class will be created. If there were error messages, you need to go back and fix your code. There are many different types of error messages that the compiler may generate when given a source file. The simplest to fix are syntax errors, such as a missing semicolon or closing brace. Other messages will highlight incorrect use of variable types, invalid expressions, or violation access restrictions.
Getting your source code to compile is only the first part of the debugging process; error-free compilation does not guarantee that your program will do what you want.
Creating an HTML file to host your applet
<HTML> <HEAD> <TITLE>Sample HTML Document With Filled Box</TITLE> </HEAD> <BODY> <H1>FilledBox Demo</H1> <P> <APPLET CODE="FilledBox.class" WIDTH=50 HEIGHT=50> <PARAM NAME=color VALUE="red"></APPLET> </BODY> </HTML> You can create this file by simply typing it into a text editor. Save the file as FilledBox.html. HTML files can be named anything you like, although it is common practice to name them after the applets they host.
No comments:
Post a Comment