GETTING STARTED WITH JAVA (DOS)
Mtht 420
This is the DOS version (for public labs and home computers with Sun's
JDK installed) of these instructions.
Before sitting down to type in, compile, and test a program you
should have:
- A written copy of the program you wish to type in,
- Your netid and password (usually the same as your account on icarus), and
- A blank or DOS/IBM formatted floppy diskette.
The Sun JDK (Java Developer's Kit) should be installed in computer labs in:
SEL 2249, ECSW L270, BGRC 179, SSB 2300
it may also exist in other labs. When you are ready to enter your
program into the computer, go to one of these labs and do the
following:
- Log on to the machine using your netid and password.
- Insert your diskette in the drive. Format it if necessary.
- Choose "MS-DOS Prompt" from the Start menu in the lower left hand
corner of your screen. This will create the window on your screen in
which you will work.
- Type A:\ so that files you create will be saved on
your diskette. If you do not do this, your files will probably be
deleted as soon as you leave the computer.
- Type edit Welcome.java to create a file named
Welcome.java containing your code. Type in your program or applet --
the sample applet in section 1.16 of Deitel
and Deitel is a good applet to start with. (There are many ways to
create and edit a file. If you prefer another editor which can create
compilable plain text files, feel free to use it. Be warned that you
may not be able to get help in class if it fails to work.) Save your
work and quit the editor when you are done.
- Type C:\jdk1.1.7A\bin\javac Welcome.java to compile
your program or applet. If the compilation is successful (no error
messages), typing DIR A:\ should show you two files:
Welcome.java and Welcome.class.
- At this point, you have typed in some Java code and compiled it.
The next step is to try running it. Running a Java program is
different from running an applet.
- You can run a compiled program by
typing, for example, C:\jdk1.1.7A\bin\java Hello. Most
examples provided by Dr. Burgiel or Professor Larson will be
programs.
- Most examples given by Deitel and Deitel are applets. Applets
run on web pages, and generally have fancier user interfaces. To run
an applet, you first first create an HTML document inside which your
applet will run. You can do this by typing edit Welcome.html
and entering code similar to that in Figure
1.3 of Deitel an Deitel. Save your work and quit the editor when
you are done. Then run your applet by loading the web page into a
java capable browser. For example, type
C:\jdk1.1.7A\bin\appletviewer Welcome.html.
- Test your applet or program to see if it does what you want it to
do. Edit your code (edit Welcome.java), save, compile, and
run (you do not need to create a new html file unless you change the
name of your program) until it does what it's supposed to.
- Back up your work by emailing copies to yourself, copying it to
icarus via ftp, printing it out, or saving it to another diskette.
- Double click on the Logout (stop sign) icon, eject your disk from
the drive, and give the next lucky student a chance to log on!
Mtht 420