Friday, January 16, 2015

Running first Java program 103


A bread with "hello world" imprinted in it

Hello everyone, welcome to a new edition of the Java tutorial. Now, we going to run the BlueJ test project of the previous tutorial and explain the basic things you need to know about it


Must Read:  What I Love About My Phone :)




Start up your BlueJ program. Once you start it, you should see a window that looks something like the image below:



A BlueJ window looks like





So let's try to run a project on BlueJ

Click Project > Open Project. The normal file open dialog box will appear. Open the examples folder you saved earlier, and within it, open the Hello project. You should see the project appear in the BlueJ window so that it looks something like the image below:




Must Read:  Welcome to Java Tutorial 101.. lol








The icon named Hello represents a simple Java program that writes the phrase, "Hello, world" to a window on the screen. The diagonal blue lines in the box mean that the program hasn't been compiled yet. So click the Compile button to tell BlueJ to compile the program.


The message Compiling will appear in the bottom left corner of the BlueJ window for a few seconds, and when the program has compiled, it'll change to Compiling . . . Done. The blue lines will also disappear from the Hello box. That means the program is compiled and ready to run.


To run it, right-click the Hello box and choose the second option from the drop-down menu, "void main(String [] args)" as in the image below. This is the signature of the program's main method, where the highest-level logic of the program goes, and where Java always starts when it executes a program.







Void main option within BlueJ



When you click that menu option, you'll see a Method Call dialog box open up like the one in the image below. This is a dialog box that BlueJ uses to run a Java method. Click OK to run the program.





When the program runs, all it does is display some text onscreen. BlueJ opens a new window, called the terminal window, to show you the text. We'll use this window for a lot of our programs' input and output. It should look like this:









running my first program on BlueJ


Congratulations! You've just compiled and run your first Java program!

Feel free to leave any suggestion in the comment box





And share ,like or tweet this if it's helpful to you. thanks 

No comments:

Post a Comment

we love to see your comment