Difference between revisions of "Java"
Kynikos.bot (talk | contribs) (remove language suffix from Category:Development (English), see Talk:Table of Contents#English Category Names: Capitalization and Conflict with i18n) |
m (→Parrot VM) |
||
(40 intermediate revisions by 22 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category: | + | [[Category:Programming language]] |
− | + | [[cs:Java]] | |
+ | [[es:Java]] | ||
[[fr:Java]] | [[fr:Java]] | ||
− | + | [[it:Java]] | |
+ | [[pt:Java]] | ||
+ | [[ru:Java]] | ||
+ | [[tr:Java]] | ||
{{Article summary start}} | {{Article summary start}} | ||
{{Article summary text|This article explains how to install and configure JRE/JDK.}} | {{Article summary text|This article explains how to install and configure JRE/JDK.}} | ||
Line 12: | Line 16: | ||
== Installation == | == Installation == | ||
− | The only JVM implementation in supported repositories is the open source [http://openjdk.java.net/ OpenJDK]. Additional Java implementations are available via the [[AUR]]. Keep in mind that the open-source and closed-source versions cannot be installed simultaneously. The | + | The only JVM implementation in supported repositories is the open source [http://openjdk.java.net/ OpenJDK]. Additional Java implementations are available via the [[AUR]]. Keep in mind that the open-source and closed-source versions cannot be installed simultaneously. The OpenJDK is nearly perfect, and it should not be necessary to install Oracle's proprietary version of Java. |
+ | |||
+ | {{Note|After installation, the Java environment will need recognized by the shell ({{Ic|$PATH}} variable and {{Ic|$JAVA_HOME}}). This can be done from the command line by sourcing {{Ic|/etc/profile}}, and for Desktop Environments it is likely a logout/login will be necessary.}} | ||
=== OpenJDK JVM === | === OpenJDK JVM === | ||
− | + | Install the OpenJDK Java runtime environment (''JRE'') with the package {{Pkg|jre7-openjdk}}, available in the [[official repositories]]. There is also a Java development kit (''JDK'') available with the package {{Pkg|jdk7-openjdk}}. | |
− | + | If you want Java functionality in browsers ([[Wikipedia:Java applet|Java applets]] and [[Wikipedia:Java Web Start|Java Web Start]]), install {{Pkg|icedtea-web-java7}}. For more details see [[Browser Plugins#Java (IcedTea)]]. | |
− | {{ | + | ==== Flagging OpenJDK packages as out-of-date ==== |
+ | Please flag packages {{Pkg|jre7-openjdk-headless}}, {{Pkg|jre7-openjdk}} and {{Pkg|jdk7-openjdk}} as out-of-date based on their [http://icedtea.wildebeest.org/download/source IcedTea version] (2.3.4) rather than on their Oracle version (u9). | ||
+ | IcedTea-web project (package {{Pkg|icedtea-web-java7}}) have version number that are independent from the IcedTea one (packages {{Pkg|jre7-openjdk-headless}}, {{Pkg|jre7-openjdk}} and {{Pkg|jdk7-openjdk}}) so please flag each package based on its right version number. | ||
=== Oracle JVM === | === Oracle JVM === | ||
− | + | The [[AUR]] contains the Oracle implementations of JRE and JDK: {{AUR|jre}} and {{AUR|jdk}}. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | === | + | ==== Oracle JVM 6 ==== |
− | [ | + | The [[AUR]] contains {{AUR|jre6}} and {{AUR|jdk6}}, which are the Oracle implementations of Java SE 6. If you want to use Java 6 alongside an up to date version (OpenJDK or Oracle), install {{AUR|jre6-compat}} and {{AUR|jdk6-compat}}. |
− | === | + | === Oracle JRockit JIT JVM (+JDK) === |
− | [ | + | [http://www.oracle.com/technetwork/middleware/jrockit/overview/index.html JRockit] is a JIT version of Java, provided by Oracle and available as {{AUR|jrockit}} from the [[AUR]]. |
=== VMkit LLVM-based JIT VM === | === VMkit LLVM-based JIT VM === | ||
− | [http://vmkit.llvm.org/index.html VMkit] is an LLVM-based framework for JIT virtual machines. J3 is a JVM running on VMkit. | + | [http://vmkit.llvm.org/index.html VMkit] is an LLVM-based framework for JIT virtual machines. J3 is a JVM running on VMkit. The webpage can be found here: [[http://vmkit.llvm.org/get_started.html vmkit]]. J3 depends on the GNU classpath libraries, but may also work with the Apache class path libraries. |
=== Parrot VM === | === Parrot VM === | ||
− | The [http://www. | + | The [http://www.parrot.org/ Parrot] VM offers experimental [http://trac.parrot.org/parrot/wiki/Languages support for Java] through two different methods: Either as a [http://code.google.com/p/parrot-jvm/ Java VM bytecode translator] or as a [https://github.com/chrisdolan/perk Java compiler targeting the Parrot VM]. {{Pkg|parrot}} is available in the [[official repositories]] and {{AUR|parrot-git}} in the [[AUR]]. |
== Troubleshooting == | == Troubleshooting == | ||
Line 68: | Line 65: | ||
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. | 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. | ||
+ | === Impersonate Another Window Manager === | ||
+ | You may use the {{pkg|wmname}} from [http://tools.suckless.org/wmname suckless.org] to make the JVM believe you are running a different window manager. This may solve a rendering issue of Java GUIs occuring in window managers like [[Awesome]] or [[Dwm]]. | ||
+ | |||
+ | <pre>$ wmname LG3D</pre> | ||
+ | |||
+ | (You must restart the application in question after issuing the wmname command.) | ||
+ | |||
+ | This works because the JVM contains a hard-coded list of known non-re-parenting window managers. For maximum irony, many users prefer to impersonate “<code>LG3D</code>,” the non-re-parenting window manager [http://en.wikipedia.org/wiki/Project_Looking_Glass written by Sun, in Java]. | ||
+ | |||
+ | === Fonts are Illegible === | ||
+ | In addition to the suggestions mentioned below in [[#Better_font_rendering]] some fonts may still not be legible afterwards. If this is the case there is a good chance ms-fonts are being used. Install {{AUR|ttf-ms-fonts}} from the AUR. | ||
== Tips and tricks == | == Tips and tricks == | ||
− | {{Note|Suggestions in this section are applicable to all applications, using explicitly installed (external) Java runtime. Some applications are bundled with own (private) runtime or use own mechanics for GUI, font rendering etc, so none of written below is guaranteed to work.}} | + | {{Note|Suggestions in this section are applicable to all applications, using explicitly installed (external) Java runtime. Some applications are bundled with own (private) runtime or use own mechanics for GUI, font rendering, etc., so none of written below is guaranteed to work.}} |
Behavior of most Java applications can be controlled by supplying predefined variables to Java runtime. From [https://bbs.archlinux.org/viewtopic.php?id=72892 this forum post], a way to do it consists of adding the following line in your {{Ic|~/.bashrc}} (or {{Ic|/etc/profile.d/jre.sh}} to affect all users): | Behavior of most Java applications can be controlled by supplying predefined variables to Java runtime. From [https://bbs.archlinux.org/viewtopic.php?id=72892 this forum post], a way to do it consists of adding the following line in your {{Ic|~/.bashrc}} (or {{Ic|/etc/profile.d/jre.sh}} to affect all users): | ||
export _JAVA_OPTIONS="-D'''<option 1>''' -D'''<option 2>'''..." | export _JAVA_OPTIONS="-D'''<option 1>''' -D'''<option 2>'''..." | ||
+ | |||
+ | For example, to use system anti-aliased fonts and make swing use the GTK look and feel: | ||
+ | |||
+ | export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel' | ||
=== Better font rendering === | === Better font rendering === | ||
− | Both closed source and open source | + | Both closed source and open source implementations of Java are known to have improperly implemented anti-aliasing of fonts. This can be fixed with the following options: {{Ic|1=awt.useSystemAAFontSettings=on}}, {{Ic|1=swing.aatext=true}} |
=== GTK LookAndFeel === | === GTK LookAndFeel === | ||
− | If your | + | If your Java programs look ugly, you may want to set up the default look and feel for the swing components: {{Ic|1=swing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel}}. |
+ | |||
+ | Some stubborn Java programs insist on using the cross platform Metal look and feel. In some of these cases you can force these apps to use the GTK look and feel by setting the following property: | ||
+ | |||
+ | {{Ic|1=swing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel}}. | ||
+ | |||
+ | === Symlinks change === | ||
+ | Typically, OpenJDK installation creates symlinks in {{Ic|/usr/bin}} for java, javac ... etc. If you want to change these symlinks to any other JDK (e.g. if you installed environment-compat packages of Oracle JDK), [https://github.com/d1x/linux-utils/blob/master/replace-java-symlinks.sh this] script might be handy for you. |
Revision as of 12:51, 28 September 2013
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end
"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 article
Installation
The only JVM implementation in supported repositories is the open source OpenJDK. Additional Java implementations are available via the AUR. Keep in mind that the open-source and closed-source versions cannot be installed simultaneously. The OpenJDK is nearly perfect, and it should not be necessary to install Oracle's proprietary version of Java.
$PATH
variable and $JAVA_HOME
). This can be done from the command line by sourcing /etc/profile
, and for Desktop Environments it is likely a logout/login will be necessary.OpenJDK JVM
Install the OpenJDK Java runtime environment (JRE) with the package jre7-openjdk, available in the official repositories. There is also a Java development kit (JDK) available with the package jdk7-openjdk.
If you want Java functionality in browsers (Java applets and Java Web Start), install icedtea-web-java7. For more details see Browser Plugins#Java (IcedTea).
Flagging OpenJDK packages as out-of-date
Please flag packages jre7-openjdk-headless, jre7-openjdk and jdk7-openjdk as out-of-date based on their IcedTea version (2.3.4) rather than on their Oracle version (u9). IcedTea-web project (package icedtea-web-java7) have version number that are independent from the IcedTea one (packages jre7-openjdk-headless, jre7-openjdk and jdk7-openjdk) so please flag each package based on its right version number.
Oracle JVM
The AUR contains the Oracle implementations of JRE and JDK: jreAUR and jdkAUR.
Oracle JVM 6
The AUR contains jre6AUR and jdk6AUR, which are the Oracle implementations of Java SE 6. If you want to use Java 6 alongside an up to date version (OpenJDK or Oracle), install jre6-compatAUR and jdk6-compatAUR.
Oracle JRockit JIT JVM (+JDK)
JRockit is a JIT version of Java, provided by Oracle and available as jrockitAUR from the AUR.
VMkit LLVM-based JIT VM
VMkit is an LLVM-based framework for JIT virtual machines. J3 is a JVM running on VMkit. The webpage can be found here: [vmkit]. 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. parrot is available in the official repositories and parrot-gitAUR in the AUR.
Troubleshooting
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 should enable remote access to MySQL, following instructions in MySQL article.
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 java
binary to java.bin
# mv /opt/java/jre/bin/java /opt/java/jre/bin/java.bin
Then, create a new launcher script at /opt/java/jre/bin/java
#!/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.
Impersonate Another Window Manager
You may use the wmname from suckless.org to make the JVM believe you are running a different window manager. This may solve a rendering issue of Java GUIs occuring in window managers like Awesome or Dwm.
$ wmname LG3D
(You must restart the application in question after issuing the wmname command.)
This works because the JVM contains a hard-coded list of known non-re-parenting window managers. For maximum irony, many users prefer to impersonate “LG3D
,” the non-re-parenting window manager written by Sun, in Java.
Fonts are Illegible
In addition to the suggestions mentioned below in #Better_font_rendering some fonts may still not be legible afterwards. If this is the case there is a good chance ms-fonts are being used. Install ttf-ms-fontsAUR from the AUR.
Tips and tricks
Behavior of most Java applications can be controlled by supplying predefined variables to Java runtime. From this forum post, a way to do it consists of adding the following line in your ~/.bashrc
(or /etc/profile.d/jre.sh
to affect all users):
export _JAVA_OPTIONS="-D<option 1> -D<option 2>..."
For example, to use system anti-aliased fonts and make swing use the GTK look and feel:
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'
Better font rendering
Both closed source and open source implementations of Java are known to have improperly implemented anti-aliasing of fonts. This can be fixed with the following options: awt.useSystemAAFontSettings=on
, swing.aatext=true
GTK LookAndFeel
If your Java programs look ugly, you may want to set up the default look and feel for the swing components: swing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
.
Some stubborn Java programs insist on using the cross platform Metal look and feel. In some of these cases you can force these apps to use the GTK look and feel by setting the following property:
swing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
.
Symlinks change
Typically, OpenJDK installation creates symlinks in /usr/bin
for java, javac ... etc. If you want to change these symlinks to any other JDK (e.g. if you installed environment-compat packages of Oracle JDK), this script might be handy for you.