Java Environment Set Up Guide

Integrated Development Environments (IDEs) for Java

IDEs are not required to develop Java programs, but it is extremely helpful to use them.

  • NetBean
  • Eclipse
  • Once you have installed the either one of the above, you are good to write, compile and run Java programs. If you want to learn more about how Java technology works, you can keep reading the following which will show you how to set up Java environment for writing, compiling and running Java programs without an IDE.

    Before You Start

  • In order to compile and run Java program, Java Development Kit(jdk) is needed.
  • If you don’t have the jdk installed already, go download the appropriate version of jdk from the above link for your Operating System.
  • Once you have downloaded and installed the jdk on your system, refer to the following to set up the path for the operating system you are using.
  • JDK Path Set Up for Windows

    Windows 7: Start Menu -> System Properties -> Advanced System Settings -> Advanced tab
    Windows Vista: Right click My Computer -> Properties -> Advanced system Settings -> Advanced tab
    Windows xp: Start Menu -> Control Panel -> System -> Advanced tab
    Environment Variables -> System Variables -> PATH -> click on it.
    In the Edit windows, append the jdk path to the existing PATH.
    For example,
    if your jdk path is c:\Program Files\java\jdk
    add ;c:\Program Files\java\jdk to the end of your existing PATH variable, the semi-colon in front of your jdk path says you are appending the jdk path to the existing PATH.

    JDK Path Set Up for Mac

    For Mac, the jdk is usually already set up. To check, go to Applications -> Utilities -> Terminal

    java -version

    You should see information regarding the version of the java you have installed on your system.

    If you don’t have the jdk installed by default, download the jdk from Apple and install it.

    JDK Path Set Up for Linux

    To check if Java is in your path, type the following in the Terminal Window:

    java -version

    If you see information regarding the version of the java you have installed on your system, that means you have the java in your environment path.

    If you see COMMAND NOT FOUND, then do the following.

    Assume you have the java jdk installed at /usr/local/jdk1.6/bin

    Edit the startup file (.bashrc for bash shell) at your home directory, you can use the emacs editor

    emacs .bashrc

    Add the following two lines to the file

    export PATH

    Save and close the file, Ctr-x, Ctr-z
    Restart the Terminal Window
    Verify the PATH by type the following command

    java -version

    Compile and Run Java Programs

    Once you have installed JAVA JDK, you are good to compile and run Java programs in command prompt(Windows), Terminal(Mac/Linux). Assume you have a file called Hello.Java, cd into the directory where this java file is,

    To Compile, type the following and enter:


    Once you have compiled the java file, type the following and enter to run the program:

    java Hello

    Search within Codexpedia

    Custom Search

    Search the entire web

    Custom Search