Java 101: Lesson 2 - First lines of code
Tuesday, October 21, 2008 2:59Hey, welcome to lesson 2 of Java 101, if you missed lesson 1, you can check it out here, now that you’ve got the necessary tools for making some java code we will start by doing the all time classic “Hello world” but you’ll need to know some things first:
For starters you will need to create a project, in NetBeans go to File and select New Project, After that select Java and then Java Application, just like the picture (The process is similar in all IDE’s)
After that fill the Project name and you are ready to go (By leaving the Create Main class box checked you are doing yourself a favor, just for now though)
Now you will have something like this, this is you coding environment, you’ll get used to it soon (Note: Maybe you have a package line at the beginning, just ignore this line and move on)
Ok, now, public class Main is like the project itself, as the name says is the main class, you’ll be writing your code here for now.
The public static void main(String[] args) class is like the test class, if you want to try something you’ll need to post it here.
We want to write the “Hello World” lines, so, if you want to write something in Java you can use the following sintaxys:
System.out.print(”What you want to write”); (Note: This “command” will leave the cursor at the same line, so if you write something next it will be written in the same line)
Or
System.out.println(”What you want to write”); (Note: This “command” will take the cursor a line down, so if you write something after this it will be written in a different line)
We can use either of them for this simple code, and because of the simplicity of the program just write directly in the public static void main class.
So your program should look like this:
Now click in the “Play” button (As the arrow is pointing) and your output box should look like this
Ok, you just made you first java program , its kind of stupid I know, but just keep reading the lessons and you will learn usefull things.
Don’t miss the next lesson, you can subscribe if you want to, but I don’t think you want… yet.














Computer Juice says:
April 22nd, 2009 at 9:30 pm
Great post! This is why I love blogging. Always something interesting to read, watch and enjoy. It keeps the mind active. Thanks, Amy x.
batty says:
June 30th, 2009 at 11:42 pm
this was a good tutorial i haven
Leontes says:
July 14th, 2009 at 8:30 pm
Sup? thanks a million for this great tutorial. It helped me improving my skills pretty much. It is always great to get some impressive inspiration and I hope to find more of such posts here soon because nobody will ever stop learning new things. Keep on
survey money says:
June 3rd, 2010 at 6:13 am
Thank you soooooooooooooooooo much for the great article. this was just the thing I needed today
Jeremiah Schomas says:
June 15th, 2010 at 4:24 pm
Super post – and great domain by the way:-)
Elijah Riise says:
June 16th, 2010 at 5:27 pm
Eating, loving, singing and digesting are, in fact, the four acts of the jocular opera known as individual, and they pass like bubbles of a grit of champagne. Whoever lets them contravene without having enjoyed them is a entire fool.
lenen zonder bkr toetsing says:
July 17th, 2010 at 8:46 am
BKR problemen? Nu Geld lenen zonder BKR toetsing? Op zoek naar betrouwbare aanbieders? Wij vergelijken banken die u toch kunnen helpen aan een betrouwbare
migraine says:
July 25th, 2010 at 3:42 am
Migraine is niet zomaar hoofdpijn. Migraine kan je leven totaal ontregelen en verzieken. De dreiging van migraine hangt dagelijks meer dan 10% van alle
lenen says:
July 30th, 2010 at 11:25 am
Lenen zonder BKR toetsing gaat vandaag heel gemakkelijk. Binnen een paar uur geld lenen zonder BKR toetsing doet u hier, lees snel verder