Tuesday, August 5, 2008

How to install Java in Ubuntu

sudo apt-get update

And finally, just tell it to install java :)

sudo apt-get install sun-java5-jdk


After this the rest of the process will display a dialog that will require you to accept the license agreement. When you do, the rest of the setup will happen on its own.

When you're on the command prompt type

javac -version

or

java -version

To Install jdk-6u5-linux-i586.bin:

download from http://15fwqxm1kxnjv9qge3r2.linux-packages.s3.amazonaws.com/jdk-6u5-linux-i586.bin
wget http://15fwqxm1kxnjv9qge3r2.linux-packages.s3.amazonaws.com/jdk-6u5-linux-i586.bin
-----------------------------------------------------------
Optional Runtime Dependencies:

ALSA Library-1.0.13: http://www.linuxfromscratch.org/blfs/view/svn/multimedia/alsa-lib.html
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.13.tar.bz2
./configure --enable-static &&
make
make install &&
install -v -m644 -D doc/asoundrc.txt \
/usr/share/doc/alsa-lib-1.0.13/asoundrc.txt
make doc
install -v -d -m755 /usr/share/doc/alsa-1.0.13/html &&
install -v -m644 doc/doxygen/html/* /usr/share/doc/alsa-1.0.13/html

CUPS-1.2.12: http://www.linuxfromscratch.org/blfs/view/svn/pst/cups.html
wget ftp://ftp.easysw.com/pub/cups/1.2.12/cups-1.2.12-source.tar.bz2
useradd -c "Print Service User" -d /dev/null -g lp -s /bin/false -u 9 lp
patch -Np1 -i ../cups-1.2.12-security_fixes-2.patch &&
./configure &&
make
make install
gunzip -v /usr/share/man/man{\
1/{cancel,cups{-config,test{dsc,ppd}},\
lp{,options,passwd,q,rm,r,stat}}.1,\
5/{{classes,client,cups-snmp,cupsd,printers,subscriptions,mailto}.conf,\
mime.{convs,types}}.5,\
7/{backend,filter}.7,\
8/{accept,cups{d,addsmb,enable,-{deviced,driverd,lpd,polld}},\
lp{admin,info,move,c}}.8}.gz &&

rm -v /usr/share/man/man8/{reject,cupsdisable}.8.gz &&

ln -v -s accept.8 /usr/share/man/man8/reject.8 &&

ln -v -s cupsenable.8 /usr/share/man/man8/cupsdisable.8
make install-cups

GTK+-2.10.13: http://www.linuxfromscratch.org/blfs/view/svn/x/gtk2.html
wget ftp://ftp.gtk.org/pub/gtk/v2.10/gtk+-2.10.13.tar.bz2
./configure --prefix=/usr --sysconfdir=/etc &&
make
make install &&
install -v -m755 -d /usr/share/doc/gtk+-2.10.13/{faq,tutorial} &&
cp -v -R docs/faq/html/* /usr/share/doc/gtk+-2.10.13/faq &&
cp -v -R docs/tutorial/html/* /usr/share/doc/gtk+-2.10.13/tutorial &&
install -v -m644 docs/*.txt /usr/share/doc/gtk+-2.10.13

----------------------------------------------------

chmod 755 jdk-6u5-linux-i586.bin

./jdk-6u5-linux-i586.bin


cd jdk1.6.0_05
install -v -m755 -d /opt/jdk-6u5 &&
mv -v * /opt/jdk-6u5
chown -v -R root:root /opt/jdk-6u5 &&
ln -v -sf xawt/libmawt.so /opt/jdk-6u5/jre/lib/i386/
cd ..
sed -i 's@XINERAMA@FAKEEXTN@g' \/opt/jdk-6u5/jre/lib/i386/xawt/libmawt.so

ln -sf xawt/libmawt.so /opt/jdk-6u5/jre/lib/i386/: This fixes linking issues with other applications that expect to find the motif libraries with the other JDK libraries.

Configuring JDK

As the root user, create a symlink to the installation directory:

ln -v -nsf jdk-6u5 /opt/jdk

The information below assumes your system is set up using the instructions found in “The Bash Shell Startup Files”. You may need to extract the relevant information below and incorporate it into your system's startup files if your system is set up differently.

Add the following jdk.sh shell startup file to the /etc/profile.d directory with the following commands as the root user:

cat > /etc/profile.d/jdk.sh << "EOF" # Begin /etc/profile.d/jdk.sh

# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk

# Adjust PATH
pathappend ${JAVA_HOME}/bin PATH

# Auto Java CLASSPATH
# Copy jar files to, or create symlinks in this directory
AUTO_CLASSPATH_DIR=/usr/lib/classpath
pathprepend . CLASSPATH
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
pathappend $dir CLASSPATH
done

export JAVA_HOME CLASSPATH
unset AUTO_CLASSPATH_DIR
unset dir

# End /etc/profile.d/jdk.sh

EOF

The Java plugin is located in $JAVA_HOME/jre/plugin/i?86/ns7/. Make a symbolic link to the file in that directory from your browser(s) plugins directory.



Choosing the default Java to use

apt-get install java-common
  • Open a Terminal window
  • Run sudo update-java-alternatives -l to see the current configuration and possibilities.

  • Run sudo update-java-alternatives -s XXXX to set the XXX java version as default. For Sun Java 6 this would be sudo update-java-alternatives -s java-6-sun

  • Run java -version to ensure that the correct version is being called.

You can also use the following command to interactively make the change;

  • Open a Terminal window
  • Run sudo update-alternatives --config java

  • Follow the onscreen prompt




AddThis Feed Button

No comments: