We
are all still learning the JBuilder compiler, and all getting a bit
frustrated. As an alternative to
JBuilder...
You
can type your code into any editor (notepad, Word, even JBuilder), but compile
with the javac command line compiler.
If you have JBuilder, you have this compiler too. This saves you from creating a big JBuilder
project, then package, then applet, which creates many directories and files
that seem very confusing. This way, you’ll
have a .java file, a .html file and a .class file when you’re done. Here goes...
Go
to a DOS window (go in the Start menu and in Programs, pick MS-DOS
prompt). In this window, change the
current directory to that of your javac compiler, probably in JBuilder35\jdk1.2.2\bin. From this command prompt, you can type
javac
c:\cop2253\assignment1\assignment1.java
where
your assignment1 source code is saved in
c:\cop2253\assignment1\assignment1.java.
This will compile the file and return any errors, or just return the command
prompt if there are none, and create an assignment1.class file (the bytecode).
Now
to create an HTML file...
In
another blank file in any text editor, type the following:
<HTML>
<HEAD>
</HEAD>
<BODY>
<APPLET
CODE = "Assignment1.class" WIDTH = 400 HEIGHT = 300>
</APPLET>
</BODY>
</HTML>
where
the only line that will change is the name of your class file, as needed.
If
you put all 3 of these files in one directory (such as a c:\cop2253\assignment1
directory), you should now be able to open your assignment1.html file in any
browser and see your applet go!