Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Java Programming for Windows XP Users - Lecture Notes | CMSC 150, Study notes of Computer Science

Material Type: Notes; Professor: Barnett; Class: INTRODUCTN TO COMPUTING LAB; Subject: Computer Science; University: University of Richmond; Term: Unknown 2005;

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-awd
koofers-user-awd 🇺🇸

5

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Science, University of Richmond 2005
Page 1
Java Programming for Windows XP Users
All of the software we use in CMSC 150 and CMSC 221 is freely available for the Windows plat-
form.
Obtaining the Free Software
You can get the Java 2 Standard Edition (J2SE) which contains javac (the compiler), java (the
command to run a Java program), various other programming tools such as javadoc, plus docu-
mentation and the netBeans IDE at no charge.
The current version of the J2SE is 1.5, and the current version of netBeans is 4.1. J2SE 1.5 bun-
dled with netBeans 4.1 is a 128MB download; J2SE by itself is 56MB. The Java documentation is
another 44MB. If you have the space, go to Sun’s web site and download the JDK 1.2.
http://java.sun.com/products/jdk/1.2/download-windows.html
You will have to agree to a user license, which you should read before agreeing. Save the down-
load in a temporary directory like C:\temp. Also download the documentation if you want. This
will allow you to look up information on classes in the library without going across the Internet to
get to Sun’s online copy. Downloading the documentation is not essential if you have limited disk
space.
Installation Issues
The installation instructions are found here:
http://java.sun.com/j2se/1.5.0/install-windows.html
Installation is more or less automated. You can follow the basic installation procedure and install
the files in the default location or you can create a directory like C:\java and install in
C:\java\j2se1.5.0. I personally prefer having a special Java directory, primarily because in the past
there were certain IDEs and third party libraries that had problems with pathnames containing
spaces, but most of those problems should be history by now. However, if you do end up install-
ing third party libraries, it is nice to have everything in one place. For the rest of this discussion I
will assume that you installed in C:\Program Files\java\jdk1.5.0. I will refer to this as the “instal-
lation directory.” After installation you can delete the file you downloaded.
After installing the programs you will need to set some environmental variables so the operating
system can find the javac and java commands and the programs can find any additional java
libraries you might install.
The two key environmental variables to set are Path and CLASSPATH.
After the JDK is installed, right-click “My Computer” and select “Properties.” In the window that
appears, select the “Advanced” tab. Near the bottom of the resulting window, click the “Environ-
ment variables” tab. You can also check this from a Command Prompt window by typing the
command
set
and look to see if you can find Path and CLASSPATH among the list of values. There will be
two windows, one with the environment variable values for the system as a whole and one for
additions for the current user. If you are on a single user machine, it doesn’t make a lot of differ-
ence which one of these you modify. For our current purposes, look through the values in both
pf3

Partial preview of the text

Download Java Programming for Windows XP Users - Lecture Notes | CMSC 150 and more Study notes Computer Science in PDF only on Docsity!

Java Programming for Windows XP Users

All of the software we use in CMSC 150 and CMSC 221 is freely available for the Windows plat- form.

Obtaining the Free Software

You can get the Java 2 Standard Edition (J2SE) which contains javac (the compiler), java (the command to run a Java program), various other programming tools such as javadoc , plus docu- mentation and the netBeans IDE at no charge.

The current version of the J2SE is 1.5, and the current version of netBeans is 4.1. J2SE 1.5 bun- dled with netBeans 4.1 is a 128MB download; J2SE by itself is 56MB. The Java documentation is another 44MB. If you have the space, go to Sun’s web site and download the JDK 1.2.

http://java.sun.com/products/jdk/1.2/download-windows.html You will have to agree to a user license, which you should read before agreeing. Save the down- load in a temporary directory like C:\temp. Also download the documentation if you want. This will allow you to look up information on classes in the library without going across the Internet to get to Sun’s online copy. Downloading the documentation is not essential if you have limited disk space.

Installation Issues

The installation instructions are found here:

http://java.sun.com/j2se/1.5.0/install-windows.html Installation is more or less automated. You can follow the basic installation procedure and install the files in the default location or you can create a directory like C:\java and install in C:\java\j2se1.5.0. I personally prefer having a special Java directory, primarily because in the past there were certain IDEs and third party libraries that had problems with pathnames containing spaces, but most of those problems should be history by now. However, if you do end up install- ing third party libraries, it is nice to have everything in one place. For the rest of this discussion I will assume that you installed in C:\Program Files\java\jdk1.5.0. I will refer to this as the “ instal- lation directory .” After installation you can delete the file you downloaded.

After installing the programs you will need to set some environmental variables so the operating system can find the javac and java commands and the programs can find any additional java libraries you might install.

The two key environmental variables to set are Path and CLASSPATH.

After the JDK is installed, right-click “My Computer” and select “Properties.” In the window that appears, select the “Advanced” tab. Near the bottom of the resulting window, click the “Environ- ment variables” tab. You can also check this from a Command Prompt window by typing the command

set and look to see if you can find Path and CLASSPATH among the list of values. There will be two windows, one with the environment variable values for the system as a whole and one for additions for the current user. If you are on a single user machine, it doesn’t make a lot of differ- ence which one of these you modify. For our current purposes, look through the values in both

windows. We want Path to include your installation directory’s subdirectory called “bin”. For example,

Path=C:\windows\system32;C:\windows; C:\Program Files\java\JDK1.5.0\bin ; would be a reasonable value. This may be automatically set up for you during the installation pro- cess. Notice the semicolons. These separate directories in the list. The Path simply is a list of directories where the operating system looks for commands to run. If you see a similar path con- taining “jre” rather than “jdk,” you need do nothing. JRE stands for “Java Runtime Environment,” and contains its own bin and lib subdirectories.

The CLASSPATH variable tells the Java compiler and interpreter where to find the classes it needs. It does not need to contain the location of the basic java libraries, only additional libraries you have installed yourself. For example, in the classpath

ClassPath=.;C:\java\classes\junit.zip

the dot (.) means always check the current directory and the second listed entry indicates a collec- tion of files in the archive junit.zip that are stored in the folder C:\java\classes which the user created. If you haven’t installed any additional class files or libraries, you need not mod- ify this variable, either.

Where To Put Your Files

I suggest creating a folder like C:\java for your working space. In that folder create a folder called classes for any additional class libraries you may install. If you have special projects you can create folders in C:\java to do your work.

Creating Java Programs on a PC with the JDK

You will need to use an editor or IDE. You can use Notepad for the editor although Wordpad will work just as well. There are also a number of free Java editors as well as more capable software development environments like NetBeans and Eclipse. If you are interested, you can have a look at http://www.mathcs.richmond.edu/~lbarnett/java/Java.php for a number of links. The following description assumes you are using the simplest possible option.

  • Pick a directory/folder where you want to develop your programs. I suggest some- thing like C:\java.
  • Start Notepad by selecting ‘Programs’ on the ‘Start’ menu, then ‘Accessories’, then ‘notepad.’ (Start>Programs>accessories>notepad)
  • Type in your program. You will have to indent manually.
  • When finished typing, select ‘Save As’ on the ‘File’ menu. Be sure you find the directory C:\java and then enter the name, including the .java extension.
  • To compile the program requires an MS-DOS window. Open one by selecting ‘Programs’ on the ‘Start’ menu, then ‘Command Prompt.’
  • In the command prompt window (which is a simple command-line terminal win- dow) enter the following commands C: If the prompt is already something like C:\WINDOWS> you would need to enter cd .. to get the prompt C:> Then continue with the commands below.