Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 3545

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Installing Java</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="
  MMBase Installation HOWTO
  "
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Installation"
HREF="x201.html"><LINK
REL="NEXT"
TITLE="Installing Tomcat"
HREF="x321.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
><SPAN
CLASS="application"
>MMBase</SPAN
> Installation HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x201.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x321.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="AEN212"
></A
>3. Installing <SPAN
CLASS="application"
>Java</SPAN
></H1
><P
>&#13;Download the latest versions of the
<SPAN
CLASS="application"
>Java 2 Development Kit
(<SPAN
CLASS="acronym"
>JDK</SPAN
>)</SPAN
> or
<SPAN
CLASS="application"
>Run-time Engine
(<SPAN
CLASS="acronym"
>JRE</SPAN
>)</SPAN
>,
and the accompanying documentation from:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;  <A
HREF="http://java.sun.com/"
TARGET="_top"
>http://java.sun.com</A
>
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Installation instructions and release notes for the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
> and
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JRE</SPAN
></SPAN
>
are available at the download page.
</P
><P
>&#13;Make the binary distribution of the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
>
executable
and extract in a new directory:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chmod +x jdk-xxx.bin
  cd /usr/local/
  .../jdk-xxx.bin
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Install the <SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
>
documentation
by unzipping it in the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
> directory:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  cd /usr/local/jdk-xxx/
  unzip .../jdk-xxx-doc.zip
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Change the ownership of the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
> directory
and make it available as
<TT
CLASS="filename"
>/usr/local/j2sdk/</TT
>:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chown -R root:root /usr/local/jdk-xxx/
  ln -s /usr/local/jdk-xxx /usr/local/j2sdk
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;If you need only the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JRE</SPAN
></SPAN
>,
the installation would be like this:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chmod +x jre-xxx.bin
  cd /usr/local/
  .../jre-xxx.bin
  chown -R root:root /usr/local/jre-xxx/
  ln -s /usr/local/jre-xxx /usr/local/j2re
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;<DIV
CLASS="warning"
><P
></P
><TABLE
CLASS="warning"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/warning.gif"
HSPACE="5"
ALT="Warning"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>&#13;Using <SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
>
version 1.5.0 caused
our <SPAN
CLASS="application"
>Tomcat</SPAN
> server
to crash every now and then:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  #
  # An unexpected error has been detected by HotSpot Virtual Machine:
  #
  #  SIGSEGV (0xb) at pc=0x4042db3f, pid=11991, tid=16386
  #
  # Java VM: Java HotSpot(TM) Server VM (1.5.0-b64 mixed mode)
  # Problematic frame:
  # V  [libjvm.so+0x3abb3f]
  #
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
Upgrading to version 1.5.0-01 seemed to solve these problems.
</P
></TD
></TR
></TABLE
></DIV
>
</P
><P
>&#13;<DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>&#13;For the (previously used)
<SPAN
CLASS="application"
>BlackDown Java for Linux distribution</SPAN
>:
</P
><P
>&#13;Find yourself a mirror for the
<SPAN
CLASS="application"
>BlackDown Java Development Kit</SPAN
>
at:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="screen"
>&#13;  <A
HREF="http://www.blackdown.org/java-linux/mirrors.html"
TARGET="_top"
>http://www.blackdown.org/java-linux/mirrors.html</A
>
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;There you can download the latest versions of the
<SPAN
CLASS="application"
>J2 Software Development Kit (<SPAN
CLASS="acronym"
>SDK</SPAN
>)</SPAN
>
and
<SPAN
CLASS="application"
>Run-time Engine (<SPAN
CLASS="acronym"
>RE</SPAN
>)</SPAN
>.
</P
><P
>&#13;Make sure you pick out the right version for the
<SPAN
CLASS="systemitem"
>gcc</SPAN
> library installed on your system.
You can find out the version currently installed by typing:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  rpm -q libgcc
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Installation instructions for the
<SPAN
CLASS="application"
>Java Development Kit</SPAN
>
are available as
<TT
CLASS="filename"
>INSTALL-j2sdk</TT
>
and <TT
CLASS="filename"
>INSTALL-j2re</TT
>.
</P
><P
>&#13;Make the binary distribution of the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>SDK</SPAN
></SPAN
>
executable
and extract in a new directory:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chmod +x j2sdk-xxx.bin
  cd /usr/local/
  .../j2sdk-xxx.bin
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Change the ownership of the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>J2SDK</SPAN
></SPAN
>
directory
and make it available as
<TT
CLASS="filename"
>/usr/local/j2sdk/</TT
>:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chown -R root:root /usr/local/j2sdk-xxx/
  ln -s /usr/local/j2sdk-xxx /usr/local/j2sdk
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Do the same for the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>RE</SPAN
></SPAN
>:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chmod +x j2re-xxx.bin
  cd /usr/local/
  .../j2re-xxx.bin
  chown -R root:root /usr/local/j2re-xxx/
  ln -s /usr/local/j2re-xxx /usr/local/j2re
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
></TD
></TR
></TABLE
></DIV
>
</P
><P
>&#13;Since we didn't install the
<SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
>
and <SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JRE</SPAN
></SPAN
>
in our path,
we have to add the <TT
CLASS="filename"
>bin/</TT
> directories
to our <TT
CLASS="envar"
>$PATH</TT
> environment variable.
To make sure the <SPAN
CLASS="application"
>Java</SPAN
>
distributions and classes can be found,
we set the <TT
CLASS="envar"
>$JAVA_HOME</TT
>
and <TT
CLASS="envar"
>$CLASSPATH</TT
> variables as well.
</P
><P
>&#13;For the <SPAN
CLASS="application"
>Bourne shells</SPAN
>,
create a file <SPAN
CLASS="systemitem"
>/etc/profile.d/java.sh</SPAN
>:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  if ! echo ${PATH} | grep -q /usr/local/j2sdk/bin ; then
    export PATH=/usr/local/j2sdk/bin:${PATH}
    fi
  if ! echo ${PATH} | grep -q /usr/local/j2re/bin ; then
    export PATH=/usr/local/j2re/bin:${PATH}
    fi
  export JAVA_HOME=/usr/local/j2sdk
  export CLASSPATH=.:/usr/local/j2sdk/lib/tools.jar:/usr/local/j2re/lib/rt.jar
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Set its ownership and access rights:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chown root:root /etc/profile.d/java.sh
  chmod 755 /etc/profile.d/java.sh
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Do the same for <SPAN
CLASS="application"
>C shells</SPAN
>,
by creating the file
<SPAN
CLASS="systemitem"
>/etc/profile.d/java.csh</SPAN
>:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  if ( "${path}" !~ */usr/local/j2sdk/bin* ) then
    set path = ( /usr/local/j2sdk/bin $path )
    endif
  if ( "${path}" !~ */usr/local/j2re/bin* ) then
    set path = ( /usr/local/j2re/bin $path )
    endif
  setenv JAVA_HOME /usr/local/j2sdk
  setenv CLASSPATH .:/usr/local/j2sdk/lib/tools.jar:/usr/local/j2re/lib/rt.jar
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;and setting its ownership and access rights:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  chown root:root /etc/profile.d/java.csh
  chmod 755 /etc/profile.d/java.csh
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;Now the <SPAN
CLASS="application"
><SPAN
CLASS="acronym"
>JDK</SPAN
></SPAN
>
should be available to everyone on your system.
</P
><P
>&#13;<DIV
CLASS="tip"
><P
></P
><TABLE
CLASS="tip"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/tip.gif"
HSPACE="5"
ALT="Tip"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>&#13;You can test the <SPAN
CLASS="application"
>Java</SPAN
> engine
by typing:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  java -version
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;or create a file <TT
CLASS="filename"
>Test.java</TT
>:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  public class Test {
    public static void main(String[] args) {
      System.out.println("Hello world");
      }
    }
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
>&#13;and test the compiler:
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="programlisting"
>&#13;  
  javac Test.java
  java Test
  
  </PRE
></FONT
></TD
></TR
></TABLE
>
</P
></TD
></TR
></TABLE
></DIV
>
</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x201.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x321.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Installation</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Installing <SPAN
CLASS="application"
>Tomcat</SPAN
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>