About Java

Java is different from most of the packages in LFS and BLFS. It is a programming language that works with files of byte codes to obtain instructions and executes then in a Java Virtual Machine (JVM). An introductory java program looks like:

public class HelloWorld 
    public static void main(String[] args) 
        System.out.println("Hello, World");

This program is saved as The file name, HelloWorld, must match the class name. It is then converted into byte code with javac The output file is HelloWorld.class. The program is executed with java HelloWorld. This creates a JVM and runs the code. The 'class' extension must not be specified.

Several class files can be combined into one file with the jar command. This is similar to the standard tar command. For instance, the command jar cf myjar.jar *.class will combine all class files in a directory into one jar file. These act as library files.

The JVM can search for and use classes in jar files automatically. It uses the CLASSPATH environment variable to search for jar files. This is a standard list of colon-separated directory names similar to the PATH environment variable.

Binary JDK Information

Creating a JVM from source requires a set of circular dependencies. The first thing that's needed is a set of programs called a Java Development Kit (JDK). This set of programs includes java, javac, jar, and several others. It also includes several base jar files.

To start, we set up a binary installation of the JDK created by the BLFS editors. It is installed in the /opt directory to allow for multiple installations, including a source based version.

This package is known to build and work properly using an LFS-7.5 platform.

Binary Package Information

Java Binary Runtime Dependencies

ATK-2.12.0, Cairo-1.12.16, Cups-1.7.2, gdk-pixbuf-2.30.7, giflib-5.0.6, GTK+-2.24.23, Little CMS-2.6, PulseAudio-5.0, and Xorg Libraries

Installation of the Java BinaryJDK

Begin by extracting the appropriate binary tarball for your architecture and changing to the extracted directory. Install the binary OpenJDK with the following commands as the root user:

install -vdm755 /opt/OpenJDK- &&
mv -v * /opt/OpenJDK-         &&
chown -R root:root /opt/OpenJDK-

Configure the temporary OpenJDK installation by issuing the following commands (note that if you logout and login back before having definitely configured OpenJDK-, you'll have to issue them again):

export CLASSPATH=.:/usr/share/java &&
export JAVA_HOME=/opt/OpenJDK- &&
export PATH="$PATH:/opt/OpenJDK-"

Do not forget to reboot or to source the profile file after modification.

The binary version is now installed. If you don't want to compile the sources, skip ahead to the Configuring OpenJDK section. Otherwise, continue to the JUnit-4.11, apache-ant-1.9.3, and OpenJDK- sections.

Last updated on 2014-03-29 20:32:20 +0000