Debian Java FAQ. ---------------- Torsten Werner Niels Thykier Javier Fernández-Sanguino Peña Sylvestre Ledru $Revision: 10410 $, $Date: 2014-05-22 20:20:16 +0000 (Thu, 22 May 2014) $ ------------------------------------------------------------------------------- Abstract -------- Answers to Frequently Asked Questions on Debian and Java. Any changes/corrections to this FAQ are appreciated. Please send them to the Debian Bug Tracking System as described in Section 1.3, `Sending bugs on this FAQ'. Copyright Notice ---------------- This document may be freely redistributed or modified in any form provided your changes are clearly documented. This document may be redistributed for fee or free, and may be modified (including translation from one type of media or file format to another or from one spoken language to another) provided that all changes from the original are clearly marked as such. ------------------------------------------------------------------------------- Contents -------- 1. Introduction 1.1. Introduction to this FAQ 1.2. Location of this FAQ 1.3. Sending bugs on this FAQ 1.4. What is Java? 1.5. Where can I ask questions about Java on Debian? 1.6. Complementary information 1.7. Uncovered issues 2. Java Development 2.1. What full-fledged Java development platforms are available in Debian? 2.2. What free platforms are there and how can I contribute? 2.3. Questions on platforms and license concerns 2.4. Making Debian packages for Java programs. 3. Managing Java (for users and administrators) 4. Java Virtual Machines (JVM) 4.1. What JVMs are available in Debian? 4.2. What Java Compilers are available in Debian? 4.3. What API do these JVMs provide? 4.4. Are there known problems? 4.5. How can I use the proprietary version of the JDK/JRE from Oracle as a Debian package? 4.6. Do I need a JVM to run a Java program in Debian? 5. Java Plugins for Browsers 6. Java Servlets 6.1. How can I make Java servlets work? 7. Java Policy 7.1. Is there a Java policy for Debian? 7.2. Are there holes in the Java Policy? 8. Other Java alternatives for Debian 8.1. Java programs not yet available on Debian ------------------------------------------------------------------------------- 1. Introduction --------------- 1.1. Introduction to this FAQ ----------------------------- This FAQ was started by Javier Fernández-Sanguino who on February 1st, 2000 was enough to send a message to the debian-java mailing list with the subject "How about a Debian-Java-FAQ?". Of course, since "every idea is a responsibility" he had to do this himself looking through the three month-long archive of the newborn mailing list. The purpose of this FAQ is to be a place to look for all kinds of questions a developer or user might have regarding Java as far as Debian is concerned. It includes license issues, development packages available, and programs related to building a Free Software Java environment. Thanks go to all the (many) contributors from the debian-java mailing list, who have made this document possible. Without their knowledge this FAQ would not be at all possible since I only have a vague knowledge of what they're talking about when I browse the list. Special thanks go to Paul Reavis, whose previous Debian-JDK informational page I used to add more information, and who made useful suggestions to this document. Also to Peter Moulder who revised thoroughly the FAQ and provided many suggestions, to Juergen Kreileder, maintainer of Blackdown's debian packages who pointed out some mistakes, and to Egon Willighagen, who has provided quite a lot of proper patches to update its content. This document does not address issues with other Linux distributions, or with non-Debian-specific problems. 1.2. Location of this FAQ ------------------------- This FAQ is published under the Debian Documentation Project at http://www.debian.org/doc/manuals/debian-java-faq/. The `java-common' (available at http://packages.debian.org/java-common) provides an HTML version for offline reading. The package version does not provide Text and PDF versions currently (if you want them please submit a bug 'wishlist' to the package). Also, the web version might be more up-to-date than the package's offline version. Sources for this FAQ and its translation are available in a Subversion repository. They can be found here: http://anonscm.debian.org/viewvc/ddp/manuals/trunk/java-faq/ 1.3. Sending bugs on this FAQ ----------------------------- Please note that this FAQ might be, sometimes, outdated but it gets updated step by step. Contributors (you included!) help improve the content and keep it up-to-date. Please file bug reports against the java-common package if you find errors or have suggestions on how to improve this document. However, make sure first you are reading the latest version. If you are reading a translator, look first if the issue you have found does exist also in the original english version. You can always find the latest verion online version of the english text available at http://www.debian.org/doc/manuals/debian-java-faq/. Please, check it before filing a bug report. Translations, if available, and the offline version in the java-common package might be out of date. You can also check if the issue you have found has already been reported. To do this, please browse through the bugs you will find in java-common's list of reported bugs (bugs.debian.org/java-common). Bugs on this FAQ, either for the english version or its translations, can be filed using Debian's Bug Tracking System (https://www.debian.org/Bugs/). Please report the bugs against the `java-common' package. 1.4. What is Java? ------------------ Java is a programming language originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. Since May 2007, Sun/Oracle with some partners like Red Hat provide a free implementation released under the GNU GPL called OpenJDK. More information can be found at Wikipedia (http://en.wikipedia.org/wiki/Java_%28programming_language%29). 1.5. Where can I ask questions about Java on Debian? ---------------------------------------------------- The appropriate place to ask such questions is . You can subscribe at the Debian Mailing Lists (http://lists.debian.org/debian-java/) page. 1.6. Complementary information ------------------------------ Users might want to access some online sources to complement the information available in this FAQ which might be, sometimes, too out of date. The main source of information is the Java entry (http://wiki.debian.org/Java) at the Debian's wiki. Since Ubuntu is based on Debian, some users might find it helpful to check the tips on Installing Java (https://help.ubuntu.com/community/Java) on Ubuntu's wiki. 1.7. Uncovered issues --------------------- This FAQ does not describe some issues due to lack of time and/or information. If you are able to help in any of these, please, provide them to the documentation maintainer: * Information on how to setup a fully working Servlet engine (Application Server) using Apache and Tomcat or information on how to setup non-free application servers (such as WebSphere) in Debian. * Specific information targeted for non-i386 users (PowerPC users and AMD64 users), some can be found in Ubuntu's wiki. ------------------------------------------------------------------------------- 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 6, available since the Debian 5.0 _Lenny_ release in the _main_ section. * Oracle's OpenJDK 7, available since the Debian 7.0 _Wheezy_ release in the _main_ section. * The combination GCJ, GIJ, and Classpath in the _main_ section. It is recommended to install one of the default-jdk or default-jre meta packages which either installs OpenJDK or GCJ depending on the architecture and 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: http://openjdk.java.net/ * gcj and libgcj: http://gcc.gnu.org/java/ * Classpath http://www.classpath.org. Most of the Standard classes for Java 1.2 (except Swing and RMI) are implemented by the ClassPath project, it tries to build an alternative to jdk's 1.2 core classes. (NB: This was removed from Squeeze) * Mauve http://sources.redhat.com/mauve/ is a free suite to test if these tools are 'compliant'. Most free Java development is grouped under the Free Java Project (http://www.gnu.org/software/java/). 2.3. Questions on platforms and license concerns ------------------------------------------------ 2.3.1. Java 6 and 7 ------------------- There are binary packages available for the Java 6 and Java 7 platforms since the Debian 7.0 ('wheezy') release. Once this is done and you have updated your package database. You can either install the Java development kit: apt-get install openjdk-6-jdk or the Java runtime environment: apt-get install openjdk-6-jre Similarly, you can install the Java 7 development kit: apt-get install openjdk-7-jdk or the Java 7 runtime environment: apt-get install openjdk-7-jre You might want to update the alternatives system to have Sun's tools as the default: update-java-alternatives -s java-1.6.0-openjdk-amd64 Or for java 7: update-java-alternatives -s java-1.7.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 (http://packages.debian.org/sid/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 (http://www.oracle.com/technetwork/java/index.html). 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 Alioth: http://pkg-java.alioth.debian.org/. 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 pkg-java page: http://pkg-java.alioth.debian.org/developers.html#rules and http://pkg-java.alioth.debian.org/building.html. 2.4.3. What tools are available to make maintaining a Java packages easier? --------------------------------------------------------------------------- Both cdbs and debhelper (dh7) 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'. `gcj-jdk' also has a dh_javadoc tool. 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 tag in ant. An example: # command line example of linking against system doc. javadoc -link /usr/share/doc/default-jdk-doc/api [other arguments] [other tags] 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: * `commons-jci' * `ow-util-ant-tasks' * `libhamcrest-java' * `libfreemarker-java' ------------------------------------------------------------------------------- 3. Managing Java (for users and administrators) ----------------------------------------------- By default Java programs shipped with Debian will use the java in PATH. Some of them may respect the JAVA_HOME variable (usually only if upstream supports this) or have command line arguments to select a different java implementation. Unfortunately not all java implementations work as well as others. So some times it may be necessary to change the current java and Debian provides an easy way to change the default java in PATH by using update-java-alternatives (from the `java-common'). Some examples of how to do this are: # List available java implementations $ update-java-alternatives --list # Use openjdk-6 $ update-java-alternatives --set java-6-openjdk # Use the non-free sun java. $ update-java-alternatives --set java-6-sun # Use the non-free sun java only for the web plugin $ update-java-alternatives --plugin --set java-6-sun For more information, please read the manpage (or the --help output) of update-java-alternatives. Also please note that update-java-alternatives is a frontend for update-alternatives. ------------------------------------------------------------------------------- 4. Java Virtual Machines (JVM) ------------------------------ 4.1. What JVMs are available in Debian? --------------------------------------- The following JVMs are currently available in Debian Wheezy: * `openjdk-6-jre' * `openjdk-7-jre' * `gcj-4.7-jre' The following lists JVMs available in Debian 6.0 release ('Squeeze'): * `openjdk-6-jre' * `sun-java6-jre' (non-free) * `gcj-4.4-jre' 4.2. What Java Compilers are available in Debian? ------------------------------------------------- * `openjdk-6-jdk' * `openjdk-7-jdk' * `gcj'. Compiles Java source to native code, also source to bytecode, or bytecode to native code. Please note that the support of the Java language is not completed. 4.3. What API do these JVMs provide? ------------------------------------ Note that providing an API does not mean that everything is implemented, and certainly not implemented correctly. 4.4. Are there known problems? ------------------------------ Yes, there are. Some of these are reported as Debian bugs. You can look up the bugs for a specific Debian package at the Debian Bug Tracking System (http://www.debian.org/Bugs/). As a quick link, here are some packages: * java-common (http://bugs.debian.org/java-common) * openjdk-6 (http://bugs.debian.org/src:openjdk-6) * openjdk-7 (http://bugs.debian.org/src:openjdk-7) * gcj-4.7 (http://bugs.debian.org/src:gcj-4.7) As common within the Debian project, the developers would appreciate good bug reports on found problems. These include the good description of the problem, the command that gives the problem, the errors given when running the command, and any other information that might be relevant. A good tool to report bugs is `reportbug'. 4.5. How can I use the proprietary version of the JDK/JRE from Oracle as a Debian package? ---------------------------------------------------------------------------- The package java-package (http://packages.debian.org/wheezy/java-package/) provides an easy way to convert an upstream installer into a Debian package. It should be as easy as: make-jpkg ~/Downloads/jdk-6u31-linux-x64.bin For more information, see this Blog article (http://sylvestre.ledru.info/blog/2012/02/29/java_package_replacement_of_sun_java6) 4.6. Do I need a JVM to run a Java program in Debian? ----------------------------------------------------- No, you can try to run the applications without a jvm by compiling the source code to native code is. However, the usage of the OpenJDK is recommended. For example, gcj does not provide any support of Swing (the Java GUI API). 4.6.1. How do I compile to native code? --------------------------------------- You might be able to use `gcj' to compile the program. And use `gcj' to convert bytecode to native code. The entire software chain is free. ------------------------------------------------------------------------------- 5. Java Plugins for Browsers ---------------------------- * You can install the package icedtea-6-plugin or icedtea-7-plugin in _wheezy_ ------------------------------------------------------------------------------- 6. Java Servlets ---------------- 6.1. How can I make Java servlets work? --------------------------------------- You can use: * Apache `tomcat6' from http://tomcat.apache.org. * Eclipse `jetty' from http://www.eclipse.org/jetty/. ------------------------------------------------------------------------------- 7. Java Policy -------------- 7.1. Is there a Java policy for Debian? --------------------------------------- It is still in the works. The current policy addresses _some_ of the problems. It has not been officially released. You can find it at http://www.debian.org/doc/packaging-manuals/java-policy/. The Java Policy can also be found in the `java-common' package. 7.2. Are there holes in the Java Policy? ---------------------------------------- Yes, some until under discussion. Please check out the bugs against the java-common package (http://bugs.debian.org/java-common). Thus it is _very_ inconvenient to use several compilers of virtual machines since there is not one CLASSPATH setting for all of them. ------------------------------------------------------------------------------- 8. Other Java alternatives for Debian ------------------------------------- If the Java packages provided in Debian are not sufficient for your needs you might need to take a look at other alternatives. Please understand that these alternatives are not supported by the Debian project directly, you might get help, however, from the debian-java mailing list if you encounter issues with them. Some of the alternatives presented use Debian packages which is convenient, since the user/administrator does not need to care on installation issues. However, mixing packages that come from a source which is not the Debian project might cause conflicts with your installation some times. Of course, Debian tries to integrate as many free software efforts as possible, so some of the alternatives described below might (if license permits) be included in Debian in the near future. 8.1. Java programs not yet available on Debian ---------------------------------------------- The following are programs that have not yet been packaged for Debian nor is there an installer. There are quite a lot Java programs out there. A list of missing packages is maintained on the Debian Wiki - Java Packaging Wishlist (http://wiki.debian.org/Java/RequestedPackages). ------------------------------------------------------------------------------- Debian Java FAQ. Torsten Werner Niels Thykier Javier Fernández-Sanguino Peña Sylvestre Ledru $Revision: 10410 $, $Date: 2014-05-22 20:20:16 +0000 (Thu, 22 May 2014) $