Refer to the lecture notes where necessary to find out how to do the commands used in this tutorial.
List the files in your home directory.
Create a sub directory for Programming Environment. Short meaningful names are best as you end up typing them a lot e.g. pe, progenv, PE or ProgEnv
To create a subdirectory use the mkdir (make directory) command. Type the following command substituting an appropriate name for the directory:
mkdir ProgEnv
List the files in your home directory. A directory for programming environment should now appear.
Change directory to your new Programming Environment directory. To do this use the cd (change directory) command. Type the following command substituting an appropriate name for the directory:
cd ProgEnv
List the files in your programming environment directory. It should be empty. Now list all of the files in the directory (what command option is used for this?). The "." and ".." should be listed.
The programming environment directory (folder) is to help organise your work, in future put all work for Programming Environment in this directory.
Create a sub directory in the Programming Environments directory for your tutorials.
Create a sub directory in the Programming Environments directory for your assignments.
Draw your new directories on the following directory tree:
Example: Directory tree (partial)
/
|
+----+----+----+----+
| | | | |
bin dev etc tmp Users
|
|
+----------+----------------+
| |
cjcope
|
--+------+-+---------+
| | |
Pictures Public Music
|
+--------+--------
| |
Welcome.java lecture17.html
Use the directory tree above to help with the following questions.
Write the paths for the following:
Write commands for the following, then try them:
Change directory to your tutorials directory.
List all of the files in cjcope's Public directory.
Copy the file Welcome.java from cjcope's Public directory to your tutorial directory using an absolute path. Have a look at the directory tree drawn above to see where the file is located. Type the following command, making sure you include the dot at the end:
cp /Users/cjcope/Public/Welcome.java .
Also copy the file lecture17.html from cjcope's Public directory to your tutorials directory.
View Welcome.java using cat.
Have a look over the program. It looks different to Visual Basic, but as you'll see in later lectures many of the things learnt in earlier lectures on VB will be applicable to Java. The program just displays the message "Welcome to Java programming".
View the file using less.
Now lets try a longer file to see the difference between cat and less.
View the file lecture17.html using cat
View the file lecture17.html using less. Try the less commands shown in the lecture. e.g. use the space key to move forward one window of text at a time. Use q to quit (exit more).
Some commands are shown below. Try them.
gedit is a useful text editor. Text editors can be used to create source code for programs or web pages. gedit provides are number of features that are useful to programmers. Set the preferences for gedit as specified in the lecture. Remember you can use firefox to view the lecture notes, tutorials etc..
Open the file Welcome.java using gedit.
The name of the file is displayed in the title bar of the gedit window.
Change the comment for the Author to your name.
Change the "Welcome to Java programming" message to "Hello World".
Notice that an "*" appeared in front of the file name in the title bar. This shows that changes to the file haven't been saved yet.
What is the shortcut key for Save?
Save the changes, using the shortcut key for Save. Check that the * disappeared
from the title bar.
What are the shortcut keys for Cut, Copy and Paste?
Use the shortcut keys to Copy and Paste the line commencing System.out.println,
so that it appears 5 times. .
Save the changes.
Exit gedit
Further investigate the commands covered in the lecture.
If you haven't set up a web browser, see the previous tutorial and set one up. Have a browse.
Written by Tim Whitfort (and Chris Cope).