Sunday, November 11, 2007

Setting up Java Development Environment on Ubuntu Gutsy, Part 2: Configuring Java Environment Variables on Ubuntu Gutsy

The default command line interface for Ubuntu Linux is called bash (Bourne Again Shell), and in order to add Java environment variables, we will edit a file named ".bashrc" and add our commands inside, here we go:

  1. Edit the ".bashrc" file by typing "sudo gedit .bashrc" which will open gedit; the famous Linux text editor in Read/Write mode (Note: If you don't use the keyword sudo to get administrative privileges, then the file will be opened in Read Only mode)
  2. Scroll to the end of the file and add your env. variables as in the following example which I used to define the JAVA_HOME env. variable:
    1. Append this line to the end of the .bashrc file: "export JAVA_HOME=/usr/lib/jvm/java-6-sun" where I point this variable to the location of my default JDK
    2. Save the file and exit and close the terminal
    3. Reopen the terminal and to check that everything went fine, type the following command: "echo $JAVA_HOME" which should result in displaying "/usr/lib/jvm/java-6-sun", otherwise, repeat the process again, you must have done something wrong.


Ala'a I. Mohamed said...

there is a version of JDK 6 bundled with netbeans,,just mark Aollow executing file as program in the properties permissions,& then start installing...done :):)

Ahmad Amr said...

I don't only use Netbeans, I use Eclipse as well, and so I won't download Netbeans to have the JDK for sure.