Java/ja

Java は Sun Microsystems によって開発されたプログラミング言語]]で、Java で開発されたアプリケーションがさまざまなプラットフォームで実行できるランタイムを採用しています. クロスプロットフォームのアプリケーションを作りたい開発者にとって、Java は人気のある選択肢です.

概要
Javaは、Sun Microsystems社のエンジニアが開発したプログラミング言語です. 言語は、オブジェクト指向と各プラットフォーム用のコードを再コンパイルする必要なく、複数のプラットフォーム上で動作するように設計されています. Javaはネイティブプログラムとしてコンパイルすることができますが、Javaの人気の多くは、ガベージコレクションなど他の機能と一緒に、その携帯性に起因することができます. プラットフォーム独立を可能にするためにJavaコンパイラは、オペレーティングシステム上で直接JRE（Javaランタイム環境）上で動作する「Javaバイトコード」と呼ばれる中間表現にJavaコードをコンパイルしていません.

Javaバイトコードを実行するためには、JRE（Javaランタイム環境）がインストールされている必要があります. JREは、とりわけコアライブラリ、プラットフォームに依存し、Java仮想マシン、ブラウザ用のプラグインを提供します. JDK（Javaの開発キット）は、バイトコードコンパイラやデバッガなどのプログラミングツールを追加します.

JVM languages
The Java virtual machine is not used exclusively by Java programming language. Multiple programming languages use the Java platform and run on the JVM. Examples of such include: Clojure, Apache Groovy, Kotlin or Scala.

選択肢
Gentoo は多くの Java 実行環境 (JRE) と Java 開発キット (JDK) を提供しています. 現時点で使用可能な選択肢は以下の通りです.

JRE/JDK をインストールする
プロファイルのデフォルトの JDK をインストールするには、次のコマンドを実行します.

プロファイルのデフォルトの JRE をインストールするには、次のコマンドを実行します.

To avoid any restrictive license hassle, consider installing, which is an open Java implementation from the OpenJDK project.

Installing IcedTea GCJ Virtual Machine
The IcedTea virtual machine is provided in source code and requires compilation by a Java bytecode compiler. This bootstrapping can be executed by the GNU Compiler for Java (GCJ). This compiler is available when GCC is built with the  USE flag.

When GCC is rebuilt with this USE flag set, the package can be installed. Because of a Portage bug, users need to install and  explicitly first if they are not already present.

Installing fetch-restricted virtual machines
Some of the JDKs and JREs require a few extra steps in their configurations. Emerge the packages as normal. If additional steps are required the ebuilds will provide instruction for the user on where to go and what to download.

Download the indicated file(s) into (or the value of DISTDIR ). Once the files are in the right directories, rerun the command, at which point the JRE/JDK will be begin to install.

Setting up a headless JRE
Sometimes there is no need for a full JRE with all the capabilities of java. Using java on a server often does not require any GUI, graphical, sound or even printer related features. To install a simplified (sometimes also referred to as headless) JRE, a few USE flags need to be changed for the selected JRE flavor.

Depending on the current Gentoo profile, this might already be the case. As usual, the USE flag settings that are applicable to a particular package can be checked by running in pretend mode:

概要
Gentoo has the ability to have multiple JDKs and JREs installed without causing conflicts.

Using the tool with root privileges, a system-wide default java virtual machine (VM) can be set. Users can also use to custom set their personal VM on a user-by-user basis.

Setting a default virtual machine
Running the command with the   option will output a list of all JREs and JDKs installed on the system. Here is an example of the output:

The * indicates this is the current active JVM (system-vm or user-vm when set). The name in the brackets ([]) is the handle or ID for that particular VM. The handle or the number to can be used to set the VM. The following text provides an example of how to set the system VM.

Setting the system VM by handle (preferred):

Alternate method: select VM by number handle number:

As a regular user, use java-config.

Build only VM
Some virtual machines are flagged as build-only due to being EOL and/or containing security vulnerabilities. These virtual machines will not automatically be used by Gentoo for the running of applications using Gentoo launchers (run-java-tool script designed for switching VMs), but will still be available for use by Gentoo's build environment as some packages may require them for building. The setting of these virtual machines as either the system or user VM is strongly discouraged as these VMs will then be used when running the executables, as well as used by any packages not using Gentoo's launcher scripts.

Setting a default CLASSPATH
can also be used to set a system-wide default CLASSPATH, as well a user-specific default CLASSPATH.

First, list available Java libraries installed on the system to possibly put in the CLASSPATH variable. Here is an example of output:

Again, the names in brackets ([]) are the IDs to pass to. Here is an example:

Update the environment by logging out, then in again or by typing.

For users, will create  file, which should be sourced from the shell's profile.

If desiring a system wide or user default classpath add something like the following to the shell's profile. This is advised against:

Java browser plugins
The Java browser plugin used to be managed via. This has now been removed in favor of a simpler out-of-the-box experience. For basic usage, simply emerge the chosen JVM with the  USE flag enabled. Note that Oracle's plugin is only available for and.

For more information, including JVM selection, Web Start, and multilib, see the README installed with icedtea-web.

Setting USE flags
For more information regarding USE flags, refer to the USE flags chapter from the Gentoo Handbook.

USE flags

 * The flag adds support for Java in a variety of programs;
 * The flag adds support for Mozilla-like browsers (including Firefox). This is needed for viewing Java applets in a Mozilla-like browser;
 * The flag adds support for the Java Cryptography Engine;

Following USE flags go in JAVA_PKG_IUSE.
 * The flag installs a zip of the source code of a package. This is traditionally used for IDEs to 'attach' source to the libraries that are being use;
 * For Java packages, the flag will build API documentation using javadoc.

External resources

 * The gentoo-java, gentoo-user, and gentoo-dev mailing list archives
 * and on IRC
 * Java 7 and bootstrapping icedtea on the Gentoo forums

More information can be found offline:



For suggestions or questions regarding this document, please email the Gentoo Java team: