June 29, 2012

Setting Up Eclipse with Java 1.6 on Windows


Step 1 - Download Java
Step 2 - Install Java
Step 3 - Set the PATH
Step 4 - Set the CLASSPATH
Step 5 - Test the Java installation
Step 6 - Download and install Eclipse
Step 7 - Test the Eclipse installation
Step 1     Download Java 1.6 package for Windows
Click the Download button alongside the label  JDK 6 Update 2 (or similar). On that page, accept the license agreement near the top of the page and download either the online or offline Windows Platform installation file. The offline option is a big file (c. 66MB) which includes all of the Java language and can be used to install even when an internet connection is not available. The online option is a small file (c. 0.4MB) that when run downloads Java over an internet connection as installation proceeds. It is recommended that you save the installer file to the Desktop so that it can be found easily. 



Step 2     Install the Java 1.6 package.
a. Double-click the file that you just downloaded. The name should be something similar to jdk-6u2-windows-i586-p.exe or, if you chose the online installation option,jdk-6u2-windows-i586-p-iftw.exe

b. Accept the License Agreement.

c. Accept all the default choices. In other words, just keep clicking "Next".

d. Wait for the installation to complete.



Step 3     Update the PATH environment variable.
(The following is adapted from Sun's Installation Notes for JDK 1.6 Microsoft Windows)

You can run the JDK without setting the PATH variable, or you can optionally set it as a convenience. To save yourself a lot of careful typing, it is highly recommended that you set the path variable.
Set the PATH variable if you want to be able to conveniently run the JDK executables (javac.exejava.exejavadoc.exe, etc.) from any directory without having to type the full path of the command. If you don't set the PATH variable, you need to specify the full path to the executable every time you run it, such as:
   C:> "\Program Files\Java\jdk1.6.0_\bin\javac" MyClass.java

It's useful to set the PATH permanently so it will persist after rebooting.
To set the PATH permanently, add the full path of the jdk1.6.0_\bin directory to the PATH variable. Typically this full path looks something like C:\Program Files\Java\jdk1.6.0_\bin, where  is a two-digit number. Set the PATH as follows, according to whether you are on Microsoft Windows NT, XP, 98, 2000, or ME.
Microsoft Windows NT, 2000, and XP - To set the PATH permanently:
  1. Choose Start, Settings, Control Panel, and double-click System. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows XP and 2000 select the Advanced tab and then Environment Variables. Look for "Path" in the User Variables and System Variables. If you're not sure where to add the path, add it to the right end of the "Path" in the User Variables. A typical value for PATH is:
       C:\Program Files\Java\jdk1.6.0_\bin 
    Where is the latest version number. For example, if you downloaded jdk1.6.0_02, then the value to add to the path is:
       C:\Program Files\Java\jdk1.6.0_02\bin 
                                                                                              Capitalization doesn't matter. Click "Set", "OK" or "Apply".The PATH can be a series of directories separated by semi-colons (;). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should only have one bin directory for a JDK in the path at a time (those following the first are ignored), so if one is already present, you can update it to jdk1.6.0_\bin.
  2. The new path takes effect in each new Command Prompt window you open after setting the PATH variable.
Microsoft Windows 98 - To set the PATH permanently, open the AUTOEXEC.BAT file and add or change the PATH statement as follows:
  1. Start the system editor. Choose "Start", "Run" and enter sysedit, then click OK. The system editor starts up with several windows showing. Go to the window that is displaying AUTOEXEC.BAT
  2. Look for the PATH statement. (If you don't have one, add one.) If you're not sure where to add the path, add it to the right end of the PATH. For example, in the following PATH statement, we have added the bin directory at the right end:
       PATH C:\WINDOWS;C:\WINDOWS\COMMAND;"C:\PROGRAM FILES\JAVA\JDK1.6.0_\BIN" 
    Capitalization doesn't matter. The PATH can be a series of directories separated by semi-colons (;). Microsoft Windows searches for programs in the PATH directories in order, from left to right. You should only have one bin directory for a JDK in the path at a time (those following the first are ignored), so if one is already present, you can update it to jdk1.6.0_.
  3. To make the path take effect in the current Command Prompt window, execute the following:
       C:> c:\autoexec.bat
    
        
    To find out the current value of your PATH, to see if it took effect, at the command prompt, type:
       C:> path
    
        
Microsoft Windows ME - To set the PATH permanently:
From the start menu, choose programs, accessories, system tools, and system information. This brings up a window titled "Microsoft Help and Support". From here, choose the tools menu, then select the system configuration utility. Click the environment tab, select PATH and press the edit button. Now add the JDK to your path as described in step b above. After you've added the location of the JDK to your PATH, save the changes and reboot your machine when prompted.



Step 4     Set the CLASSPATH environment variable.
The CLASSPATH variable tells Java where to look for *.class bytecode files. Bytecode is created when you compile your *.java files. Set the CLASSPATH as follows, according to whether you are on Microsoft Windows NT, XP, 98, 2000, or ME.
Microsoft Windows NT, 2000, and XP - To set the CLASSPATH:
  1. Choose Start, Settings, Control Panel, and double-click System. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows 2000 or XP select the Advanced tab and then Environment Variables. Look for "classpath" in the User Variables and System Variables, then click Edit. If no classpath variable exists, create it by clicking New and adding "classpath" to the User Variables. A typical value for CLASSPATH is:
       .;..
    The '.' represents your current directory, allowing you to compile and run code in your current directory (as shown in the command line of your command window). The '..' represents the folder above the current directory. Together, the '.' and '..' cover most situations where you need to compile and run programs. The semi-colon ';' separates these entries. The CLASSPATH can contain multiple directories separated by semi-colons. 
    Click "Set", "OK" or "Apply".
  2. The new classpath takes effect in each new Command Prompt window you open after setting the CLASSPATH variable. 
Microsoft Windows 98 - To set the CLASSPATH permanently, open the AUTOEXEC.BAT file and add or change the CLASSPATH statement as follows:
  1. Start the system editor. Choose "Start", "Run" and enter sysedit, then click OK. The system editor starts up with several windows showing. Go to the window that is displaying AUTOEXEC.BAT
  2. Look for the CLASSPATH statement. (If you don't have one, add one.) The classpath should contain a '.' and a '..'. If you're not sure where to add them, put them at the right end of the CLASSPATH. For example, in the following CLASSPATH statement, we have added the '.' and '..' directories at the right end:
       CLASSPATH C:\someFolder\someClasses.jar;..;.
    The '.' represents your current directory, allowing you to compile and run code in your current directory (as shown in the command line of your command window). The '..' represents the folder above the current directory. Together, the '.' and '..' cover most situations where you need to compile and run programs. The semi-colon ';' separates these entries. The CLASSPATH can contain multiple directories separated by semi-colons.
  3. To make the classpath take effect in the current Command Prompt window, execute the following:
       C:> c:\autoexec.bat
    To find out the current value of your CLASSPATH, to see if it took effect, at the command prompt, type:
       C:> classpath
        
Microsoft Windows ME - To set the CLASSPATH permanently:
From the start menu, choose programs, accessories, system tools, and system information. This brings up a window titled "Microsoft Help and Support". From here, choose the tools menu, then select the system configuration utility. Click the environment tab, select CLASSPATH and press the edit button. Now add '.' and '..' to your path as described in step b above. Then save the changes and reboot your machine when prompted.


Step 5     Test your Java installation.

a. Open a command window and create a test directory.

    1. Go to Start >> Run... then type cmd and click OK.
    2. Type cd \ and press Enter.
    3. The bottom line should read C:\>
    4. Type mkdir test and press Enter to create a new directory for your testing.
    5. Type cd testand press Enter to enter the directory. The bottom line of the command window should read  C:\test>

      b. Open a text editor and create a small Java program.
      Open WordPad or NotePad (in XP these can be found at Start >> All Programs >> Accessories) and copy in the following simple program:
      public class MyTestApplication {
      
        public static void main(String[] args) {
      
          System.out.println("Hello World!");
        }
      }

      c. Save the program in the test directory. 

      In the text editor menu, choose File >> Save. Then in the File Name field near the bottom of the dialog box, type the following exactly -

         C:\test\MyTestApplication.java
      and click Save.


      d. Confirm the save.
      In your command window, type dir. You should see something similar to -

      C:\test>dir
       Volume in drive C has no label.
       Volume Serial Number is 3C4D-5998

       Directory of C:\test

      29/01/2006  08:20 PM   
                .
      29/01/2006  08:20 PM              ..
      29/01/2006  08:20 PM               129 MyTestApplication.java
                     1 File(s)            129 bytes
                     2 Dir(s)  59,076,812,800 bytes free

      C:\test>


      e. Compile the program.
      Type javac MyTestApplication.java and press Enter. You should see -
      C:\test>javac MyTestApplication.java
      
      C:\test>
      There are two problems that you may encounter at this step.

      Problem 1
      If instead you get the following message -
      C:\test>javac MyTestApplication.java
      'javac' is not recognized as an internal or external command,
      operable program or batch file.
      
      C:\test>
      then Java has not been correctly installed. Perform the following tests :

          1) Check that Java has been correctly downloaded and installed. In particular, look for the directory
      C:\Program Files\Java\jdk1.6.0_\bin. If you cannot find a Java folder in the Program Files folder, then go back to Step 1 now.

          2) Check that the PATH variable has been set correctly. Type echo %path%. You should see something similar to -
      C:\test>echo %path%
      C:\Perl\bin\;c:\programfiles\imagemagick;C:\texmf\miktex\bin;C:\WINDOWS\system32
      ;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Contr
      ol Panel;C:\Program Files\SecureCRT\;C:\Program Files\Java\jdk1.6.0_02\bin
      
      C:\test>
      If you do not see an entry anywhere in your PATH similar to the one above in bold, then go back to Step 3 now.


      Problem 2
      If instead you get the following message -
      C:\test>javac MyTestApplication.java
      error: cannot read: MyTestApplication.java
      1 error
      
      C:\test>
      then either the CLASSPATH variable is not set or your file is not in the test folder. Perform the following tests:

          1) Check that the CLASSPATH variable has been set correctly. Type echo %classpath%. You should see something similar to -
      C:\test>echo %classpath%
      .;..;C:\someFolder\someClasses.jar
      
      C:\test>
      Note that the classpath may have been automatically updated to contain the location of various class files, and therefore may be longer than the example above. Just make sure that it contains a '.' with a ';' to separate it from other entries. Go back to Step 4 above to edit the classpath.

         2) Make sure you are in the test folder. If you are not, then use the cd command to navigate to the test folder. Once you are in the test folder, type dir at the command line to examine its contents. If you do not see an entry for MyTestApplication.java then Go back to Step 5b above.


      f. Confirm the compilation.
      Type  dir. You should see something similar to -
      C:\test>dir
       Volume in drive C has no label.
       Volume Serial Number is 3C4D-5998
      
       Directory of C:\test
      
      29/01/2006  08:28 PM              .
      29/01/2006  08:28 PM              ..
      29/01/2006  08:28 PM               440 MyTestApplication.class
      29/01/2006  08:20 PM               129 MyTestApplication.java
                     2 File(s)            569 bytes
                     2 Dir(s)  59,076,796,416 bytes free
      
      C:\test>
      If compilation was successful, a *.class file should be present as shown.


      g. Run the program.

      Type java MyTestApplication to run the program. You should see -
      C:\test>java MyTestApplication
      Hello World!
      
      C:\test>
      There is one common problem at this step.

      Problem
      If you get the following message -
      C:\>java MyTestApplication
      Exception in thread "main" java.lang.NoClassDefFoundError: MyTestApplication
      
      C:\>
      then either your class file is not in the test folder (type dir at the command line to make sure), or you are in the wrong directory as in this example, where the javacommand has been typed in C: rather than C:\testGo back to Step 5b above and make sure that you have performed all steps correctly.



      Step 6     
      Download and install Eclipse.
      1. Download Eclipse from the Eclipse downloads page.
      2. Click the link next to "Download now".
      3. If possible, choose a mirror close to your location (e.g. Portland, if you are in Vancouver).
      4. Wait for your download to finish. This may take some time: the installer is a large file (>100MB).
      5. Unzip the downloaded file to C:\Program Files. Again, this may take some time.
      6. In C:\Program Files\eclipse, right-click on eclipse.exe and select Create Shortcut. Rename the shortcut to eclipse and drag it to your Desktop. Then close theeclipse folder.
      7. On the Desktop, double-click on the eclipse shortcut to start the program.
      8. Workspace Launcher dialog will appear. Select "Use this as the default and do not ask again" and click OK.
      9. Eclipse will start up. Either explore the Overview, Tutorials, etc. or close the Welcome page by clicking on the white X to reveal the Java perspective, where you will do your programming.
      Now set up Eclipse to use the latest version of Java for compiling and running your Java programs. 
      (Note: you need to configure Eclipse to use Java 1.6 or it will use an older Java version by default)
      1. Set the default installed JRE to Java 1.6 (this tells Eclipse which libraries to use):
        • Open the Eclipse Preferences Pane (Window -> Preferences) and go to the Java >> Installed JREs subpane.
        • Check the JRE 1.6.0_ as the default (where is a two digit number representing the version number that you downloaded and installed)
        • Click OK to save the settings.
      2. Set the Java compiler to Java 1.6 (this tells Eclipse which compiler to use):
        • In Eclipse Preferences Pane go to Java >> Compiler >> Compliance Level
        • Select "6.0".
        • Click OK to save the settings.
      Eclipse should then be set up properly to compile and run Java 1.6 programs. 


      Step 7     Test the Eclipse installation.

      Create a new Java project with a class and run it.
      1. In the Java Perspective, right-click in Eclipse's Package Explorer window and select New >> Project....
      2. Select Java Project and Next.
      3. Name the project whatever you like (e.g. 'test'). For now the other options do not matter; just click on Finish.
      4. In the Package Explorer window, right-click on the test package and select New >> Class.
      5. Name the class MyTestApplication. For now the other options do not matter; just click on Finish.
      6. Delete everything in the editor that appears. Copy the following into the editor:
      public class MyTestApplication {
      
        public static void main(String[] args) {
      
          System.out.println("Hello World!");
        }
      }
      7.  In the Eclipse menu bar, select File >> Save. If everything is working properly this program should compile automatically without errors.
      8  Run the program by right-clicking on the MyTextApplication class in the package manager, then select Run As >> Java Application.

        "Hello World!" should appear in the console output.

        20 comments:

        1. Some of the benefits of the student loans. It would not be able to take on the road ahead.
          This will give you additional information on the student loans lacks some of the
          world's great IT hubs, which means it protects all devices used on the web. Google has a remarkable stash of information on the types at compile time. He recommends keeping abreast of what people want to be and not necessarily who they actually are. First, let's look first at how student loans download speed testing works.


          my homepage Private Student Loans for People

          ReplyDelete
        2. scar treatment Boyes

          Here is my web blog - Steprock scar treatment

          ReplyDelete
        3. scar treatment Ackerly

          My blog post :: Lincolnville scar treatment

          ReplyDelete
        4. rosacea doctor Cedar Mountain

          my blog post :: Thousand Palms rosacea specialist

          ReplyDelete
        5. Since the admin of this website is working, no doubt
          very shortly it will be renowned, due to its quality contents.


          Feel free to surf to my blog post ... professional seo company

          ReplyDelete
        6. Wonderful items fгom you, man. I've consider your stuff prior to and you are just too wonderful. I actually like what you have received here, really like what you are stating and the best way through which you say it. You're mаκing it entertаіnіng and уou still taκe carе of to ѕtaу it ѕеnsible.
          I cant wait to learn much mоre from уou. This is actuаlly a tremendous web sіte.



          Alsο visit mу blog ... moringa benefits

          ReplyDelete
        7. No matter that from which site you have purchased the coupons as great deals and offers are always available on every purchase.
          Since it can be found and used online, it is convenient
          for anyone those who shop online as these codes are readily available
          online for use with your purchases. There are websites that offer shedders at lower than wholesale
          rates and even get cash back offers, discount coupons,
          or free shipping. Vaseline Coupon 2013 Chilis Coupons
          2013 Kids Eat Free.

          Also visit my web-site ... Flipkart Coupons

          ReplyDelete
        8. Good day! I could have sworn I've been to this site before but after browsing through some of the post I realized it's new to me.
          Nonetheless, I'm definitely happy I found it and I'll be book-marking and checking back
          often!

          Look into my site: cute cheap clothes

          ReplyDelete
        9. Hello, just wanted to tell you, I loved this blog post.
          It was practical. Keep on posting!

          Feel free to visit my site; Insanely priced Xen VPS offerings

          ReplyDelete
        10. Wonderful beat ! I wish to apprentice while you amend your website, how can i subscribe for a blog
          website? The account aided me a acceptable deal.
          I had been tiny bit acquainted of this your broadcast provided bright clear
          concept

          my homepage - Green Coffee Results

          ReplyDelete
        11. The basic concept behind this card was to get instant cash benefits along
          with great discounts. There have been various promotional strategies implemented by the
          major cellular service. The Big Indian Wedding ' Why Indian Weddings Are Costly Affairs. This also provides them an easy access to the expensive brands, otherwise not available in their town.

          Also visit my web-site: Flipkart Discount Coupons

          ReplyDelete
        12. Enjoy the depth you bought into listed here, i am going to have to use this as soon as achievable.


          Have a look at my web-site ... familiar

          ReplyDelete
        13. If you use any from the popular blogging platforms you might see that someone has already made the initial steps,
          and allowed the code that they intended to be used by other
          people, which would obviously save a lot of time. Might be a great time to choose several friends who not mind helping you take on this kind of task.
          Here's a fast action plan of how it is possible to get started. Of course, once you've
          such a online business, be sure to then use a really good website.


          Here is my site; How To Make A Website

          ReplyDelete
        14. Like the depth you got into below, i am going to have to
          use this as quickly as possible.

          Check out my webpage; could

          ReplyDelete
        15. is much safer and you can save more on every booking.
          HP is well known for its outstanding as well as qualitative products.
          Nobody can deny the fact that the country is no doubt the home
          of numerous mammals including Asian Elephants or Asiatic Lion.
          I always fall for them knowing darn well that I'm not going to
          save one penny.

          Here is my web-site ... eBay Coupon Code

          ReplyDelete
        16. SEO link building is the main focus of off-page online
          search engine optimization. It's an approach utilized to increase the
          exposure of a website organically. Organic traffic, or unsettled traffic,
          is produced with popular search engines. Since of this company's target high traffic keywords
          to attract their perfect audience. The clenched fist
          step in the online search engine optimization procedure is
          to discover these keywords and develop SEO articles around them.
          This portion of the SEO process is on-page optimization. After this is completed,
          it's time for SEO link building.

          ReplyDelete
        17. Thus, online shopping is quite a boon to many people who lead the modern,
          busy lifestyle. The high-end printers offer a very realistic reproduction of
          the photographs. Of course the extra money that you save on your shopping is received via
          Cashback. If you search for any coupons on the internet, you can be able to see
          that they will give you a heavy discount on their products.


          Have a look at my web page - Flipkart Coupon ()

          ReplyDelete
        18. Enjoy the depth you received into here, i'll have to use this as soon
          as probable.

          Also visit my web site :: top ()

          ReplyDelete
        19. Good web site you hаve here.. It�s hard to find
          excellent writing like youгѕ these days. I honestly appreciate people like
          you! Take care!!

          Feel frеe too ѵisit mmy blog :: pick up Artist

          ReplyDelete
        20. I constantly spent my half an hour tο read this blog�s сontent all
          the time along with a cup oof coffee.

          Allѕο visit my blog pot ... EciGlow

          ReplyDelete

        I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

        My Favorite Site's List

        #update below script more than 500 posts