[arch-general] Package guidelines for apps requiring a specific Java version
I'm working on a PKGBUILD for a Java app that must be built and run using Java 8, but I couldn't find any guidelines on best practices for such a situation. The easy part is including 'java-environment=8' and 'java-runtime=8' in makedepends and depends respectively, but how to ensure the right version is set as default when building and running (rather than spitting out the opaque Java errors you get when using the wrong version)? Right now at the start of build() I have echo "Checking that default Java is version 8..." java -version 2>&1 | grep 'version "1.8' Which seems reasonable since building is infrequent. But what about for the shell script that starts the app? I could put a similar check there, but that seems like it would be really annoying for people who have multiple Java versions installed. Could there be a good way of letting my app always use Java 8, even if some other version is set as the default? Thanks, Max
On 2 October 2014 18:41, Maxwell Anselm <silverhammermba@gmail.com> wrote:
I'm working on a PKGBUILD for a Java app that must be built and run using Java 8, but I couldn't find any guidelines on best practices for such a situation.
The easy part is including 'java-environment=8' and 'java-runtime=8' in makedepends and depends respectively, but how to ensure the right version is set as default when building and running (rather than spitting out the opaque Java errors you get when using the wrong version)?
Right now at the start of build() I have
echo "Checking that default Java is version 8..."
java -version 2>&1 | grep 'version "1.8'
Which seems reasonable since building is infrequent. But what about for the shell script that starts the app? I could put a similar check there, but that seems like it would be really annoying for people who have multiple Java versions installed. Could there be a good way of letting my app always use Java 8, even if some other version is set as the default?
Thanks, Max
Hello,
The easy part is including 'java-environment=8' and 'java-runtime=8' in makedepends and depends respectively Yes. Also note existence of "java-runtime-headless" in case your application does not require graphical stuff (if it does not have a GUI).
how to ensure the right version is set as default when building If building in a chroot (using scripts in package "devtools") and as you added a makedependency on "java-environment=8" then jdk8-opendjk and its dependencies will be the only ones installed. Thus your application will automatically be built with it.
If building on a box where multiple JVM can be installed: build scripts for Java apps usually provide a "--with-jdk=<PATH>" or "--java-home=<PATH>" (or similar) to force the JVM to use to build. If true for the app you are trying to build then you could use path "/usr/lib/jvm/java-8-openjdk/" Same applies when running the application: it usually involves a script that checks where the JVM is located that usually takes the same kind of parameter to "force" the JVM. What is the name/URL of this app?
participants (2)
-
Guillaume ALAUX
-
Maxwell Anselm