Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

maven and jdk8 on Alpine Linux image

Writer Matthew Martinez

This is my first time working with an Alpine linux image. Its part of a Jenkins build pipeline.

When I try to compile my maven build (which requires Java 1.8) ... it gives an error suggested there is no compiler installed.

However, I confirmed its installed ... multiple ways;

  1. Echo the JAVA_HOME variable which returns/usr/lib/jvm/java-1.8-openjdk

  2. Tested to confirm the compiler is there; by running "${JAVA_HOME}/javac -version" ... which returns;

/usr/lib/jvm/java-1.8-openjdk/bin/javac -version
javac 1.8.0_222
  1. However, maven still points to the JRE ...
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T07:58:13Z)
Maven home: /usr/share/java/maven-3
Java version: 1.8.0_222, vendor: IcedTea
Java home: /usr/lib/jvm/java-1.8-openjdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.19.84-coreos", arch: "amd64", family: "unix"

I tried manually installed the JDK ... but doesn't seem to help;

 apk update apk add openjdk8 apk add maven

Any suggestions? I need Java 8 to compile this app ... and currently every attempt to do a "mvn clean install" results in a failure, as below;

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

1 Answer

Tried many different ideas and then eventually thought about setting the path to the compiler and amazingly, now it works!

 export PATH=${PATH}:${JAVA_HOME}/bin mvn clean install

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy