Where are javac, java, and the appletviewer executables located on the university UNIX system?
There are several versions of the Java Development Kit (Java from Sun) on-line. For this class, I recommend using Java 1.1 which can be found in: /usr/local/jdk1.1.6/bin. To change your UNIX environment so that these files are always available add the following line to the end of your .cshrc file: setenv PATH /usr/local/jdk1.1.6/bin:$PATH
How do I compile a program
How do I run a Java program?
There are two cases. If your program is not an applet, just run the file using java. In the above example you could run the program Foo by typing java Foo. If your program is an applet, you must create an HTML (Hypertext Markup Language) file that refers to your applet. Then you can simply view the HTML file using appletviewer, or other web browser software.
When running a Java program I get a NULL pointer exception. What is going on?
When compiling some code, I get a warning from the compiler about some "deprecated" methods. The code appears to run fine otherwise. What is going on?
What is an infinate loop?
Simply put, an infinate loop is a for, while, or do-while loop that never terminates. The test that controls such a loop is always returning true, so the loop never exits and gets on with the rest of the program.
Why is 5/9 zero?
Java, (like C and C++) truncates integer division unless you use an explicit cast operator. Dividing 5 by 9 is something like 0.55, which gets truncated to 0. Similiarly 9/5 is 1. 9 divided by 5 is 1.8, which as an integer gets truncated to 1. If you wanted a floating point expression instead, you could write ((float) 5 / (float) 9).
When should a method be a static method?
A static method (like Math.sqrt(double)) is a method that only makes use of input arguments and does not refer to any class instance variables. You should use static methods when the return value of the method is only a function of the input arguments, and not otherwise.
Can I run applets in Netscape and Internet Explorer if my code is using Java 1.1 features?
It depends on the release of your browser. Until about May of 1998, no browsers supported Java 1.1. Netscape 4.05 and greater does and the latest version of IE should as well. Another way to run Applets with Java 1.1 code is by using the appletviewer program that comes with the JDK.
How do I print the output of my applet?
The easiest thing to do is probably use a screen capture utility to grab an image which may be printed out.
Can my Applet read from or write to a file?
Yes and No. Normally, applets may not read and write from a file. If you want people to be able to run your applet anywhere on the Internet, the answer is no. However, it is possible to have digitially signed applets, where surfers can elect to override their browser's normal security policy and permit your applet to do certain things (like accessing files).
Feel free to send me suggestions of other topics for this file.