Hello everyone, i love to help out our community and as such i am willing to teach all users on the forum if they want, how to use java. I will be starting with the most basic form of java you could imagine and day by day progress to more and more advanced techniques. Below find a list of the tutorials so far:
Lesson 1 - Getting Started - Post 1
Lesson 2 - Introduction - Post 2
Lesson 3 - Variables - Post 3
Lesson 1
Getting Started.
In this tutorial we will be downloading the java development kit and a program called netbeans.These two things are going to allow you to jump right in and start learning Java.So the first thing you want to do is use a search engine such as google. Search for JDK
the first result should be something along the lines of Java SE Downloads @ oracle.com click on that link. You will see the below:
You want to click on the one that says NetBeans. ( JDK + Netbeans ) After clicking on that image/sqaure box you will come to a download page. Cick on the radio circle button that read "Accept License Agreement " then click on the appropriate installer for your operating system. Once its finished downloading its the usual installer, choose the location and accept the terms an conditions. So once you have that installed and you know it set up correctly you can move onto the next step.
We will need to set up something called Environment Variables. The way were going to do this is by clicking on Start then right click on computer to bring up a menu and then click on Properties. Once a new window opens up your going to click on 'Advanced System Settings' on the left side of your new window usually the bottom option in a list of 4 or 5. Another window around half the size of the last one will open and be called System Properties. If you on windows XP you will be on the first Tab called computer name and will need to click on the tab named Advanced. Anyone on xp or above should already be on the advanced tab. So click on a button near the bottom of the advanced tab called ' environment variables ' This will open an even smaller new window. What were doing here is providing java with the path to where it was installed, this basically means that when you run a java program it knows where to find the compiler and other nice things java can do.
So now leaving what we just opened aside for a moment dont close any of the windows. Click on start and click computer again. and go to the location i specify now: Computer >local disk > program files > Java > JDK 1.7? > bin. now make sure you click on program files not the x86 one and make sure if you have multiple jdk installs that you click on the latest version. If you have windows 7 you can right click on the address bar at the top and click ' copy address as text ' if you don't have windows 7 right click on any file in the bin folder and click on properties. In the general tab you will see the location of the file. You want to highlight this and copy it by either highlighting it then right clicking and selecting copy or use the short cut after highlighting it Ctrl+C
Once you do that you will want to go back to your Environment variables window we opened just a moment ago and click on the New button. ( the top one ). In the variable name box type PATH in capitals. Then right click in the box called Variable Name and select paste to put in the location of the bin folder. You can then hit ok, ok, ok to close all three windows.
So now that's all done we are going to test the installation of java and your Environment variables. Click on start once more and open up notepad (can be found under the Accessories folder ) Once its opened copy and paste the code below directly into notepad. Don't worry about whats going on in the code at all you will learn all this in the tutorials to come.
public class Test { public static void main (String [] args) { System.out.println("Hello World!"); }}
So now you should have this in your notepad file? great. Click on File at the top and select Save As. In the file name box type "Test.java" Yes do include the " " the parentheses are to make sure that the file is saved as a .java file and not as a .txt file. Just save it to your desktop for now so you can find it easily. So now you should have a little rectangle on your desktop with Test.java below it. Excellent! Now on to the next part, Press on the keyboard the windows key + R this will being up the run. Type into the open box 'cmd' without the single ' ' ' ' ' on each end. Now a big black box will come up named the command prompt. The last line in the box should say C:UsersYourUserName where YourUserName is your... you got it. We need to change the directory from your name to the desktop so type ' cd desktop ' you will see the directory change to your desktop. Now type ' javac Test.java ' the cursor will flash for a few seconds and then just show the directory once more if it has compiled correctly. What the compiler does is turn our code into a language the computer can understand and use. You will notice you have two files on your desktop now one called Test.java and now another called Test.class if you want you can open that in notepad and you will see all the weird symbols the computer uses. So now we have our .class file we can now run our program by click back onto the black cmd window and typing in ' java Test ' don't forget the capital T. We can see it now prints out Hello World! if you don't see this either because you changed the text or you get any errors or something like java does not recognized i recommend you go back and make sure you path variable is correct and your JDK is fully installed and if you get error messages such as cannot find symbol you should make sure you copied the code above exactly as i typed it with capital letters in the right place and symbols in the correct place.
Thats it for this tutorial, in the next lesson we will be doing an introduction to netbeans and going over the very basics of java.
Like this post if you followed it fine or liked what you read so far.
i will post the next one tomorrow