Latest version 

Java-based Exploratory Data Analysis for EEG

Java installation: Linux

 

Welcome

Getting started

For users

For developers

Introduction

If you are reading this, then you have probably been directed here from Java installation, as a result of discovering that you need to install Java.

Installation of Java is really quite easy, if you have done it a few times. However there are a number of considerations that make it impossible for me to provide explicit installation instructions that will work in all situations.

These questions are occasionally crucial to successful installation of Java. However much of the time the above questions will be irrelevant, or else you will be able to answer them with certainty. In particular, if your computer is self-managed, and doesn't yet have Java installed, then installation will be easy. In that case, go ahead with the installation of Java, making use of my notes below and adapting them where necessary to your situation and goals. But otherwise prudence should rule:

In order to install Java in less-than-ideal cases, it is extremely helpful to have system administration skills.

These non-trivial cases will require judgements to be made based on your context, and may require some trial and error. The judgements relate mainly to placement of directories, patching strategies, and ensuring the PATH is not messed up.

However Java does not touch anything to do with the operating system or desktop, so any problems you may have will be limited and reversible.

The following assumes you have 'root' privileges, don't have any pre-existing version of Java to deal with, and are doing an installation in the program area that is common to all users of your computer.

The two main installation alternatives are to use the version direct from Sun, or the repackaged version from your Linux version (CentOS, Debian etc). Both are acceptatable.

Manual installation

Downloads

The version from Sun is most definitive, and comes in several flavours: JRE which can run Java but not compile, JDK Micro Edition for embedded devices, JDK Standard Edition for most situations, and JDK Enterprise Edition for 'enterprise' situations. All four supply the crucial Java Runtime Environment (JRE), but only the latter three versions allow for compilation — essential for Jeda. These three have distinct specialized goals; accordingly, I recommend installing JDK SE, of which JDK 6 Update 16 is the current version. Sun offers JDK SE as a download, as well as offering other downloads where the JDK is bundled with other products: JavaFX, NetBeans, GlassFish and so on. Your choice. If you choose the basic JDK SE, then the downloaded file will have a name like jdk-6u16-linux-x64.bin (i586 and Itanium versions are also available).

Anyone intending to do Java programming should also download and install (a) the documentation for Java, and (b) Ant. The latter is a utility that is helpful for compiling Java. However if you are simply running Jeda (or the Jeda demo) as is, then these are not necessary, or can be added later.

Ant is available as a .zip, .tar.gz or .tar.bz2 archive file. Choose whichever you are most familiar with.

Installation of Java and Ant

The general plan is to install Java in a place that is common to all users, but doesn't interfere with any of the directories used by the package manager. This minimizes the chance of interference between Java and anything else on your system. I recommend installing everything (Java, the documentation, Ant) under a new directory /usr/java. This directory can then hold all these aspects of Java, plus new versions or each.

You need administrator privileges to perform the installation. So within a terminal window you will need to become root, one way or another: in RedHat-like systems you type su - followed by the root password; in Debian-like systems you type sudo -i followed by your own password (assuming you are a sudoer).

    mkdir /usr/java                # or whatever you like
    cd /usr/java

    # Move JDK to this directory and unpack
    mv <wherever>/jdk-6u16-linux-x64.bin .
    chmod +x jdk-6u16-linux-x64.bin
    ./jdk-6u16-linux-x64.bin
    # Scroll to the end of the license agreement and answer 'yes'
    # Watch the unpacking complete
    rm jdk-6u16-linux-x64.bin      # tidy up

    # Optional: Unpack documentation
    mv <wherever>/jdk-6-doc.zip .
    unzip jdk-6-doc.zip
    rm jdk-6-doc.zip

    # Optional: Unpack Ant (.tar.gz version)
    mv <wherever>/apache-ant-1.7.1-bin.tar.gz .
    tar xvf apache-ant-1.7.1-bin.tar.gz
    rm apache-ant-1.7.1-bin.tar.gz

    # Result will be that /usr/java now has three subdirectories:
    #   /usr/java/jdk1.6.0_16
    #   /usr/java/docs
    #   /usr/java/apache-ant-1.7.1

The above installation also provides the Java browser plugin. This plugin enables running of Java applets, which are sometimes embedded in web pages, e.g. my FFT Demo. (Note that Java and JavaScript are totally independent languages; so the present discussion has no impact on normal browser operation.) If you wish to link your browser to your new version of Java, then there a couple of intricate steps. My own experience is just with Firefox and Unbuntu, so you will probably need to adapt the following to your environment. [The organization of plugins appears to be in flux.]

    # On x86-32 systems
    cd /usr/lib/firefox/plugins   # or else /usr/lib/xulrunner-addons/plugins/
    rm libjavaplugin_oji.so       # if present
    ln -s /usr/java/jdk1.6.0_16/jre/plugin/i386/ns7/libjavaplugin_oji.so

    # On x86-64 systems, $JAVA_HOME/jre/lib/amd64/libjavaplugin_jni.so
    # exists, but doesn't do anything when linked to in the normal way.
    # However the following does work.
    cd /usr/lib/firefox/plugins   # or else /usr/lib/xulrunner-addons/plugins/
    rm libnpjp2.so                # if present
    ln -s /usr/java/jdk1.6.0_16/jre/lib/amd64/libnpjp2.so

Restart Firefox, enter the pseudo-URL about:plugins, and the browser will show whether the new version of Java has been found.

Environment variables

After installing Java, the final step is to add (or modify) your environment variables. These are a number of labelled values that are commonly used for system configuration. In the present context they are used to help the operating system find where Java was installed, and to help programs like Jeda to locate certain resources.

Linux users can simply edit their startup scripts. The goal is to set three new environment variables, and append to your PATH:

Variable Example value
JAVA_HOME /usr/java/jdk1.6.0_16
JAVA_BINDIR /usr/java/jdk1.6.0_16/bin
ANT_HOME /usr/java/apache-ant-1.7.1
PATH $PATH:$JAVA_HOME/bin:$ANT_HOME/bin
where the paths should obviously reflect your own installation choices. You only need to specify ANT_HOME if you had installed Ant. Note that the variable values should not have a '/' as their final character.

The lines to add to your startup script depend on what shell you use. For the Bash shell, I use the following:

  # Java
  export JAVA_HOME=/usr/java/jdk1.6.0_16
  export JAVA_BINDIR=${JAVA_HOME}/bin
  echo $PATH | /bin/grep -q -v $JAVA_BINDIR
  if [ $? -eq 0 ]; then export PATH="${PATH}:$JAVA_BINDIR"; fi

  # Ant
  export ANT_HOME=/usr/java/apache-ant-1.7.1
  echo $PATH | /bin/grep -q -v $ANT_HOME/bin
  if [ $? -eq 0 ]; then export PATH="${PATH}:$ANT_HOME/bin"; fi

The C Shell uses the syntax setenv var value instead of export var=value. Also the 'if' syntax is slightly different.

Changes to variables do not take effect until you open a new terminal.

To confirm that the PATH change was successful, open a terminal (and it shouldn't matter which folder you are in), and type the following:

   java -version           # version should be >= 1.5
   javac -version          # version should be >= 1.5
   ant -version            # version should be >= 1.7 [optional]

Installation via package management utility

This section describes installing Java from a repository specific to your Linux distribution.

Sun provides an RPM version of the JDK, with a name like jdk-6u16-linux-i586-rpm.bin. This may work in your environment. However it is hard to believe that it is 100% compatible with your particular package management system. Best avoided.

RedHat-style installation

Under RedHat, Fedora, SuSE and related distributions there are various package management utilities, of which rpm is the most fundamental, but yum is probably more common these days. If using yum, type

   su -c "yum install java-1.6.0-openjdk"    # I don't know about Sun's Java

This section need expanding ...

Debian-style installation

Under Debian, Ubuntu and related distributions there are various package management utilities, of which apt-get is the most fundamental. A full installation involves several packages. If using apt-get, then see what is available (apt-cache search 'sun-java') and type something like:

    sudo apt-get install sun-java6-bin
    sudo apt-get install sun-java6-doc
    sudo apt-get install sun-java6-fonts
    sudo apt-get install sun-java6-javadb    # optional
    sudo apt-get install sun-java6-jdk
    sudo apt-get install sun-java6-jre
    sudo apt-get install sun-java6-plugin
    sudo apt-get install ant                 # optional
    sudo apt-get install ant-doc             # optional
    sudo apt-get install ant-optional        # optional

Some Ant scripts look for the environment variable JAVA_HOME, so add JAVA_HOME="/usr/lib/jvm/java-6-sun" to the list of standard environment variables, /etc/environment. There are some relevant comments in /usr/share/doc/sun-java6-jre/.

Finally

Your distribution may implement a system allowing for multiple versions of packages: update-alternatives and JPackage are ones I have heard of. In the former case type update-alternatives --display group to see what is available, and update-alternatives --config group to switch between versions. The two relevant values for group are java and javac. (There is a front-end to this utility, update-java-alternatives.)

Finally, to confirm that the installation was successful, open a new terminal, and type the following:

   java -version           # version should be >= 1.5
   javac -version          # version should be >= 1.5
   ant -version            # version should be >= 1.7

If the version numbers are reported, and are sufficiently recent, then Java has been installed successfully. Proceed now with installing Jeda.

Alternative instructions

http://www.wikihow.com/Install-Java-on-Linux

Uninstalling

Should you ever wish to uninstall Java, and you followed the instructions above, then itcan be achieved thus:
  1. Delete the directory pointed to by JAVA_HOME
  2. Delete the part of your startup script dealing with the variables JAVA_HOME, JAVA_BINDIR and ANT_HOME
  3. Edit PATH to remove ";$JAVA_BINDIR" (or whatever you added)

 

Validate HTML CSS Last changed 2009-09-23 Chris Rennie