Pages

Install Java........

Install Java........
Java is Installing

Thursday 4 August 2011

How To Install Java on Windows:

In 4 easy steps i describe how to install Java.

1. Download either the JRE or the JDK.
2. Install.
3. Configure
4. Test.

1. Download either the JRE or the JDK:
    You have to download the JRE/JDK from Sun microsystems website.
To download the JRE click here.
To download the JDK click here.



2. Install:
    After downloading open the file to start the installer.
    It will install by itself, all you have to do is to continue by clicking next
    as you go through the setup. It is quite easy.

3. Configure:
    After installation, you have to configure the JDK in order for you to start development.
    In three easy steps:
    1. Right click the My Computer Icon on your Desktop and Click Properties.
    2. In the Option provided, Click the Advanced Tab(on Windows XP), this will be
        Advanced System Settings (Windows 7).
    3. Below you will see the Enviroment Variables button, Click it.

   4. Another Dialog Window Opens, in the dialog wondow, there are two options, the
       “User Variables” and the “System Variables”. We are working with the “System Variables”
       in the System Variables scroll down till you see the “Path”, Double click the “Path”,
       or highlight the “Path” and click Edit.


         Note: You have to be careful with this step, because if you edit the “Path” wrongly,
                   it might affect your “cmd(command prompt) commands ” because the cmd
                   uses the “Path” arguments to work with its command.

    5. Now go to the end of all the texts. At the end type a semicolon “;” and add the
        directory to the bin folder in the location where Java was installed on your system.
        Note: The bin folder will be located in “C:\Program Files\Java\jdk1.6.0_25\bin”
                 because i installed Java in the C: directory of my system, so this is what
                 i will be adding to the end of the Path’s text
                 “ ;C:\Program Files\Java\jdk1.6.0_25\bin ”.

    6.  Now Go to the CLASSPATH variable in the same System Varaibles,
         it is below the Path variable. If the CLASSPATH variable does not exist,
         create a new one by Clicking new, specify name as CLASSPATH and
         placing a period and semicolon “ .; ” then adding the location to the
         tools.jar file in the lib folder. But if the CLASSPATH as already been
         created, simply add a semicolon “ ; ” to the end of the text the same
         way you did for Path and the location to the tools.jar file.


        Note: The tools.jar file is in the lib folder which is located in
                  “C:\Program Files\Java\jdk1.6.0_25\lib\tools.jar” because
                  i installed java in the C: directory of my system, so this is what
                  i will be adding to the end of the CLASSPATH’s variable:
                  “ .;C:\Program Files\Java\jdk1.6.0_25\lib\tools.jar ” for New CLASSPATH.
                  “ ;C:\Program Files\Java\jdk1.6.0_25\lib\tools.jar ” for already
                  existing CLASSPATH.
                 Please don’t copy and paste the directory I specified here, it is just a guide, 
                 because, the location of your JDK might be different from mine.

    7. Now Click OK to complete the Configuration and OK again to
        exit the Advanced Tab;

4. Test:
    To test the Java configuration:
    1. Create a Java file in any Text Editor suitable for you.
        I'll advise you to use NotePad++ or Crimson Editor because of Keyword
        highlights and other nice features.
   2. Type the following code:
        public class Hello{
           public static void main(String[] args){
               Hello hello = new Hello();
                   System.out.println("Hello, Java was successfully installed");
           }
        }
  3. Save the file as Hello.java
  4. Open cmd (command prompt) and go to the current directory of where the file was saved.
  5. In the current directory, type "javac Hello.java" , this will compile the Hello.java file to the java byte code.
      Note: Be careful as you type and save the file as Java is case sensitive.
                It is safe to copy and paste the the code itself.
  6. After typing this nothing should happen, else if it displays any message, that means it has not compiled and
      something is wrong with your configuration.
  7. Type "java Hello" to run the application.
  8. You should see an output like this:


That is it, You have successfully installed Java on your System.

No comments:

Post a Comment