\section{Java}
Java is used by many mainstream software applications and software
development tools. As such, Java is often bundled with them. This
can result in several different Java Virtual Machines (JVMs), and
versions, installed on the same computer. To exacerbate the issue,
many Linux distributions (such as SUSE, Mandrake, RedHat, and Ubuntu)
install the OpenJDK, or IcedTea, and the GNU Compiler for Java (GCJ)
system-wide. This causes many other problems.
The following instructions describe how to install the Java Development
Kit (JDK) on a typical Linux distribution. You can adapt the commands
to other platforms.
To simplify the Java environment install and configure Java as follows:
\begin{enumerate}
\item Login to a user account.
\item Delete or uninstall all previous Java installations and Java compilers.
For example, type:
\begin{lyxcode}
sudo~aptitude~remove~openjdk-6-jdk~openjdk-6-jre
sudo~aptitude~remove~icedtea-6-jre-cacao~gcj
\end{lyxcode}
\item Download the JDK into \unixdirtemp{}.
\footnote{\href{http://www.oracle.com/technetwork/java/javase/downloads/}{http://www.oracle.com/technetwork/java/javase/downloads/}
}
\item Install the JDK.
\begin{enumerate}
\item Open a terminal.
\item Extract the contents of the JDK
\footnote{Change the version number where appropriate.
} archive into \unixdirrootprog{} as follows:
\footnote{Use \texttt{/opt/} for precompiled binaries, such as the JDK. Use
\texttt{/usr/local/} for manually compiled binaries.
}
\begin{lyxcode}
sudo~su~-
cd~\unixdirrootprog{}
chmod~+x~\unixdirtemp{}jdk{*}.bin
\unixdirtemp{}jdk{*}.bin
ln~-s~\unixdirrootprog{}\unixdirseparator{}jdk1.6.0\_24~\unixdirrootprog{}\unixdirseparator{}jdk
\end{lyxcode}
\end{enumerate}
The JDK is installed and a symbolic link is created. Note: To simplify
JDK upgrades, the symbolic link must not contain the version number.
\item Logout of the root account.
\item Edit \texttt{\$HOME}\unixdirseparator{}\texttt{.bashrc}.
\item Append the following text:
\begin{lyxcode}
JAVA\_HOME=\unixdirrootprog{}\unixdirseparator{}jdk
PATH=\$PATH:\$HOME\unixdirseparator{}bin:\$JAVA\_HOME\unixdirseparator{}bin
export~PATH~JAVA\_HOME
\end{lyxcode}
\item Save the file.
\item Either logout and login again, or type the following to update the
environment settings:
\begin{lyxcode}
source~\$HOME\unixdirseparator{}.bashrc
\end{lyxcode}
\end{enumerate}
After setting the \texttt{JAVA\_HOME} and \texttt{PATH} environment
variables, you will seldom need to change them again. All future JDK
upgrades are accomplished by following steps 3 and 4 (to download
and extract the JDK). In addition to simplicity, this installation
process has the following advantages:
\begin{itemize}
\item No other versions of Java are installed, which eliminates potential
conflicts.
\item You can install multiple JDKs; change the symbolic link to switch
between them.
\item All the files related to Java are located in a single location.
\item You know exactly what version of Java runs the applications.
\end{itemize}
As this installation method does not use the system package manager,
some applications (for example, LibreOffice) cannot reliably detect
the Java installation during their own installation process.