|
|
|
|
Introduction
ATTENTION CSE 143 Students Only: All of the assignments
in 143 will assume that you are using the editor of your choice and the
command line progams javac and java. Where necessary, we will be providing
you with additional information (why, how) for specifying your classpath.
In all cases, we are going to assume that you have installed the software
according to our recommendations (eg, you will want to put the SDK where
we say you should). If you choose to install the software elsewhere, it
will be up to you to figure out how to set your classpath. If you choose
to use a more sophisticated development environments (Dr. Java, Eclipse,
XCode, etc), then it will again be up to you to figure out how to set
your classpath. This shouldn't be difficult, but you know more about your
machine and environment than we do, and if we tell you how to do it, we're
likely to get it wrong.
This document should help you get set up for working on a home computer.
The software setup is the same for both CSE142 and CSE143 this quarter
- these instructions apply to both courses. You'll need to install the
following software:
- The Java SDK from Sun
or Apple
- Probably one or more of (ask your instructor which)
- DrJava: a Java
interpreter and development environment designed for learners, but
robust enough for developing substantial projects.
- Eclipse:
an industrial-strength Java development environment that has become
very popular in the open-source community.
- Local CSE142/143 libraries
We're not particularly religious about which development environment
you use. You can do most of the assignments in this class with very
simple tools -- see the end of the document for a low-tech (yet surprisingly
powerful and useful) approach -- or with other recent Java 2 programming
environments like BlueJ, jGrasp,
JBuilder,
Sun One Studio
(formerly known as Forte), the NetBeans
IDE, CodeWarrior
(commercial only), and so forth. You can't use Microsoft Visual
J++, however; it does not support the current version of the the Java
language and libraries.
If you want to work at home, you are on your own to some extent in terms
of getting stuff set up. Ask friends, read documentation, post a question
on the bulletin board, ask us -- but we can't be guaranteed to have an
answer. Ultimately you're on your own with your home computer. The UW
lab is always available as a fallback.
Regardless of the development environment that you use, the code you
turn in should only rely on the standard Sun Java libraries, and libraries
that are distributed by us. Your code should not rely on "wizards", special
libraries that might be provided with your environment, or code that comes
from the Internet or friends. The programs you give us will be compiled
and run using our set-up.
Java SDK
Java 1.4.2 for Windows, Linux, and Unix
You must first install the Java 2
Platform from Sun Microsystems. We suggest using the latest
version of the Standard Edition, version 1.4 or to be precise, v 1.4.2_03,
however any recent release of version 1.4.1 or 1.4.2 is also ok if you
have that installed.
Go visit the Java2
home page (really, the page where you can download the Software
Development Kit (SDK) 1.4). If you're downloading the Windows version,
be sure to get the "windows offline installation", which includes
all files needed and doesn't require an active internet connection to
install. The distribution is big, roughly 36MB, so if you're connecting
by slow modem, it's going to be a pain. DSL or Cable Modem users should
have an easier time. You can always download it onto a UW lab machine
with a CD burner and make a copy that you can carry home to install.
To install, double-click on the j2sdk-XXX.exe installer program
that you downloaded from Sun, and then follow the instructions. A couple
of notes:
-
If you have earlier versions of Java on your machine and plan to
replace them with the current version, remove the old versions
first. Use the add/remove programs control panel, and be sure
to remove all Java components, including the Java SDK, the Java Runtime
Environment (JRE), and Java Web Start. (There is a bug in some versions
of the Sun installer that can prevent DrJava and other programs from
launching if older parts of Java are removed after the new version
is installed.)
-
We strongly recommend you install the Java SDK in the the default
directory suggested by the installer, which is C:\j2sdk1.4.2_03 for
version 1.4.2_03. By doing that, you can keep your environment consistent
with IPL machines and most students and TAs' environment. And you
should be able to download the tools from us and run them directly
without the need of modification. If you already installed Java SDK
in another directory, we recommend you delete it - including the SDK,
JRE, and Java Web Start - using the add/remove programs control panel,
then run the installer and let it put the SDK in the default directory.
(Do NOT just rename the original directory. It will NOT work). If
you really want to use other directory names, you may have to make
changes in other parts of the installation to match.
-
Be sure you install the Java Standard Edition Software Development
Kit (J2SE SDK), formerly known as the Java Development Kit (JDK).
There is a smaller package called the Java Runtime Environment (JRE),
which is a subset of the SDK that includes files needed to run, but
not create, Java programs. The JRE is not adequate for our purposes
-- be sure to get the SDK.
-
A sizeable part of the SDK distribution is source code. If
disk space is limited on your machine, you don't need to install the
source code, or the demos, but install everything else. (You'll
eventually get the option of what you want to install when you run
the j2sdk-XXX.exe installer program that you downloaded from
Sun.) However, in past quarters, some students have had trouble getting
Java to work if only part of it is installed, so it is best to install
the entire package if you can.
Java 1.4.1 for Macintosh OS X
An earlier version of Java, 1.3.1, comes pre-installed on OS X Jaguar.
Java 1.4.1 was released in March 2003 for OS X 10.2.3 (Jaguar) and later
versions. It is not available for OS X 10.1 and Mac OS 9 and earlier.
To install Java 1.4.1, open the software update control panel, select
check for updates, select Java 1.4.1 from the list of available
updates, and click update. This is a large download, about 30MB,
which is reasonable on a DSL or Cable modem line, but can be a pain if
you have a slow dialup line. You can download
the update from Apple onto a campus machine with a CD burner and make
a copy on CD to carry home if you don't have a fast connection.
If you have OS X 10.3 (Panther), you should have a current version of
Java, but run software update to be sure that you have the latest version.
If you have installed the Developer Tools software that comes with OS
X Jaguar, you should get the Java 1.4.1 OS tools update and install it
(available at http://developer.apple.com/).
If you did not install or don't plan to use the Developer Tools, this
is not necessary. If you have OS X 10.3 (Panther), the developer tools
that you received with OS X should be current. In any case, run software
update to get any available updates.
If you have an earlier version of OS X and want to buy the newer version,
be sure to take advantage of the educational discount available through
Apple's web site (click store at the top of Apple's main page,
then click education on the horizontal banner).
Folders and UW CSE Software Library
- Note: Use of UW CSE libraries will vary from quarter to quarter.
There may be additional libraries or files which need to be downloaded
for individual programming assignments. You don not need to install
the CSE libraries if your instructor is not using them.
- Be sure you have already installed the Sun Java 2 SDK first (see
above).
- Create a folder for the CSE142/3 files. We strongly recommend
you use the name C:\CSE. It will make set-up much easier.
- Download the following file and place it in C:\CSE: uwcse.jar
- Instructions for configuring DrJava to use the UW CSE library files
are given below.
DrJava
- Be sure you have installed the Sun Java SDK or Apple Java update first.
You don't need to install Eclipse or other additional tools to use DrJava.
- DrJava's web site is http://drjava.sourceforge.net/.
You want to install the latest stable release. DrJava is about 1.5MB
in size, so it is a reasonable download even over a slow dialup connection.
- (Windows) Click on the download windows app button. This
can be placed anywhere, but we suggest putting it in the C:\CSE\
directory.
- (Unix, and Linux) Click on the download jar file button
to get the .jar (Java archive) file containing DrJava. This file
can be placed anywhere, but we suggest putting it in the C:\CSE\
directory.
- (Mac OS X) Click on the download Mac OS X app button
to get the OS X version of DrJava. This should normally be placed
in your Applications folder.
- Start DrJava.
- (Windows, Unix, Linux) On most of these systems, you should be
able to run DrJava by double-clicking on the drjava jar or application
file.
For future convenience, if you're using Windows, you might want
to create a shortcut to the DrJava file and place it on the desktop
or in some other convenient location. Right-click on the DrJava
file and select create shortcut from the popup menu.
- (Mac OS X) DrJava runs as a normal application. Double click to
start it.
- The first time you start DrJava on Windows and some other systems,
you may get a message saying "DrJava cannot find any Java compiler.
Would you like to configure [it]..." Click on yes. Assuming you've
used the default Java SDK installation, use the file dialog to select
C:\j2sdk1.4.2_03\lib\tools.jar. DrJava should then open its
main window. This extra step should not be necessary with recent versions
of DrJava, and is not necessary on Mac OS X.
- To verify that DrJava is working, enter the following line, including
the semicolon, in the interactions window pane at the bottom of the
screen, to the right of the ">" prompt.
System.out.println("Hello");
Hit return (enter) and DrJava should display the word hello
below the line that you typed.
- Tell DrJava where it can find the CSE142/143 library files, if your
class is using them. This only needs to be done once. You must
first have installed the libraries on your system.
- Start DrJava if it is not already running.
- Select Preferences from the Edit menu.
- Select the Resource Locations tab if it is not already
selected and click Add.
- In the file dialog that appears, locate the file C:\CSE\uwcse.jar,
click select, then click ok.
- To test that the new libraries are installed correctly, enter
the following two lines of code at the bottom of the screen in the
interactions window.
import uwcse.graphics.*;
GWindow w = new GWindow();
If everything is installed properly, an empty window named
DemoWindow should appear on the screen.
- If you want to use the new assert statement that was added
to Java in version 1.4 (optional for CSE142, needed for CSE143), start
DrJava if it is not already running, select Preferences...
from the Edit menu, select the Miscellaneous category,
then click the Allow assert keyword in Java 1.4 check box in
the middle of the panel, and click ok. This only needs to be
done once. DrJava currently does not support the use of assert
in the interactions window at the bottom of the screen, but you can
use it in any new classes that you create.
Eclipse
This is a full-featured development environment that has an enthusiastic
following in the open-source community. It is probably overkill for the
projects encountered in introductory courses like CSE142 and CSE143, but
some students have found it useful for larger projects, particularly in
CSE143.
- Be sure you have installed the Sun SDK or Apple Java update first.
You don't need to install DrJava or other tools to use Eclipse.
- Eclipse is available from www.eclipse.org.
We suggest installing the latest "3.0 stream stable build",
which was version 3.0M6 as of late December. This is a big download
(~60MB), so if you have a dialup line, you may want to download the
file in a campus lab and burn it onto a CD to carry home.
- Install Eclipse by moving the application to the Applications folder
(Mac OS X), or unpacking the zip file and installing using the usual
conventions for your system (others).
- Start Eclipse by double clicking the Eclipse application.
- Tell Eclipse where to find the CSE142/143 library files if you need
them.
<to be supplied>
- To use the assert statement with Eclipse, do the following.
<to be supplied>
Textbook Libraries
As you read the textbook, you may come across references to special Java
libraries and sample code that the textbook authors have created.
If these are needed for your course, you will receive specific instructions
for how to use them with your assignments. Of course, you are welcome
to study the code samples in the textbook. As you do, please keep
in mind that they may use features or libraries which will not be discussed
in your course.
Old School
Once you have installed the Java SDK on your home machine, you can actually
build Java programs without DrJava, Eclipse, or other tools. The SDK comes
with command-line tools that you can use to compile programs, and a functional
debugger, called jdb. You'll want to use a good editor to write
your programs, the best of which is emacs (read more
about emacs). There is a faster compiler available called jikes,
from IBM. The advantage of using this approach is while it may not be quite
as easy as an integrated environment, you'll learn to use some tools that
you can use in many other contexts as well.
|