Java and BlueJ Information


Students programming in Java will use the BlueJ development environment on the individual electronic classroom machines. Hermes will be used to submit programs.

  • Using BlueJ to write and compile a Java program

  1. Locate BlueJ in the "Start" Menu. Once BlueJ loads, you'll notice that the BlueJ window has a menu bar on the top, a series of buttons on the left pane, a large main window in the right center pane, and an object bench along the bottom. The large window in the right center pane is used to show a class diagram for the currently opened package.

    the Bluej Main window

  2. From the "Project" Menu, select "New Project." A dialog box will appear asking you to enter the project name. You may choose any project name you desire, but it's strongly recommended that you do not include spaces or non-alphanumeric characters. Note that BlueJ will probably default to the "My Documents" directory to save this project; this is acceptable, but please delete your files when the contest is completed. In the following examples, I've created a project named "Hello".
  3. To create a new class, click the "New Class..." button on the left pane. Another dialog box will appear; enter the desired name of this Java class. (Remember that it is Java convention to name classes beginning with a capital letter.) In the following example, I've created a "Hello" class.

    Bluej with one class

  4. You should notice a new rectangle in the center right pane. (The gray diagonal lines indicate that this class has not been compiled since last changed.)
  5. Double click the class rectangle to open an editor window. You'll notice that BlueJ includes some "default" code. You should delete all of this code, except the "public class Hello" line (replace "Hello" with the name of your class):

    Bluej with one sample class loaded

  6. Enter your code; when you're ready to compile, simply click the "compile" button at the top of the editor window.

    Bluej with one sample class loaded



  • Using BlueJ to run a Java program
  •  
  • To run your program, close the editor window, (you should notice that the gray diagonal lines originally depicted on the class rectangle have disappeared), and right-click on the class rectangle. Then click the "void main(args)" option to run your program. A "method call" dialog box will then appear; just click "ok". BlueJ should open a console window as soon as it encounters a "System.out.print.." statement. This console window will serve as the means of screen output and keyboard input for your program.


  • Submitting a program

  •  
  • When you are ready to submit your program, open a web browser to the following address:
    http://online2.wcu.edu:8900
    Then follow these steps:
    1. Click on the "Click Here to Login" button near the top. A new page will appear.
    2. Enter the name of your team in the
      Username
      text field.
    3. Enter your team password in the
      Password
      text field. Your team password was given to you before the start of the contest.
    4. Click on the "Login" button. A new page will appear.
    5. In the section of the page labeled Courses is a course labeled Computer Science Programming Contest. Click on the link for that contest. A new page will appear.
    6. In the left pane of the new page is a list of categories. Click on the link that is for the category DropBox. A new page will appear.
    7. In the main pane (the right pane) of the new page is a list of the four contest programs. Click on the link that is the name of the program that you want to submit. A new page will appear.
    8. In the section of the main pane of the new page labeled Submit Assignment click the button labeled Upload File. A new page will appear.
    9. Click the Browse button. A dialog will appear. Use the dialog to navigate to the folder containing your BlueJ project. BlueJ places all the files for a project in a folder having the name of your project.
    10. Identify the file that you want to submit. You want to submit the Java source file for your program. The Java source file has the .java extension. BE SURE THAT YOU SUBMIT THE ".java" FILE! Windows will probably not show you the ".java" extension on your file, but if you hold your mouse over the file that seems to have no extension, you should be able to confirm the correct file is the ".java file."
    11. Select that file by clicking on its name once. This will cause the name to be highlighted. Click the Open button.
    12. You will have been returned to the previous page with the pathname of your Java source file in the text field. Click the Upload button to upload the file.


  • Additional BlueJ issues

  •  
  • When using the "readLine" method to read input from the keyboard, be sure to have a System.out.print... statement that executes before any call to readLine. The System.out.print... call tells BlueJ to open a console window; it's not smart enough to do this if a call is made to readLine first.
  • Closing the BlueJ console window DOES NOT terminate your program! If you need to prematurely end your program (i.e. in the case of an infinite loop, or you have a readLine statement before a System.out statement), reset the virtual machine by following these steps:
    1. Locate the horizontal "barber pole" in the main BlueJ window: If it shows red and gray stripes, your program is running. You can right-click this indicator and select "reset machine" to end your program.
    2. If that doesn't work, then close BlueJ, wait a few seconds, and open it back up.

    Bluej with app running