Difference between revisions of "Java"

From ArchWiki
Jump to: navigation, search
(french language link)
m (Redone section for Oracle JVM. (Previously it was pre-DLJ instructions with a note saying that they're out of date.))
Line 23: Line 23:
 
===Oracle JVM===
 
===Oracle JVM===
  
{{Note|Arch Linux (and any other GNU/Linux distribution) can no longer package the Oracle implementation of Java. Read [http://mailman.archlinux.org/pipermail/arch-general/2011-August/021671.html here] for the announcement. Alternatively, you can download ''openjdk6'' from [extra] or use ''jre'' or ''jre6'' from the [[AUR]].<br/>
+
Prior to the [http://mailman.archlinux.org/pipermail/arch-general/2011-August/021671.html retirement of the Oracle DLJ], it was possible to simply install the <tt>jre</tt> and <tt>jdk</tt> packages from the repositories, respectively. However, now Arch Linux (and any other GNU/Linux distribution) can no longer package the Oracle implementation of Java. The OpenJDK packages are the recommended providers of <tt>java-runtime</tt> and <tt>java-environment</tt>.
The rest of this section is left for reference purposes only.}}
+
  
To be able to run Java programs, you can install the Oracle JRE from the repositories:
+
The [[AUR]] contains packages for [http://aur.archlinux.org/packages.php?ID=51908 jre] and [http://aur.archlinux.org/packages.php?ID=51906 jdk], the Oracle implementations of Java.
# pacman -S jre
+
  
You will need to log out and log in again, or add {{Filename|/opt/java/jre/bin/}} to $PATH to use the ''java'' command.  
+
{{Note| You will need to ensure that {{Filename|/opt/java/jre/bin/}} is in your <tt>$PATH</tt> variable, and that <tt>$JAVA_HOME</tt> points to the correct position (generally {{Filename|/opt/java}}). You can do this by either logging out and in again, or by sourcing {{Filename|/etc/profile}}.}}
  
To create Java programs, you can install the Oracle JDK from the repositories:
+
{{Note|If you experience any problems with the Java plugin, you can try the solution suggested for the Firefox Flash plugin: [[Flash#Plugins are installed but not working]]}}
# pacman -S jdk
+
 
+
{{Note|If you experience any problems with the Java plugin, you can try the solution suggested for the Firefox Flash plugin: [[Flash#Plugins_are_installed_but_not_working]]}}
+
 
+
{{Note|For Oracle Java, you will need to source {{Filename|/etc/profile}} in order to for the JAVA_HOME path to point to the correct place}}
+
# source /etc/profile
+
  
 
===Apache Harmony===
 
===Apache Harmony===

Revision as of 13:52, 1 October 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

"Java is a programming language originally developed by Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture." — Wikipedia:Java (programming language)

Installation

There are two Java Virtual Machines in the Arch repositories that can be installed on your system — the OpenJDK open source implementation and Sun's closed source implementation. Arch recommends OpenJDK.. Additional Java implementations are available via the AUR.

OpenJDK JVM

To be able to run Java programs, you can install OpenJDK from the repositories. This also installs a Java Development Kit.

# pacman -Syu openjdk6

You will likely need the Template:Package Official package for Java functionality in Firefox as suggested in this thread: https://bbs.archlinux.org/viewtopic.php?pid=895343

# pacman -S icedtea-web
Note: If you experience any problems with the Java plugin, you can try the solution suggested for the Firefox Flash plugin: Flash#Plugins_are_installed_but_not_working
Note: If you use a non-reparenting window manager, you should uncomment the corresponding line in Template:Filename

Oracle JVM

Prior to the retirement of the Oracle DLJ, it was possible to simply install the jre and jdk packages from the repositories, respectively. However, now Arch Linux (and any other GNU/Linux distribution) can no longer package the Oracle implementation of Java. The OpenJDK packages are the recommended providers of java-runtime and java-environment.

The AUR contains packages for jre and jdk, the Oracle implementations of Java.

Note: You will need to ensure that Template:Filename is in your $PATH variable, and that $JAVA_HOME points to the correct position (generally Template:Filename). You can do this by either logging out and in again, or by sourcing Template:Filename.
Note: If you experience any problems with the Java plugin, you can try the solution suggested for the Firefox Flash plugin: Flash#Plugins are installed but not working

Apache Harmony

Apache Harmony is a clean room re-implementation of the Java language and comes under the Free Apache license. A binary re-distribution of the Harmony JRE can be found in the AUR.

Kaffe

Kaffe is another clean-room implementation of a Java VM without official endorsement from Sun/Oracle. A git package of Kaffe can be found in the AUR. The Kaffe VM is redistributed according to the GPL license.

BEA JRockit JIT JVM (+JDK)

You can also install JIT version of Java from the AUR. jrockit

VMkit LLVM-based JIT VM

VMkit is an LLVM-based framework for JIT virtual machines. J3 is a JVM running on VMkit. A broken build for VMkit can be found in the AUR. J3 depends on the GNU classpath libraries, but may also work with the Apache class path libraries.

Parrot VM

The Parrot VM offers experimental support for Java through two different methods: Either as a Java VM bytecode translator or as a Java compiler targeting the Parrot VM.

Java sound with Pulseaudio

By default, Java and Pulseaudio do not get along very well with each other, but this is easy to fix using padsp.

(These paths are correct for Sun's Java, you will need to change the paths for OpenJDK)

First, rename the Template:Filename binary to Template:Filename

# mv /opt/java/jre/bin/java /opt/java/jre/bin/java.bin

Then, create a new launcher script at Template:Filename

#!/bin/sh
padsp /opt/java/jre/bin/java.bin "$@"

Finally, make the launcher script executable

# chmod +x /opt/java/jre/bin/java

You will need to redo this process on each update of Java.

You can also try replacing padsp with aoss, which can also fix it under standard ALSA as well as in Pulse, do what works best. I must warn everyone that these hacks sometimes work perfect, but are sometimes very unstable as well.

Additional notes

MySQL

Due to the fact that the JDBC-drivers often use the port in the URL to establish a connection to the database, it is considered "remote" (i.e., MySQL does not listen to the port as per its default settings) despite the fact that they are possibly running on the same host, Thus, to use JDBC and MySQL, you need to edit Template:Filename and comment out the line looking like this:

 skip-networking

Read the article about MySQL for more information.