SmileyCookieMS
Would you like to react to this message? Create an account in a few clicks or log in to continue.


A fun MapleStory Private Server.
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log in  

 

 First JavaTutorial#1! Making The IDE do something! "Hello World!"

Go down 
2 posters
AuthorMessage
Zachy
Addicted Cookie
Zachy


Posts : 322
Points : 5703
Join date : 2009-07-12
Age : 32
Location : USA

First JavaTutorial#1! Making The IDE do something! "Hello World!" Empty
PostSubject: First JavaTutorial#1! Making The IDE do something! "Hello World!"   First JavaTutorial#1! Making The IDE do something! "Hello World!" EmptyFri Aug 14, 2009 2:01 pm

Okay. I assume you've read and understand the topic i posted about what you need to do before you even attempt any of my tutorials.

If you havent, Please read it here so i dont have to worry about useless errors -_-
______________________________________________________________________

Here we will start Smile

First, Understanding the layout of the program. I use DrJava(if you do not have it, re-read the above text -_-

When you have it open, You will see your main options on the top, The most you'll use is (obviously) New, Open, Save, Close, and the more complicated buttons are Compile, reset, and run.

On the left, You should see "(Untitled)", Thats where the files you have open are going to show up. You'll use this alot more as we go on.

To the right of that, you see where you're codes are going to be. This is the main element of the program.

Directly under that, you see the console, This is where you're programs outputs are going to show up. And, to the right of that, you'll see where you can choose what JDK to use(if you install more than one type of JDK).
______________________________________________________________________

Now that you understand the program, lets start coding~!
We'll make a simple hello world file.

Just to warn you all, Java is EXTREMELY Case sensitive,...
Soooo.

Start out by naming your class. Your filename will be the same as the class name for MOST of your files.

Code:
class HelloWorld{

As you see, I've also put an opening bracket at the end to open the main function. You will only be using one function for now, Once we get more complicated, you'll be using more.

So, Now, we initiate the main function by typing

Code:
 public static void main(String[] args) {

Honestly, i have no clue why its so long, its just the way i was taught.

JUST TO CATCH YOU UP IF YOU'RE LOST, You should currently have this.

Code:
 class HelloWorld{
  public static void main(String[] args){

Now, you've opened the main function and now its time to tell the computer what the function does.

Type:
Code:
 System.out.println("Hello World!");

println stands for print on a new line, as aposed to System.out.print("text");.

"print" just prints every character in the quotes.


SOooooooooooooooo

Now, you should have
Code:
 class HelloWorld{
  public static void main(String[] args){
    System.out.println("Hello World!");

From there, we're basically done, all we need to do now is close everything(Our brackets).

Since we have only 2 open, 'class helloworld{' and 'public static void main(String[] args){', So, To close those, all we have to do is put closing brackets '}'.

Put 1 "}" and press enter, Then put another and press enter. You' should have this so far:

Code:
 class HelloWorld{
  public static void main(String[] args){
    System.out.println("Hello World!");
    }
 }

NOW, Its time to see what you've just made in action!

Look for the "Compile" button, When you locate it, Press it.

It should tell you that you need to save the file, Save it wherever you want as long as you can remember where it is.

Now, Press RUN and look down at either the interactions tab, or the console tab. Very Happy.

You should see "Welcome to DrJava. Working directory is
> java HelloWorld
Hello World!" If you're looking at the interactions tab.

And just "Hello World!" if you're looking at the console tab.
_________________________________________________________________________________

Congratulations!

You've just made your first java program!


~Zachy


Last edited by Zachy on Fri Aug 14, 2009 9:12 pm; edited 1 time in total
Back to top Go down
[Admin]1337
Co-Owner~[Admin]1337
Co-Owner~[Admin]1337



Posts : 1101
Points : 2147488488
Join date : 2009-07-07

First JavaTutorial#1! Making The IDE do something! "Hello World!" Empty
PostSubject: Re: First JavaTutorial#1! Making The IDE do something! "Hello World!"   First JavaTutorial#1! Making The IDE do something! "Hello World!" EmptyFri Aug 14, 2009 3:52 pm

Rofl, Java looks hard D:
VB is so easy

btw
Best Accepted GM app ever
Back to top Go down
Zachy
Addicted Cookie
Zachy


Posts : 322
Points : 5703
Join date : 2009-07-12
Age : 32
Location : USA

First JavaTutorial#1! Making The IDE do something! "Hello World!" Empty
PostSubject: Re: First JavaTutorial#1! Making The IDE do something! "Hello World!"   First JavaTutorial#1! Making The IDE do something! "Hello World!" EmptyFri Aug 14, 2009 6:30 pm

Vb is actually kind of hard to me ._.
Back to top Go down
Sponsored content





First JavaTutorial#1! Making The IDE do something! "Hello World!" Empty
PostSubject: Re: First JavaTutorial#1! Making The IDE do something! "Hello World!"   First JavaTutorial#1! Making The IDE do something! "Hello World!" Empty

Back to top Go down
 
First JavaTutorial#1! Making The IDE do something! "Hello World!"
Back to top 
Page 1 of 1
 Similar topics
-
» JavaTutorial #3 If-Then and if-then-else statements :D
» JavaTutorial#4 Switch statements--fun :D
» Rules of "Food" forum
» Rules of "Music" Forum
» Currently Making an Installer

Permissions in this forum:You cannot reply to topics in this forum
SmileyCookieMS :: Programming :: Java-
Jump to: