Java: Creating the first program in Java



Now that you've installed the JDK and NetBeans
it's time to create your first Java program!


How to create the first program in Java

Open your NetBeans.
Go to File, then New.
You will see a number of options. That are the possibilities of programming in Java, etc. types of applications. In our case is 'Java' in 'Categories' in 'Projects' select 'Java Application'. Click Next.




Give the name of its project 'Project Name'. This is important.
Choose names easily, without stress and without spaces. Let's choose 'First'.

In 'Project Location' will be the folder where your projects will be stored. Then choose a place nice and easy too. Create a site as needed. Click Finish.




There, you will begin your first application in Java.

Note that a screen appeared with many things written.
In the future it will be useful for you, but for now, no.

I'll pass you the code to write, compile and see the result. After you explain every detail of the code, how it works, what is and such. Come on, delete whatever is there and type:

public class First {  
   public static void main(String[] args) {  
     System.out.println("My first Java program! ");  
   }  
 }

See that green arrow there? On the side of a hammer and a broom? If you rest the mouse over see 'Run Main Project'.
Click it.
Your project will be compiled and run.





The result of your program will appear on the screen beneath the phrase: 'My first Java program! "

If not, make sure you did not write anything wrong.

Here's a valuable tip: though I will show you the codes, always, but ALWAYS type your codes!
It's a habit that you has to have! Do not copyi and paste, you will not learn anything!
However, if you type all that is showed here, you will slowly memorizing and without making any effort, you will learn naturally.

If you have given an error, post in the comments area.
If you have given everything ok, congratulations, you've programmed in Java. In the next article will explain what you did, why it all happened, we will make some changes, will be wrong on purpose to NetBeans warn us of the error and try to fix etc..


1 comment:

Blogger said...

Did you know you can shorten your long urls with AdFly and get $$$$$ for every click on your shortened links.