Starters guide to Java.

DoPi

Onyx user!
Reputation
0
Ok, since I know, and still am, learning java, I will post a helpful tutorial on how to make your first Java program!

So first what you'll need is:
JDK(Java Development Kit)
That's about it o.o

Ok, so now let's start off by right-clicking on our desktop, and going to "New" and clicking "New Text Document"
60614965.png


Now name it "first" make sure the f is not capitalized.

Now, open that text document up and type this into it (Don't just C&P, you won't learn that way) and I will explain what the code means and does.

ALSO:for the first}'s DO NOT USE SPACES, USE THE TAB KEY!

Code:
/*
* First class for new java programmers
* Tutorial written by Javacisnotrecognized at runegear.net
* Enjoy :D
*/

class first {
    public static void main(String[] args) {
        System.out.println("My first program!"); // displays the text string
    }
}

Now, let's break this down into the basics

1) What you see in the /* */ is what we call a "Block Comment" which means when we compile our .java file the compiler will ignore it and not include it in the compiled .class

2) The code "public static void main(String[] args) {" means that is the main code line for this program, and it argues it *hence the agrs*

3) The code "System.out.println("My first program!");" means that when we compile the .java and run the .class it will display the text in the ("") and write it out.

Now that we have our code typed in we must save it as a .java file as so :
File > Save as... > save it as "first.java" without the ""s.
16263918.png


Now we want to move it to this directory:
C:\Program Files\Java\jdk1.6.0_VERSION#HERE\bin

Now that we have saved it to that directory.

Now what we do is go to:
Start > Run > cmd
28547189.png


and now we want to navigate to our JDK folder as so:
cd C:\Program Files\Java\jdk1.6.0_YOURVERSION#HERE\bin
42892661.png


Once we are here we want to execute this command in the CMD Prompt
Code:
javac first.java
17890147.png


it should look like that if you did it right, congratulations! you have made your first java program! WAIT! Don't close the CMD prompt yet, we have a tad bit more to do!

now we want to see the outcome of this long adventure?

right after you compile it type this command in:
Code:
java first

and the out come should be:
45727694.png


And that's your first Java program ever!

More tutorials from me coming soon!

enjoy Rune Gear!
 
Thanks for the guide, this is the first Java guide that I've done and followed correctly.
 
Yeah, I made this for natha's old forum, need to change some stuff around.
 
You might want to post some IDE's that are very useful when it comes to using Java.

-Eclipse
-NetBeans

or just use Notepad++

:) They are helpful as well.
 
Will do, might make a whole different thread for that stuff :p
 
Javacisnotrecognized said:
Will do, might make a whole different thread for that stuff :p

:)

I might beat you too it :p
 
Back
Top