Sunday, November 30, 2008

Install Java on Ubuntu

I thought this would be straight forward....

I tried to install using the apt-get command, but my install died when the license agreement took over my terminal, and did not give me a way to accept the agreement. I exited and ran the dpkg --configure -a command to clean up the failed install. 

Instead I went to the System>Synaptic Package Manager and performed the install this way: 
  • Specify "java" in the search box. A List of packages to install appears.
  • I chose the java5 jre, jdk and plugin, and accepted the installation of packages that they were dependent on. 
  • Click Apply
  • Accept the license agreements as they appear.
  • The java home directory will be in /usr/lib/jvm
Note: If the java versions do not appear in the above list, ensure that the /etc/apt/sources.list file contains the following entries : 

  • deb http://us.archive.ubuntu.com/ubuntu/ intrepid multiverse
  • deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid multiverse
  • deb http://us.archive.ubuntu.com/ubuntu/ intrepid-updates multiverse
  • deb-src http://us.archive.ubuntu.com/ubuntu/ intrepid-updates multiverse

You then need to ensure that this Java is the default java for the system: 
  • update-java-alternatives -s java-5-sun (specifies java 5 as the default)
  • update-java-alternatives -l (lists out the default)

Finally, add environmental variables. I add them in /etc/environment. You could also add them in your local .bashrc file in your home directory. The values specified in /etc/environment are in all shell. Be careful of the syntax in this file! If an error occurs you may not be able to boot up... : 

  • JAVA_HOME="/usr/lib/jvm/java-1.5.0-sun"
  • CLASSPATH="/usr/lib/jvm/java-1.5.0-sun/bin:/usr/lib/jvm/java-1.5.0-sun/lib"




No comments: