Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#42346 - [java-common] add support for version specific Java env

Attached to Project: Arch Linux
Opened by Guillaume ALAUX (galaux) - Sunday, 12 October 2014, 20:16 GMT
Last edited by Guillaume ALAUX (galaux) - Sunday, 12 October 2014, 20:25 GMT
Task Type Feature Request
Category Packages: Extra
Status Assigned
Assigned To Guillaume ALAUX (galaux)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 1
Private No



Add link such as


These could be changed with "archlinux-java set -7 jre-7-openjdk" and "archlinux-java set -8 jre-8-openjdk"

Original request:
This task depends upon

Comment by Matthias Lisin (matthias.lisin) - Sunday, 19 January 2020, 11:58 GMT
Hey galaux, I've recently had the same situation but now found this issue from 2014, hope you don't mind reviving it.
Had a conversation with eli a while ago on IRC where we came up with another approach (though admittedly gave it only 10 minutes of though).

(excuse my pseudo-markdown)

Packages wants to provide Java application which works best with Java 8 so he specifies `java-runtime=8` as dependency. However the end-user might not use another version as default (7, 10, 11 or 13) so simply running the application by `java -cp "[libs]"` won't work.

If one resorts to using a fixed path (e.g. `PATH="/usr/lib/jvm/java-8-openjdk/bin:${PATH}"`) then non-OpenJDK users are forced to install the openjdk runtime.
The Oracle Java is quiet popular among Arch users according to AUR, so it shouldn't be ignored (imo).

Packagers should be able to specify `java-runtime=8` and reliably run the application with version 8, regardless of the implementation/brand/vendor (however it's called).

**My proposal**
Give users the ability to get the runtime path for a specific version.

# returns first match (java-13-*), since the paths are sorted by the script, the result is always the same.
$ archlinux-java get-path 13
Output: /usr/lib/jvm/java-13-jdk

# however if default-runtime is set to `java-13-openjdk`, it is returned instead
$ archlinux-java get-path 13
Output: /usr/lib/jvm/java-13-openjdk

# The user proceeds with running the bin/java under that path or prepending the PATH variable in his wrapper script
# (in theory) get-path should never fail if the dependencies in PKGBUILD are properly specified
JRE13=$(archlinux-java get-path 13)
java -cp "/opt/myapp/app.jar"

My implementation (+tests):
(same structure as the packages/java-commons branch in archlinux git repo in case you want diff/apply.

Feedback of any kind is appreciated.

I agree that returning the first match in case it's not the default-runtime is somewhat unintuitive. I also really like your approach and would provide the implementation if you want.
All I really want is to solve this issue.