Saturday, 2 August 2014

Setting up your Java environment


This is the most basic task that needs to be done before writing Java programs. I had written a couple of basic posts on Java to explain the basics which also includes downloading and installing Java.  Goal of this post is to list down steps to do so. This will be kept as a reference for all future posts.

Previous related posts

Steps to set up Java on your machine

  1. Download suitable Java distribution from  oracle site.
  2. Run the installer. 
    1. For Windows simple run the .exe file.
    2. For debian based system you can simply
      execute sudo apt-get install oracle-java7-installer
      from command line. 
  3. Next we need to add JAVA_HOME environment variable. Though not required for running standalone java programs. Many other software's use this to locate Java installation.   To do so follow the steps 
    1. Windows
      1. Open the System control panel
      2. Open Advanced tab
      3. Click on the Environment Variables button
      4. Add a new System variable with the name JAVA_HOME. Value should be the directory Java was installed in (something like C:\Program Files\Java\jdk1.7 
    2. Linux
      1. Refer How to permanently set $PATH on Linux?
      2. Path is above post is different, You should add your Java installation path (Something like /home/user/java/jdk1.7/bin)
  4. For windows when you run the installer java will be automatically added to %PATH% variable. You can easily verify that by executing following in cmd - java -version. If not added you can do so by adding %JAVA_HOME%\bin to your system path (assuming you followed step 3 else provide complete path).

No comments:

Post a Comment

t> UA-39527780-1 back to top