Java-11.0.2

#### Beyond Linux® From Scratch - Version 2019-02-27

### Chapter 13. Programming

- Prev

  Other Programming Tools

- Next

  OpenJDK-11.0.2

- Up
- Home

# Java-11.0.2

## 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 `HelloWorld.java`. The file name, HelloWorld, must match the class name. It is then converted into byte code with javac HelloWorld.java. 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-8.4 platform.

### Binary Package Information

- Binary download (x86): http://anduin.linuxfromscratch.org/BLFS/OpenJDK/OpenJDK-11.0.2/OpenJDK-11.0.2+9-i686-bin.tar.xz

- Download MD5 sum: 2b917647040e9804e0f3ccd51f40394b

- Download size (binary): 158 MB

- Estimated disk space required: 273 MB

- Binary download (x86_64): https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz

- Download MD5 sum: ce52c5844200c569a50a869e579d88f6

- Download size (binary): 179 MB

- Estimated disk space required: 296 MB

### Java Binary Runtime Dependencies

alsa-lib-1.1.8, Cups-2.2.10, giflib-5.1.6, 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-11.0.2+9-bin &&
    mv -v * /opt/OpenJDK-11.0.2+9-bin         &&
    chown -R root:root /opt/OpenJDK-11.0.2+9-bin

The binary version is now installed. You may create a symlink to that version by issuing, as the `root` user:

    ln -sfn OpenJDK-11.0.2+9-bin /opt/jdk

You may now proceed to Configuring the JAVA environment, where the instructions assume that the above link exists.

Last updated on 2019-02-18 01:33:36 -0600

- Prev

  Other Programming Tools

- Next

  OpenJDK-11.0.2

- Up
- Home