Getting Started with Visual J++

Creating a New Project
  1. Create a folder on your disk where your COMP 14 programs will reside. Calling it something like Comp14 is a good idea. If you are using a public machine, you will save your programs onto a diskette.
  2. Launch Microsoft Visual J++ 6.0 by pressing the Start button, then selecting Programs, then UNC Courseware, then Comp 14, and finally, Microsoft Visual J++ 6.0
  3. The first screen has three tabs: New, Existing, and Recent. Click on New.
  4. On the left side of the window, click on Visual J++ Projects.  On the right side of the window, click on Empty Project.
  5. Replace the Name field with the name of the project (usually something like Assignment1, Assignment2, etc.)
  6. Click on Browse and click on the folder or diskette in which you want to store the program.
  7. Click on the Open button.
  8. You should now see the Project Explorer window. If you don't see it, go to the View menu (on the top) and select Project Explorer. For example, if the project name was Program1, the Project Explorer window should look like the figure below.

Adding a New Class
  1. Right click on the project name in the Project Explorer window.  Select Add, then Add Class from the submenu.
  2. In the Add Item window, click on Class on the left and click on ClassMain on the right.  Give your new class its proper name (specified in the assignment).  Click on Open.
Building the Project
  1. Save the program by selecting Save All from the File menu. Save your program periodically. If the machine crashes, you may lose everything you did since your last save, so saving every five or ten minutes is a good habit.
  2. Select Build from the Build menu. You should see a "Solution update succeeded" message at the bottom of the screen, and the Task List window should show no errors. If the Task List window is not visible, you can make it appear with the View menu, then the Other Windows submenu. If there are errors, double clicking on the error message will show you the (approximate) location of the error. Fix the error and build again.
  3. Continue the build and fix cycle until all errors are corrected and the update succeeds.
Running the Program
    If you don't know what the command prompt is --
  1. Select Start from the Debug menu. A dialog box titled [name of project] Properties will appear.  ([name of project] should be replaced with the name of your current project.)  Check the "Launch as a console application" box.  Then click OK.  This should start your program running. 
  2. A window will appear, executing your program.  When the program has completed execution, press Enter to close the window.
    If you do know what the command prompt is --
  1. Bring up a command prompt window.   If you're in the lab, DON'T use the "COMP 14 command prompt" under "UNC Courseware."
  2. Change to the directory where your project exists.
  3. Type "dir" to get a listing of the files in that directory to make sure you type the filename exactly.
  4. Type "jview [name of class with main].class" and press Enter. (Replace [name of class with main] with the name of the class that contains the main() method.
  5. The program will execute in the current window.  When the program has completed execution, press Enter to close the window.
Saving the Program to Turn-in

You only need to turn in files in your project directory that end in ".java" and ".class".

    If you're building your project on a hard drive --
  1. Bring up either "My Computer" or "Windows Explorer" and change to the directory where your current project exists.
  2. Select all of the ".java" and ".class" files (press the Ctrl key as you click the mouse to select multiple files).
  3. Select Copy from the Edit menu to copy the files.
  4. Change directories to the A:/ drive.
  5. Select Paste from the Edit menu to paste the files to your disk.
    If you're building your project on a floppy disk --
  1. Follow steps 1-3 above. the directory where your current project exists.
  2. Change directories to a folder on the hard drive that you can write files to.
  3. Select Paste from the Edit menu to paste the files to the hard disk.
  4. Put the disk you want to turn in into the floppy drive.
  5. Follow steps 2-5 to copy the files from the hard drive to the floppy drive.
Making a Backup Copy to a Floppy Disk
    If you're building your project on a hard drive --
  1. Bring up either "My Computer" or "Windows Explorer" and change to the directory where your current project exists.
  2. Go back one directory, by pressing the button that has an arrow inside a folder on the toolbar.
  3. Select the folder that contains your project.
  4. Select Copy from the Edit menu.
  5. Change directories to the A:/ drive.
  6. Select Paste from the Edit menu to paste the folder and all of its files to the floppy disk.
    If you're building the project on a floppy disk --
  1. Follow steps 1-4 above.
  2. Change directories to a folder on the hard drive that you can write files to.
  3. Select Paste from the Edit menu to paste the folder to the hard disk.
  4. Put your backup disk into the floppy drive.
  5. Follow steps 3-6 to copy the folder from the hard drive to the floppy drive.

Michele Clark
clark@cs.unc.edu

Back to COMP 14