Java

From Void Linux Wiki
Jump to: navigation, search

Installing Java via xbps (glibc only)

OpenJRE

JRE:

# xbps-install -S openjdk-jre

JDK:

# xbps-install -S openjdk


Be sure to install both openjdk-jre and openjdk if you want to open jar files. You can launch jar files like so:

$ java -jar /path/to/file.jar

Oracle

JRE:

# xbps-install void-repo-nonfree # only necessary the first time you want to install a nonfree package
# xbps-install -S oracle-jre

JDK:

# xbps-install void-repo-nonfree # only necessary the first time you want to install a nonfree package
# xbps-install -S oracle-jdk

Manual installation (glibc only)

We can't give support for manual installations!

If you really need specific JDK-Version use this:

JDK6

$ wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin
# chmod +x jdk-6u45-linux-x64.bin
$ ./jdk-6u45-linux-x64.bin

JDK7

$ wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz
$ tar xf jdk-7u67-linux-x64.tar.gz
$ rm jdk-7u45-linux-x64.tar.gz

JDK8

$ wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.tar.gz
$ tar xf jdk-8u162-linux-x64.tar.gz
$ mv jdk1.8.0_162 /opt/java 

JDK9

$ wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz
$ tar xf jdk-9.0.4_linux-x64_bin.tar.gz
$ mv jdk-9.0.4 /opt/java
/etc/profile with android studio, sdk settings.
$ export JAVA_HOME=/opt/java
$ export ANDROID_HOME=/opt/android/sdk
$ export GRADLE_HOME=/opt/android/gradle
$ export PATH=/opt/java/bin:$PATH

Empty windows in non-reparenting window managers

Java maintains a hard-coded list of window managers that it knows about. When you use a different WM it simply assumes that it is reparenting and may present you with empty grey windows if your WM is actually not reparenting.

If you run into this problem with OpenJDK version 8u40_3 or above, you can simply set the environment variable _JAVA_AWT_WM_NONREPARENTING=1 and your GUI applications should behave as expected. In prior versions or when using the Oracle JDK you may need to trick Java into thinking that you are using a non-reparenting WM that it knows about, like LG3D. To do that you need the wmname tool from the same-named repo package:

# xbps-install -S wmname

Simply call it like this:

$ wmname LG3D

Afterwards your Java GUI applications should run as intended. However, you need to re-run the program every time your WM restarts or you reboot the computer.

Docker (glibc and musl)

There are currently no xbps packages nor any specified manual installation method available to install Java within musl environments. However, one option available to both musl and glibc environments is to run Java within a docker container.

External links