Java Tutorial

If you have decided to learn an object-oriented programming language like Java, you might be exited and want to start right away. A Java Tutorial will show you how to make your first simple program and run it on your computer.
You need three things,
A compiler A good self-study book or a course Persistence There are three editions of Java. SE, ME and EE. You want the SE which is Standard Edition. The others are Mobile Edition and Enterprise Edition.
After you have downloaded and installed the JOE, you need to make one small change in your PC settings. You want the compiler to be accessible from the command prompt.
To do that you have to add the location of the program files to the PATH variable. 1: Click Start —■ Control Panel System ( assuming you use Windows XP) 2: Click Advanced —■ Environment Variables. 3, Find the location of the bin folder in your installation. You can do this by using the Explorer. Its a good idea to copy the path from there. It might be "C,ProgramsJavajdk1.6.0_23bin" 4, Add the location to the PATH variable. You probably already have a PATH variable, so choose Edit for that one add a semicolon in the end and the location you copied in step 3 You can test if it is working by opening a command prompt and type JAVAC. This should make the compiler run. Since you did not give file names as the parameter, it just shows you the help file. Now that you have the compiler working, it is time to make your first Java application. Open notepad or any other simple text editor and type in the following text exactly like shown here.
public class HelloWorld (public static void main (String 0 args) (System.out.println ("Hello World!");))
Then save the file as "HelloWorld.java" in the folder where you want to keep your Java projects. Make sure you don't save it with the.txt extension, even thou it is a text only file.
Go back to your command prompt and type,
javac HelloWorld.java
This will tell the Java compiler to translate the file you just made. If there are no errors, you will now have a file called "HelloWorld.class." This is the byte code version of your program. It cannot be run as you would do with an executable program file. Instead, you need the Java interpreter. You can test your program with the command,
java HelloWorld Note that you don't need the.Class extension. You should now get the output from your program, Hello World!
By doing this you will have made and tested your first Java program. It is recommended that you also try to make a small change, to get a feel for how things work. Of course, it is difficult now, as most of the code doesn't make much sense when you don't know Java yet. But you can change the text of the quotation marks to make the program print a different text.
To get to learn how to write Java programs, you will need a course or a good book. There are many available free books on the matter.

No comments: