This assignment gets you started with the basic tools you will need to complete all of your homework projects. This project will:
IMPORTANT: We do not use integrated development environments (IDEs) in this class. You must use the command line and a text editor to edit, compile, and debug your Java code.
You are a CS 1331 student who needs to install the JDK, configure it for command line use, and learn how to use a programmer’s text editor to create and edit Java source code.
cs1331
.
cd
command).mkdir cs1331
.cd cs1331
.cs1331
directory named hw0
.hw0
directory.On the command line, make sure you are in the hw0
folder. Enter these commands (remember that ‘$’ is the shell prompt (something like ‘C:>’ on Windows) – don’t type the shell prompt character(s)):
$ javac -version > hw0-output.txt
$ java -version 2>> hw0-output.txt
Please note what is happening here:
>
redirects the standard output of a program. 2>
redirects stderr
, which is used for diagnostics (such as version strings). The first line creates the hw0-output.txt
file, and the second line (with the extra >
) adds more text to the file. Here is a nice discussion of the file descriptors stdin
, stdout
and stderr
.
What this means is that >
(or 2>
) will overwrite the file, so if you go back to repeat the first step, you’ll need to repeat all the other steps as well.
Open your text editor and create a file in your newly created hw0
directory named NimblyBimbly.java
and enter the following Java program:
public class NimblyBimbly {
public static void main(String[] args) {
for (int i = 0; i < 9; i++) {
System.out.print("\u004D\u0065\u006F\u0077 ");
}
System.out.println("...");
System.out.println("\u004D\u0065\u006F\u0077\u0021");
}
}
On the command line, go to the directory containing your newly created NimblyBimbly.java
file and enter javac NimblyBimbly.java
. Do a directory listing using the command ls
on Mac and Linux or dir
on Windows; you should see a file called NimblyBimbly.class
that contains the compiled bytecode of your NimblyBimbly
program. These commands should look like this:
Mac / Linux:
$ javac NimblyBimbly.java
$ ls
NimblyBimbly.class NimblyBimbly.java hw0-output.txt ...
Windows:
C:\...\cs1331\hw0> javac NimblyBimbly.java
C:\...\cs1331\hw0> dir
NimblyBimbly.class NimblyBimbly.java hw0-output.txt ...
java NimblyBimbly
to run the program and see its output on the command line.Add the output of your program to hw0-output.txt
by running
java NimblyBimbly >> hw0-output.txt
Schools.java
) for you that contains some sort of error.Schools.java
(using javac
and java
).Schools.java
the error originated. That is, identify which line caused the error. It’s alright if you don’t understand what the error means or how to fix it, but do your best to reason through it and think about it. You will encounter lots of errors as you work through homework for this class, so it’s important that you learn early how to decipher the error messages.hw0-output.txt
file from before in your text editor. At the bottom, add two lines.
For example, if you compiled the program successfully, the error happened when you ran it, and line 2 caused the error, you would add
runtime
2. public static void main(String[] args) {
to the file. Be sure to follow the instructions – no extra blank lines, capitalization (or lack of capitalization) as modeled above, etc. Get used to being pedantic about instructions. Computers are nitpicky.
Submit your hw0-output.txt
file on Canvas as an attachment. When you’re ready, double-check that you have submitted and not just saved a draft.
Practice safe submission! Verify that your HW files were truly submitted correctly, the upload was successful, and that your program runs with no syntax or runtime errors. It is solely your responsibility to turn in your homework and practice this safe submission safeguard. NOTE: Unlike TSquare, Canvas will not send an email indicating that your assignment has been submitted successfully. Follow the steps outlined below to ensure you have submitted correctly.
This procedure helps guard against a few things.