Chapter 2. Java Development

# Chapter 2. Java Development

## 2.1. What full-fledged Java development platforms are available in Debian?

If you are looking for an integrated, java virtual machine, compiler and runtime environment Debian does provide them. Of course that would depend on the Debian GNU/Linux version you are using, generally speaking they would be:

- Sun's OpenJDK 7, available since the Debian 8.0 Jessie release in the main section.

- Oracle's OpenJDK 8, available since the Debian 9.0 Strech release in the main section.

It is recommended to install one of the default-jdk or default-jre meta packages which installs the default version of OpenJDK for the current Debian version.

## 2.2. What free platforms are there and how can I contribute?

Please help one of the Free Java implementations if you want to use Java in Debian. There are a lot of projects that you can choose from:

- openjdk: https://openjdk.java.net/

- Mauve https://sources.redhat.com/mauve/ is a free suite to test if these tools are 'compliant'.

## 2.3. Questions on platforms and license concerns

### 2.3.1. Java 7 and 8

There are binary packages available for the Java 7 and Java 8 platforms since the Debian 8.0 ('Jessie') release and Debian 9.0 ('Stretch') release. Once this is done and you have updated your package database. You can either install the Java development kit in Jessie:

    apt-get install openjdk-7-jdk

or the Java runtime environment:

    apt-get install openjdk-7-jre

Similarly, you can install the Java 8 development kit in Stretch:

    apt-get install openjdk-8-jdk

or the Java 8 runtime environment:

    apt-get install openjdk-8-jre

You might want to update the alternatives system to have Sun's tools as the default:

    update-java-alternatives -s java-1.7.0-openjdk-amd64

Or for java 8:

    update-java-alternatives -s java-1.8.0-openjdk-amd64

### 2.3.2. Oracle proprietary JVM

Since the version 7 of the OpenJDK, the proprietary JVM developments are done on the OpenJDK. That means that the OpenJDK is strongly tested and high quality.

However, some users might want to use the Oracle JVM for the proprietary extensions (for example: the browser plugin). For such need, Debian provides a tool called java-package. The program make-jpkg will take an upstream archive and convert it to a Debian package. For example:

        make-jpkg jdk-6u31-linux-x64.bin

For more information see Oracle Technology Network Java.

## 2.4. Making Debian packages for Java programs.

### 2.4.1. Can the package go into main?

Yes, but only if it can be build and run with Java programs/tools in main, and if it has a Debian compliant open source license. If it needs programs from contrib or non-free, then is must go into contrib or non-free, depending on the license of the program itself.

### 2.4.2. Is there a good example Debian package?

There are many Debian packages of both Java applications and libraries. These may serve as an good starting point, as it can serve as an example for making a new Debian package.

A good start would be to check out the pkg-java project on Salsa: https://salsa.debian.org/java-team/.

Note that there are many ways to make a Debian package, making use of Ant or Makefiles does not really matter. But, some tips for good practice are given on the Debian Java packaging page: https://java.debian.net/.

### 2.4.3. What tools are available to make maintaining a Java packages easier?

Both cdbs and debhelper (dh9) have support for ant scripts. There are also a number of specialized tools or build helpers. Have a look at `javahelper` or `maven-debian-helper`.

### 2.4.4. Linking package Javadoc to system javadoc.

The java-policy mandates that documentation must be linked with the javadoc installed on the system. This can be done by passing javadoc the "-link" argument or by using the <link> tag in ant. An example:

    # command line example of linking against system doc.
    javadoc -link /usr/share/doc/default-jdk-doc/api [other arguments]

    <!-- Ant example of linking against system doc -->
    <javadoc [attributes]>
        <link href="/usr/share/doc/default-jdk-doc/api/" />
        [other tags]
    </javadoc>

The documentation must be installed at the time the linking is done; so in the example cases above the package would need a Build-Depends or a Build-Depends-Indep on `default-jdk-doc`.

Here is a short list of packages that can be used for reference:

- `libcommons-jci-java`

- `libhamcrest-java`

Chapter 1. Introduction |  | Chapter 3. Managing Java (for users and administrators)