| Java Programming Spring 2003 Homework #1 |
|   Course Syllabus   |   Java Programming Home   |   HW1 FAQ   |   Assignment   |   How to submit |
| Assignment |
This assignment is simply to install Java SDK 1.4.1 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 Java SDK 1.4.1 Standard Edition from java.sun.com, and following the instructions for installing it. Make sure you take care of setting the PATH environment variable, etc.
To test your installation we suggest you go through the "First Cup of Java" tutorial available at : http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html (This is the Windows version, others are available...).
Download the sample HW1 file Hw1.java (also shown below).
Make sure you can compile and run Hw1.java from a command prompt 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.
| 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 |
Submission of your homework is via email, the general idea is to send an email message with your files as attachments. There is an automated email submission system that will respond to your submission right away, so you will have a record that we got your file. For HW1 you should submit your Hw1.java file and the results file produced when you run the Hw1 program.
All projects must be submitted via email to javaprog-submit@cs.rpi.edu.
The subject line of the submission message should contain a single
number '1' indicating the HW number. The body of your message should
include your full name (and anything else you want to tell us). Make
sure your email message includes your full name, we can't record your
grade unless we know your name (and the email address
joe222@yahoo.com doesn't mean anything to us!).
Don't send compiled code (class files)!
You can expect a return email indicating receipt of your project submission immediately. This receipt will include a list of all the files that were successfully extracted by the submission script - please look over the receipt carefully to make sure your submission worked.
Multiple Submissions: You can resubmit up to 10 times for each project, we will always grade the last submission received unless you tell us otherwise.