Set the indentation level in DrJava to 4 spaces, by selecting Preferences -> Miscellaneous -> Indent Level -> 4. (Now you will be able to properly format your homework by using the indent key.)
Display line numbers, by selecting Edit -> Preferences -> Display Options -> Show All Line Numbers.
Deactivate automatic updates, by selecting Edit -> Preferences -> Notifications -> Check for new versions -> none
Turn off “emacs style” backups (backup files with names that end in tilde), by unchecking Preferences -> Miscellaneous -> Keep emacs-style Backup Files.
If you’re unsure, please wait until we do this in lab.
DrJava comes with many standard libraries built in. But in this course we also need the standard library provided by Sedgewick and Wayne, which adds a few convenient features to those libraries. We need this starting in section 1.5 of the textbook.
Now click Apply and Ok to save the change.
Note: You can also download stdlib.jar from the booksite, specifically here.
Important note: Section 1.5 also discusses I/O redirection and piping, for which you will need to learn how to use the “shell” (also known as “terminal” or “command prompt”). We will cover this in lab at a later date.
Important note: these are PRELIMINARY instructions, as an aid to walk through the process during lab. Please wait until lab unless you are quite confident about system administration for your computer.
C:\Program Files\Java\jdk1.6.0_27\bin”
but on others it is
“C:\Program Files (x86)\Java\jdk1.6.0_26\bin”.C:\Program Files\Java\jdk1.6.0_27\bin;originalpath”stdlib.jar (which you already set in DrJava last week).
.;c:\Users\username\pathToTheFile\stdlib.jar;The period other punctuation marks should appear exactly. Use your own user name as well as the path to where you put stdlib.jar.
C:\Users\username>java -version java version "1.6.0_27" Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0_27-b07) Java HotSpot(TM) Client VM (build 1.6.0_27-b13, mixed mode, sharing)The version should be 1.6.something, possibly
0_26.C:\Users\username>javac -version javac 1.6.0_27
Using DrJava or another text edit, edit the file
/Users/username/.bashrc and add one line near the beginning of the file:
export CLASSPATH=.:/Users/username/introcs/
If the file doesn’t exist, create a new one.
Close the Terminal and open a new one.
See the Windows instructions for how to check that everything is working.
If it does not work, in addition, try repeating the same instructions with the file
/Users/username/.bash_profile
Preliminary instructions – we will explore this in lab.
C:\Users\username>java -version java version "1.6.0_27" Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0_27-b07) Java HotSpot(TM) Client VM (build 1.6.0_27-b13, mixed mode, sharing)Any version numbered like 1.6.any is ok.
C:\introcs.Note: We can now compile programs at the command prompt, but it is preferable to use DrJava. Pay attention to where you are saving and compiling, to avoid frustration about which copy of your program is running.
Open Applications -> Utilities -> Terminal
It works similarly to the command prompt in Windows but some commands have different names. Try reading the short tutorial on the Windows command prompt but when you try the commands yourself use these equivalents:
| win | mac | |
| dir | ls | (list directory) |
| move | mv | |
| copy | cp | |
| cd | cd | (change current directory) |
| more | more | |
| exit | exit | |
| java | java | |
| javac | javac | |
In OS/X, directory paths are written with forward/slash rather than backward\slash as in Windows.