| Getting Started with Java | |
| 1 | It is imperative that all your Java applications (packages)
be stored in separate directories). I recommend that you keep all your
Java files below the C:\cis206
directory (you may wish to substitute
C for other drive). To create this directory, do this:
...
|
| 2 | Type cis206
and press
|
| 3 | You will next create another folder (test)
inside the cis206
folder. Do this:
...
|
| 4 |
... |
| 5 | You will now develop a Java program (SumOf.java)
using a text editor. Make sure that your C:\cis206\test
folder is open and do this:
|
| 6 | Right away type SumOf.java
over the default name and press
|
| 7 | Now, open the new file in a
text editor (Notepad or EditPad)**.
|
| 8 | Type the following Java program (another text editor can be used):
|
| 9 | Save the program (
|
| 10 | Try the following commands:
|
| 11 | In your next exercise, you will create batch files to simplify compilation and execution of your program. A batch file is a text file that may contain commands and control statements. It can be thought of as a shortcut. In Windows, batch files have the .bat extension. Switch back to Windows Explorer and create another text document.
...
|
| 12 |
Type comp.bat, press
|
| 13 | Right-click the batch file (
|
| 14 | The the command to compile your program:
|
| 15 | Save the file:
|
| 16 | You will now recycle this file to create another batch file (exec.bat). Modify the command so that it will look like the following one. Note that %1 and %2 represent arguments that will be supplied at the command line.
|
| 17 | Invoke the File > Save As command (not File > Save):
|
| 18 | Change the name of the file to exec.bat and click Save.
|
| 19 | Close the editor.
|
| 20 | Open the Command window again.
|
| 21 | Perform the following commands:
|
| 22 | Here is how it works with the exec.bat
command. The exec 10 20 command invokes
the exec.bat command, replacing the argument
%1 with a value of 10
and the argument %2 with a value of 20.,
thus creating command:
|
| 23 | Type exit and press
|
| This is it. | |
| *** | If there is no text editor in your Send
To folder, all you have to do is to create a shortcut of your preferred
editor there. In Windows 98, the Send
To folder is located in the C:\Windows
directory. In Windows XP/2000, you will find
such folder below the C:\Documents and Settings\UserName
directory****.
To add a shortcut of a program to the Send To folder, first locate the program (e.g. Notepad is usually in the C:\Windows directory), next make sure that both the program and the Send To folder are revealed, finally right-drag the program and drop it on the Send To folder. From the menu, select the Create Shortcut Here option. Return |
| **** | If you can't find the Send To
folder, it means that it is a hidden folder. In Windows
Explorer, go to Tools > Folder Options > View and turn on the Show hidden files and folder option. |