Simulation, Modeling, and Monte Carlo Methods in Archaeology

Keith Kintigh

Getting Started with Java

Installing Java on Your Own Computer

According to Sun Microsystems, you need:

"The Java 2 SDK is intended for use on Windows 95, Windows 98, Windows NT 4.0 or Windows 2000 Professional operating systems running on Intel hardware, with the following additional requirements and recommendations: A Pentium 166MHz or faster processor. At least 32 megabytes of physical RAM is required to run GUI applications. Forty-eight megabytes is recommended for applets running within a browser using the Java Plug-in product. Running with less memory may cause disk swapping which has a severe effect on performance. Very large programs may require more RAM for adequate performance. You should have 65 megabytes of free disk space before attempting to install the Java 2 SDK software. If you also install the separate documentation download bundle, you need an additional 120 megabytes of free disk space."

I thinks is worth a try on a less powerful machine, but we'll have to see. Note that java is available on the campus microcomputer networks.

Sun's specific instructions on installing jdk1.3 are provided at http://java.sun.com/j2se/1.3/install-windows.html

Basically you either download j2sdk1_3_0-win.exe from http://java.sun.com, about 30M, or otherwise get that file on your hard drive. In windows explorer, you double click on that file. The main question you have to answer is where to install it. I think by default it goes to c:\jdk1.3, which is fine. If you like to eep the directory structure on your hard disk tidy you may be tempted to put java in "program files" where it might seem to belong. DO NOT put it in "program files" or any other directory that has a space in the name or that is a subdirectory of a directory with a space in the name. To be safe I'd avoid directory names more than 8 characters long as well. After it installs and you verify that it has run you can delete j2sdk1_3_0-win.exe and get back 30M. Then using Notepad, modify the PATH statement in c:\autoexec.bt as described in the Sun installation instructions. (You have to reboot for the Path chage to be effective.) (Don't worry about classpath.)

Java DocFather

Some general information on java and additional installation instructions are provided at http://developer.java.sun.com/developer/onlineTraining/new2java/?frontpage-shortcuts .

You may be interested in java DocFather that provides access to local or internet java documentation from Sun. The zipped file is jdk13_dfi.zip. Unzip it and look at readme.

Installing a Programming Editor

Basically, as you develop programs, you write code in some sort of editor. You use the windows run command to compile the program which sends error messages (if any) to another file. You view the error listing and go back and edit the source code, and compile it and so on until you get no errors. You then use the command line to run the program. If it doesn't work quite right, you go back to the source code, edit it, compile it, etc, repeating this cycle. This can all be done with the Windows Run command, Notepad (that comes with Windows) and jdk1.3. But trust me it will become a real pain.

Another option is to use a professional integrated development environment. Jbuilder from Inprise/Borland is one such environment. Version 3 comes with Savitch, you can buy version 4 from Frys Electronics or the campus computer store (same price; though at the bookstore they did not have version 4 when I was last there). This sort of development environment, once you figure it out, makes things very fast, especially if you want to build a jazzy windows interface. However, there is a lot of overhead that I think you will to avoid at the outset.

A middle ground is a programming editor. I am aware of two that seem to work well. TextPad and WinEdit. I've used TextPad a lot more, I'm happy with it, and it is a lot cheaper so I'll talk about it. You can download an evauation copy of the the current version of TextPad from http://www.textpad.com. Version 4.3 (also an evaluation version) in included on the Savitch CD. The evaluation version is fully functional. However, you are supposed to buy it if you decide to keep it. The evaluation version interrupts you every half dozen compiles or so if you are ready to buy. Once you register your copy and pay for it, it stops bugging you. The single copy price is $27. We may or may not be able to get a 40% educational discount. (A trial WinEdit can also be downloaded from http://www.winedit.com. It costs $89.)

I recommend giving TextPad a try. (It can just replace Notepad.) To install it double click on the compressed file, txpeng440.exe, and it will install by itself. It will install by default in "Program Files" and that is fine. You can delete the compressed file.

To configure TextPad, start it from the start menu or a desktop icon, just like any other program. Then do

Installing Course-related Java Files

For the course you will want to set up a different subdirectory with all your java program information. It could be something like c:\ASM566 or c:\Doc\ASM566, but you can call it whatever you want. However, employ the same restrictions as for the jdk1.3 directory-no spaces anywhere in the path name and all subdiectories with 8 characters or fewer. In that directory, copy the "Java Savitch (Source Code)" directory from the CD. Also copy to this directory from the CD:



KintighIn.class
KintighIn.java
PrintfFormat.java
SavitchIn.class
SavitchIn.java

Opera Internet Browser

As another issue all together, I have recently discovered an alternate to Microsoft Internet Explorer and Netscape that is called Opera. It is compact, fast, and works well. I find that my system is MUCH more stable with Opera than with Internet Explorer and the internet access works faster. From http:/www/opera.com. You can run it for free and get ads or buy it for $39. The version without java embedded is ow502e32.exe (2M). If you are installing Java it will find your java and use it. The version withJava included (if you aren't installing java is) ow502e32j.exe (10M). You can delete these installation files when you are done.

Getting Started with Java

To get started, try this. Note that you never have to leave Textpad.

  1. Double click on the TextPad icon on your desktop or pick it from the Start menu.
  2. File>Open-FirstProgram.java
    1. This program is in \Java Savitch Source Code\Book Programs\ASCII\ch01\FirstProgram.java
  3. Tools>Compile Java
    1. { you should see Tool Successfully Completed} on the status line at the bottom left of the window.
    2. If you got errors, you would select the command results file in the left hand window to see them and then toggle back to the source file to correct the errors and thern recompile using Tools>Compile Java or Ctrl-1. Once it compiles without errors do:
  4. Tools>Run Java Application (or Ctrl-2) to run the application.
    1. When you run the application, you get a separate window.
    2. When the program terminates, you will need to close the window with your mouse by clicking on the X at the top right. Just pressing any key doesn't do it.
  5. To create your own program
    1. File>New
    2. File>Save As-{your program name} The program's file name needs to be the same as the classname of the program, e.g. HelloWorld. Tell it to it to file type Java. Doing that saves it with the extension .java which it has to have and it also sets up Textpad to understand this is Java and not something else.
    3. Then type the program in the editor window, debug, and run it.

Things to Keep in Mind

public class Name
{
public static void main(String[] args)
{
//program here
}
}