| Programming in Java Spring 2006 |
|   Programming in Java Home   |   HW1 FAQ   |   Assignment   |   How to submit |
Assignment
This assignment is simply to install Java SDK 5.0 and get things
working on your computer. If you have access to a computer with Java
already intalled, feel free to use that computer (we don't care if you
know how to install Java, just that you have a usable Java development
environment available to you). Once you have Java installed, you need
to make some simple additions to the program shown below, compile and
run the program. You will need to submit your source code (the file
Hw1.java that you have modified) and the output of the
program when you run it on your machine.
Installing Java:
Download the J2SE 5.0 from java.sun.com, and following the instructions for installing it. Make sure you take care of setting the PATH environment variable, etc.
Download the sample HW1 file Hw1.java (also shown below).
Make sure you can compile and run Hw1.java from a command prompt ( or use an IDE like eclipse with the commands:
javac Hw1.java java Hw1
You need to make some additions to the program. Currently the program will print out the Version of Java used to run the program, you need to add statements so that the program also prints out the following information:
Notes:
The System.out.println() method is used to print
things out.
The System.getProperty() method is used to find
out the value of various system properties (including all the
things you need to print out). You need to check the documentation
for this method (and perhaps some other things) to determine the
right parameters to pass System.getProperty(). This is
part of the assignment (becoming familiar with the Java
documentation)!
Compile and run the new version (with the above additions) and save the output. You can do this from a command prompt by redirecting the output of the program to a file, like this:
java Hw1 > results
The file results will contain everything output by
your program. You will submit this file along with your
Hw1.java file.
If you are using an IDE, you can cut and paste the output into
a text file named results.
| Starting Code for HW1 |
/**
* Title: Hw1
* Description: Homework #1 Class Definition
* @author joestudent@rpi.edu
* @version 1.0
*/
public class Hw1 {
/**
* The main() simply calls ShowInfo.
*/
public static void main(String[] args) {
ShowInfo();
}
/**
* ShowInfo does all the work by calling System.getProperty
*/
public static void ShowInfo() {
System.out.println("Version: " + System.getProperty("java.version"));
/* In addition to the above statement, this program should
print out the following:
operating system name
virtual machine name
user name
user's current working directory
HINT: Look at the documentation for System.getProperty()
*/
}
}
|
How to submit
Log in to WebCT at webct.rpi.edu using your RCS id and password. Once you get to MyWebCT click on "Programming in Java", and from there go to the homework drop boxes. Submit your files (individually, zipped, tarred or a jar file) to the drop box labeled HW1
Don't send compiled code (class files)!