GETTING STARTED WITH JAVA (DOS)

Mtht 420

This is the unix version (for use when connected to icarus by telnet or ssh from a lab computer or from home.)


Before sitting down to type in, compile, and test a program you should have:

  1. A written copy of the program you wish to type in,
  2. Your userid and password on icarus,
  3. A computer connected to the internet (a UIC lab machine, a home computer with a modem and UIC's network services kit, or a home computer and an account with some other internet service provider), and
  4. A working copy of the Telnet program.
When you are ready to enter your program into the computer, telnet to icarus and do the following:
  1. Log on using your userid and password.
  2. Decide where you want the files you create to reside and change to that directory using the cd command. If you do nothing, all files will be created in the top level of your home directory, which is OK.
  3. Type pico 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.
  4. Type /usr/local/java/jdk1.1.4/bin/javac Welcome.java to compile your program or applet. If the compilation is successful (no error messages), typing ls should show you two files: Welcome.java and Welcome.class.
  5. 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.
  6. Test your applet or program to see if it does what you want it to do. Edit your code (pico 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.
  7. Back up your work by printing it out, ftp'ing it to your home computer, ftp'ing it to a lab computer and saving it to diskette, or emailing it to a non-UIC account of yours.
  8. Type "logout" to close your connection to icarus.
For experts: you can avoid always having to type /usr/local/java/jdk1.1.4/bin if you add it to your path -- your path is the list of locations the computer looks through when interpreting the commands you give at the prompt. (Type echo $PATH to find out what your path is.) To add /usr/local/java/jdk1.1.4/bin to your path, edit your .profile file (pico .profile) and add /usr/local/java/jdk1.1.4/bin to the list of things in your path. Your .profile file should end up containing a line like:
export PATH=$HOME:/usr/local/bin:/usr/bin:/etc:/usr/sbin:/opt/SUNWspro/bin:/usr/ucb:/usr/bin/X11:/sbin:/usr/openwin/bin:/usr/local/java/jdk1.1.4/bin:.
Once you have done this, you can simply type javac Hello.java to compile a program.


Mtht 420