The Java Tutorials - Ch 1: Setting Up Java

Discussion in 'Code Snippets and Tutorials' started by Zer0, Aug 30, 2009.

  1. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    Previous Chapter: None
    Next Chapter: Logging into Neo

    The Java Tutorials - Chapter 1: Setting Up Java

    Table of Contents
    1. Getting the JDK
    2. Updating the PATH Variable (Windows only)
    3. Getting an IDE

    Getting the JDK
    Well you can't program in Java if you don't have Java installed (duh). People generally have something called the Java Runtime Environment (JRE) installed which allows them to run Java programs. However, in order to develop Java programs, you'll need to install the Java Development Kit (JDK). So let's get that up and running in your system.

    Go here: http://java.sun.com/javase/downloads/index.jsp
    Ignore most of the downloads and go straight to "Java SE Development Kit (JDK) > JDK 6 Update 16" (at the time of writing we are on Update 16 but that number may change). Download that and then install.

    If you run Linux, you should install the JDK via your package manager instead of from the download site. If you run a Mac, you should probably get the JDK from Apple's main site: http://developer.apple.com/java/download/

    Updating the PATH Variable (Windows only)
    In order to use the Java command-line tools, you'll need to update your PATH variable.
    Click Start > Control Panel > System > Advanced > Environment Variables

    Then you should see two sections: one for User Variables and one for System Variables. In both of those sections, you should see a variable called PATH. Edit both variables and add the location of your JDK installation.

    So for example, if you're PATH was initially
    Code (Text):
    1. C:/; C:/Documents and Settings
    change that to
    Code (Text):
    1. C:/; C:/Documents and Settings; C:\Program Files\Java\jdk1.6.0_<version>\bin
    and replace <version> with with the Java version you installed. Be sure to check the exact location of that bin/ folder so you get that correct.

    For complete installation notes on getting the JDK working on your system, read this: http://java.sun.com/javase/6/webnotes/i ... ndows.html
    I included all of the essentials here, but if you want more clarification, read that web page.

    Getting an IDE
    An Integrated Development Environment (IDE) is a powerful program that helps application developers immensely by providing them with development tools that speed up the programming process. You'll see what I mean when you write your first program ;)

    For Java, I recommend the Eclipse IDE and I will assume you will use it as well from now on. The tutorial is still valid if you choose not to use Eclipse, but some of the instructions will be off then.

    To get Eclipse, download it from their main website: http://www.eclipse.org/downloads/
    Download "Eclipse IDE for Java Developers (92 MB)" and install

    If you run Linux, you should install Eclipse via your package manager.
     
    tayloi and Phee like this.
  2. Phee

    Phee Moderator
    Staff Member

    Joined:
    Aug 18, 2007
    Messages:
    6,206
    Likes Received:
    101
    ...so I don't have PATH among either variables? Running XP.
     
  3. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    Then make a new variable named "PATH" :p
     
  4. Shawn

    Shawn Level IV

    Joined:
    Jul 15, 2009
    Messages:
    1,989
    Likes Received:
    76
    Location:
    Somewhere, lah.
    Thanks zer0
    what will be the end product of this tutorial
     
  5. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    The current plan is to have a 7 part tutorial. It'll end with making a fully functional Igloo autobuyer.
     
  6. Phee

    Phee Moderator
    Staff Member

    Joined:
    Aug 18, 2007
    Messages:
    6,206
    Likes Received:
    101
    Psh fine. Yay, part one done. Fuah that was super difficult.
     
  7. Shawn

    Shawn Level IV

    Joined:
    Jul 15, 2009
    Messages:
    1,989
    Likes Received:
    76
    Location:
    Somewhere, lah.
    Ok done. Awaiting part 2.
    That was easy, I'm going to be such a good Java developer

    EDIT: Then again, when I click Eclipse.exe, I get this alert.
    A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: C:\Documents and Settings\User\Desktop\eclipse-java-galileo-SR1-win32\eclipse\jre\bin\javaw.exe in your current PATH.

    I realise there's not even a folder called "jre" in the folder "eclipse"

    EDIT EDIT: Ok I found out I had to put this in the same folder as the JDK
     
  8. retroz4life

    retroz4life Newbie

    Joined:
    Dec 16, 2009
    Messages:
    2
    Likes Received:
    0
    do u have any other examples or snippets of data that the public could use?
     
  9. Skinny

    Skinny Newbie

    Joined:
    Apr 10, 2010
    Messages:
    13
    Likes Received:
    0
    I'm learning java in school but I had no clue how to set it up at home. Hopefully this well set me off into the right direction :)
     
  10. arcrutus

    arcrutus Level I

    Joined:
    Jun 28, 2010
    Messages:
    140
    Likes Received:
    2
    Alright Zer0, you've got me set up and ready to go! Now what?!

    I've recently determined that learning Java is a number one priority for me and I'd absolutely love to see a few new parts to this series!

    Can't wait for more!
     
  11. Kaito

    Kaito Level IV

    Joined:
    Jun 29, 2007
    Messages:
    2,692
    Likes Received:
    15
    part two coming out anytime soon? :D
     
  12. PrinceErik

    PrinceErik Level IV

    Joined:
    Jan 13, 2009
    Messages:
    889
    Likes Received:
    68
    hahah thats a good question Kaito, we should get on him about that :p