You are on page 1of 6


How to use BlueJ

Writing Java Programs using BIueJ
Suppose you want to store your Java projects under the directory C:\CSC211. (If you are working in a DePaul computer Jab, you should store somewhere on the E: drive). 1. Create a folder/directory using Microsoft Explorer.

If this directory (say C:\CSC211) does not exist yet, use the Microsoft Explorer to create it. First start Explorer and go to C:\ (the root directory ofC drive). Then under File, select New, and Folder.


Wave Sound Text Document WirLZip File Microsoft Word Document Bitmap I mage Microsoft Publisher Document Microsoft PowerPoint Presentation Microsoft Excel Worksheet Briefcase Image Composer Document Desktop Labels Label Desktop Labels Database Microsoft Data Link

Change the name of the folder from ''New Folder" to "CSC211 ". 2. Invoke BlueJ. Start BlueJ by finding and double clicking on its icon If you followed the installation directions for home, it will have an icon on the desktop. In the computer labs, select Course Applications, CSC, then BlueJ. 3. Create a new project. In BlueJ's top menu bar, select Project and New .... to get the New Project Dialog. In Look In box, find and select the CSC211 folder that you created in Step 1. This may require you to go up/down the directory tree a few times. Enter the name of the project (say ''HelloWorld") in File name and click on Create.

I!BlueJ: Project HelioWorld Edit Tools View I!I~ 13 Help I IFufI View II.. and make sure that the Class radio button is selected. 4.. Create a new class. Click on the button New Class . Then click on the OK button . and an icon that looks like a piece of paper should appear.') Cancel The Project Display Area to the middle right should turn white.. to obtain the Create New Class Dialog.3/13/12 How to use BlueJ II!New Project look in: 13 I fLj CSC211 Files ofrype: All Files C..... Enter ''HelloWorld" in the Class N arne textbox.

For example.3/13/12 How to use BlueJ II!BlueJ: Create New Class: 13 Class Name: IHelloworld lass Type-------------. II!BlueJ: Project HelloW'orld Edit Tools View I!!II1i1lI3 Help Compile View I~ 11<>. a constructor HelloWorld. j!l Class V Abstract Class V Interface o Applet Ok Cancel A yellow icon with the lable HelloWorld and diagonal lines should appear. When you open the HelloWorld Class. Double click on the yellow HelloWorld icon to open the editor for 6. Select all of the code and delete it. but it is totally worthless. Open the editor for the class.<> 5. the HelloWorld program would be: . including an instance variable X. that c1ass. Modify the code for the class. This code may be interesting the first time you see it. Then add your code.. and the method named sampleMethod. you will see some sample code for the class.

Run the application.pdntln("Hello. 2001 public class Hellohlo~ld public static void main(~t~ing[] ~ystem.3/13/12 How to use BlueJ 5l HelioWorld Class Edit Tools Options I!!II1i1lI3 II II II filename: Hellohlo~ld. right click on the yellow Hello World icon. } a~gs) woddl"). look at the bottom of the monitor screen -. . ~ I ~I Edit Tools Options changed I syntax erors. out. Compile the c1ass. Autho~: John ~mith Date: ~eptembe~ 1. a~gs) woddl"). and select void main(args) to run the main method. 2001 lic class Hellohlo~ld public static void main(~t~ing[] ~ystem. ~f_la_s_s_c_o_m_p_il_e_d_-_no __~ a_x_e_rr_o_rs ~II I saved 8. Go back to the main BlueJ window.pdntln("Hello.there are two BlueJ windows." 5l HelioWorld Class I!!II1i1lI3 II II II Autho~: John ~mith Date: ~eptembe~ 1. If you don't see it on the desktop screen. Then. Click on the Compile button at the top of the editor. You should get the message "Class compiled .

and press Save... wor:ld! If you like to save the output to a :file.1 101 lEi ) You will get the Terminal Window with the message 'Hello. txt". . Since you don't have any connnand line arguments for this method. Note: If your program (or method) takes arguments and you want to enter them.====d'==='... select Options and Save to file. world!" ra I BlueJ: Terminal Window I!!II1i1lI3 Options Hello.. I!BlueJ: Method Call args) 13 lIOid main(string[] HelioWorld.main ( b". such as "output. You will get the Method Call Dialog.. Specify the name of the file in File name.:'i II.. simply click on OK.. type in values separated by connnas.3/13/12 How to use BlueJ II!BlueJ: Project HelioWorld Edit Tools View I!!II1i1lI3 Help New Class HelioWorld 1 new HelloWorldO void main(args) Compile View Open Editor Compile Remove I IF...

. The console window that opened when you invoked BlueJ should close automatically. and the MainBlueJ Window.. the Editor.M Save I All Files C.. Get out ofBlueJ.1 Cancel 9.') ~======================~ .. .3/13/12 How to use BlueJ 53 Save terminal text 13 look in: iU CSC211 Iii HelloWorld File name: Files of type: loutPut. Close the Terminal Window.