7. Executing our First Java Program in BlueJ | Java Programming | Compiling and Creating java Program @techcomputergyaan Technical Magic
Executing our First Java Program in BlueJ
We are going to discuss
Comments in Java
Comments: Text ignored by the compiler
- To write some notes
- for future reference
- To find some errors
- we can make some statement as comment and can compile the program and in this way we can find errors in the program.
Way of writing Comments
// for single line comment
/* for multiple
line comments */
Create our First Project in BlueJ
Step 1: To open BlueJ
Step 2: Create new project
Step 3: Create New Class in Pascal case, I have created HelloJava
Step 4: Double click on HelloJava class. A new window in BlueJ with some codes will open.
You will see some comments and some codes written over here. So, I am going to delete everything and I will write only codes which is important for our first program.
So, here in the above screenshot you can see I have deleted everything except our HelloJava class. Now we will write code for our main() method.
So, here in the above screenshot you can see I have deleted everything except our HelloJava class. Now we will write code for our main() method.
Write and Run a Program in BlueJ
After writing our code now we can compile and run our code.
Now we will compile our program by clicking on compile.
At below of the window we will see the error. If there will be no error then it will show message: Class compiled: no syntax error.
To run our program in BlueJ
Right click on the class file. We will get some options. There we can see all the methods of the class. Here we have to run our program for the main() method. So we will click on void main(String args[])
After clicking on our main() method we can see our statement.
Here we can see the statement 4 times as I have run this program 4 times.
So in this way we can see it is easy to write compile and run our program in BlueJ IDE. Here we have also competed a program in Bluej.
Comments
Post a Comment