java help videos resources

WRITING JAVA PROGRAMS | SWING | JAVA DOWNLOADS
Writing Java Programs

Since Java files are really text files which are compiled into bytecode and run by the Java Virtual Machine (JVM), there are several options for writing your programs this semester. Remember that links to other Useful Downloads (e.g., programming editors) and Unix Information and Editors are located on the Help Page.

  1. The easiest way is to use a programming editor to type in your Java programs on your local computer, then transfer the files to the FAS system using a secure FTP program. You can then connect through telnet, and compile and run them on FAS (Java is already installed there). All programs except Swing MUST be on FAS in order to submit them for your homework. To use this method, you may want to learn enough about one of the Unix text editors to be able to make any needed quick corrections to your files, or plan to update the file locally and re-transfer it.

    DO NOT use a word processor, e.g. Word or WordPerfect! They add lots of formatting characters which you never see, but which will prevent your programs from ever compiling. On Windows, you may use Wordpad and make sure you save the files as "Text Document" with the .java extension. If the system adds a ".txt" suffix, put quotes around your file name and extension in the Save box to prevent this. You may also try any of the editors in the Useful Downloads section. On the Mac, use BBEdit Lite (also in the Downloads section).

  2. You can use a telnet program to connect into the FAS system, and write and edit your programs on the system. There are three Unix editors which you may try: pico, emacs, and vi. Once you've written your program and saved it, then, as above, you can compile and run it on FAS.

  3. You can choose to write and compile on your own computer at home. If you wish to do this, you will need a programming editor to write the programs (see above under #1), as well as a JDK (Java Development Kit) to compile and run them. Thus, if you have a PC, you will need to download and install the SDK from Sun. You still must upload and run your programs on FAS to submit them for homework.

  4. You can work on your home computer, but obtain a Java IDE (Integrated Development Environment), such as Borland's JBuilder, IBM's Visual Age for Java, MetroWerks' CodeWarrior, or even Sun's Studio. The IDE's are convenient because they'll contain a text editor, a compiler, the Java class libraries, and a debugger, all combined into one package. HOWEVER, at this level of study we do not recommend the use of an IDE.

    NOTE: Since we have provided you with FAS accounts to use for programming, the course staff will NOT be able to provide tech support for the various IDE's.
 
Return to top
 
Swing Programs
Due to their graphical nature, Swing programs cannot be run through a telnet window. It is possible to obtain a similar program known as an XWindows client that handles graphics, but unless you have a high-speed connection at home, using one to connect to NICE and run programs will be impractical. There are thus four choices for writing and running Swing programs for this course; they are as follows:

(1) Compile and run your programs on the Linux Workstations at the Science Center. These computers, in the first 3 rows of Room B-14, run XWindows as part of their operating system (Linux), and can therefore run Swing programs already. This is probably the easiest solution, if you can come to campus.

(2) Download the Java SDK 1.5 from Sun, linked below, and install it on your home computer. If you have already done this, you are all set - the JDK will do a very fine job of running Swing. This application comes pre-installed on Apple computers running OS X. If you get messages on Windows that the java and javac commands aren't recognized, see the info from Sun on how to set your PATH variable (http://java.sun.com/j2se/1.5.0/install-windows.html) - you can test the commands by typing 'java -version' at a command prompt. You should see information on your Java version. If you use a programming editor like PFE (Programmer's File Editor), there is a menu button at the top to get a command prompt to compile.

(3) Get an X-Windows server , which allows you to connect to the FAS system from home and run Swing programs, something a regular telnet client cannot do. We have not been able to locate a free XWindows server, although you can purchase X-Win32 for a student price of $60 from Starnet Communications (http://www.starnet.com).

(4) Get a Linux Live (bootable) CD and run it to connect to NICE. One of the better ones is Knoppix (http://www.knoppix.com), which does automatic hardware detection and set-up. You can purchase a Knoppix CD for a few dollars, or download the disk image and burn it to a CD yourself for free. Then set up your computer to boot from a CD, put this in your CD drive, and restart the computer. It will come up in Linux (without installing anything on your hard drive!). Once there, open a terminal window and type 'ssh -Y username@nice.harvard.edu' and it will begin an X-Windows session.

Some sections may ask that you turn in your Swing programs on a portable media (CD, USB drive, etc.) for grading.
 
Return to top
 
Java Downloads
JAVA SDK'S:
These are the nuts and bolts of Java - this used to be known as the JDK (Java Development Kit); then Sun renamed it the Java SDK (Software Development Kit); now it seems to be back to JDK. The release we will use is 1.5.0. Macs have Java already included, although it may not be version 1.5. You can check the version of a Java installation by typing the command 'java -version' at a command prompt. The links below go to Apple's download page for version 1.5, as well as other documentation for Java on Macs.
 
Windows:
NOTE that you do NOT need the NetBeans package or J2EE, just the J2SE SDK. Select JDK 5.0 Update 14 (the third item on the list)!!
SUN'S SDK 1.5.0(free) http://java.sun.com/j2se/1.5.0/download.jsp
SDK INSTALLATION http://java.sun.com/j2se/1.5.0/install.html
 
Macintosh:
MAC OS X JAVA 1.5.0 http://developer.apple.com/java/download/
MAC OS X JAVA INFO http://developer.apple.com/java/
 
IDE'S:
These programs can provide convenience if you wish to invest in them. You will see that Sun encourages the use of an IDE (Integrated Development Environment); at your level of programming, it truly won't make that much difference, and in fact, it is preferable that you write all of your own code to better learn how. It becomes more important when you begin to write complex programs that use numerous classes (coming in CSCI E-119 or E-160). Sun has an IDE available, named Java Studio. If you are interested in JBuilder or CodeWarrior, check the Harvard Coop - they'll have the educational versions at a discount.

You should be aware
that we will be checking your programs to be sure that YOU are writing the code, and not having an IDE do it for you.

SUN'S JAVA STUDIO http://wwws.sun.com/software/sundev/jde/index.html
BORLAND JBUILDER http://www.borland.com/jbuilder/
METROWERKS CODEWARRIOR http://www.metrowerks.com/

© 2008 The President and Fellows of Harvard College
Please send comments to The Webmaster
Last modified: Saturday, 13-Dec-2008 17:44:31 EST
URL: http://www.fas.harvard.edu/~libe50b/java.html