"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
- 1 Installation
- 2 Troubleshooting
- 3 Tips and tricks
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 open-source version is nearly perfect at the time of writing, and there is mostly no need anymore to install Oracle's proprietary version of Java.
To be able to run Java programs, you can install Java runtime with the package , available in the official repositories. There is also a Java Development Kit in . For those interested in the old Java v6, both JRE6 and JDK6 can be found in .
Prior to the retirement of the Oracle DLJ, it was possible to simply install the
jdk packages from the repositories. 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
AUR contains packages forAUR and AUR, the Oracle implementations of Java.
Java SE 6 (Oracle JVM)
For users interested in Java SE 6, the packagesAUR and AUR have been updated to Java SE 7. However, you can still install the JRE/JDK manually.
Here's how to do so:
First, go to http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html, move down to Hava SE 6u31 (or something of the sort) "JDK." Accept the license agreement and then download either
jdk-6u31-linux-i586.bin if your system is 32-bit OR
jdk-6u31-linux-i586.bin if your system is 64-bit.
Now, do the following:
For 32-bit systems
Open up a terminal, and then change to the directory where you downloaded the binary. Then do the following:
$ chmod a+x jdk-6u31-linux-i586.bin $ su -c 'mv jdk-6u31-linux-i586.bin /opt $ cd /opt # ./jdk-6u31-linux-i586.bin # rm jdk-6u31-linux-i586.bin
The JDK has now been installed. However, we're not quite finished. We need to alter our PATH so that Java will be in it. To do so, we need to edit /etc/profile. Why? Because we want to make this configuration system-wide, and not bound to one user. Now, using your favorite text editor, open up /etc/profile as root and then find this line:
Now, add the location of where the JDK was installed. In this tutorial's case, the JDK was installed in /opt. Therefore, the result should look like this if you've installed the JDK in /opt:
After you've done so, save your changes and exit. For your changes to take effect, either log out or source /etc/profile. To see if the changes took place, execute the following:
$ echo $PATH
If you see something like <jdk>/bin:<jdk>/jre/bin in your PATH, where <jdk> is the location of where you installed it, congratulations! You've installed the JDK!
To install the browser plugin, first close any and all web browser you have open. Then create a symlink to the browser plugin like so:
$ ln -s <jdk>/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins
Remember to replace <jdk> with the location of where the JDK is.
For 64-bit systems
According to Oracle, you can run either the 32-bit version of the JDK/JRE or the 64-bit, however if you have a 32-bit browser, you *must* follow the 32-bit version of the tutorial. The installation of the JDK/JRE remains largely the same, aside from a few differences.
First, open up a terminal and then change to the directory where you downloaded the binary. Then, do the following:
$ chmod a+x jdk-6u31-linux-x64.bin $ su -c 'mv jdk-6u31-linux-x64.bin /opt' $ cd /opt # ./jdk-6u31-linux-x64.bin # rm jdk-6u31-linux-x64.bin
Now that the JDK's been installed, it's time to edit your PATH. Using your favorite text editor, open up /etc/profile as root and then find the line in /etc/profile that looks like this:
Now append the location to where you set up the JDK to the end of the line. In this tutorial's case, it was installed in /opt. Therefore, the result for us will look like this:
Now either log out or source /etc/profile. To see if your changes took effect, execute the following:
$ echo $PATH
If you see something like <jdk>/bin:<jdk>/jre/bin in your PATH, where <jdk> is the location of where you installed the JDK, congratulations! You just installed the JDK manually :). Give yourself a pat on the back.
To install the browser plugin, close all browser windows you have open and create a symlink to
~/.mozilla/plugins. like so:
$ ln -s <jdk>/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins
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: AUR.
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 here: AUR. The Kaffe VM is redistributed according to the GPL license.
BEA JRockit JIT JVM (+JDK)
JRockit is JIT version of Java, provided by Oracle and available from the AUR here: AUR.
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 here: AUR. J3 depends on the GNU classpath libraries, but may also work with the Apache class path libraries.
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. Available in the AUR package AUR.
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
# mv /opt/java/jre/bin/java /opt/java/jre/bin/java.bin
Then, create a new launcher script at
#!/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.
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
/etc/profile.d/jre.sh to affect all users):
export _JAVA_OPTIONS="-D<option 1> -D<option 2>..."
Better font rendering
Both closed source and open source one implementations of Java are known to have improperly implement antialiasing of fonts. This can be fixed with following options:
If your java programs look ugly, you may want to set up the default look and feel for the swing components: