jitpack / jitci

A CI with tests, coverage, dependency audit, license & vuln. checks
https://jitci.com
19 stars 5 forks source link

JDK 17 not working #29

Open voidpointer0x00 opened 2 years ago

voidpointer0x00 commented 2 years ago

Although I chose JDK17 java and mvn will not change from Java 1.8, which causes the build to fail. I also tried to install Java 17 through jabba, but then came across another issue — I've no clue how to install another maven. Tried to download from Apache CND server, but it also failed.

build.log The project on JitCI

codehz commented 2 years ago

workaround: add JAVA_HOME=/home/jitpack/tools/jdk17

voidpointer0x00 commented 2 years ago

workaround: add JAVA_HOME=/home/jitpack/tools/jdk17

26. The JAVA_HOME environment variable is not defined correctly
27. This environment variable is needed to run this program
28. NB: JAVA_HOME should point to a JDK not a JRE

Do I mess it up? :smile: https://jitci.com/gh/NyanGuyMF/locale-module/19#

Settings screenshot ![jitci com_gh_NyanGuyMF_locale-module (4)](https://user-images.githubusercontent.com/43143315/164418777-7760da73-2e2a-48b5-8a89-9147402de365.png)
codehz commented 2 years ago

hmmm, at least it is working for me: (btw I use gradle)

image

https://jitci.com/gh/codehz-mcmods/vanilla-laser/builds/b1G0Z635012N1Q1VRD3S3T1Z9R/build.log My project require java 17 to working I think it is related to maven

codehz commented 2 years ago

Workaround: add to init command (copied from my log

wget -nv https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_linux-x64_bin.tar.gz -O /home/jitpack/tools/jdk17/jdk17.tar.gz
tar xfz /home/jitpack/tools/jdk17/jdk17.tar.gz --strip-components=1 -C /home/jitpack/tools/jdk17
gmitch215 commented 2 years ago

Was a solution ever reached? I've tried both workarounds (I also use maven) but it doesn't work.

voidpointer0x00 commented 2 years ago

I haven't tried the second yet, but I believe it also won't work, because the maven issue will still remain :)

gmitch215 commented 2 years ago

After playing around with the JitCI, and looking through the path dirs, I've found a solution:

The reason why above solutions didn't work was because the JAVA_HOME isn't actually in the PATH environmental variable. JitCI has all of the programming language's executables (Java, Python, Go, etc.) in one directory (/usr/bin). They removed the sudo command so you can't edit these files, but you CAN edit the PATH variable, allowing you to update your java version.

I'm not sure if setting to JDK17 will update these files in here. For some reason, maven does point to JAVA_HOME, but the actual shell doesn't.

As for my solution, you simply just need to install JDK17 (I use Adoptium), put it in that tool directory, and update the PATH environmental variable so that JDK17 gets scanned first.

Put this before running any Java Commands:

rm -rf /home/jitpack/tools/jdk17/
mkdir /home/jitpack/tools/jdk17/
wget -nv https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.3%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.3_7.tar.gz -O /home/jitpack/tools/jdk17/jdk17.tar.gz
tar xfz /home/jitpack/tools/jdk17/jdk17.tar.gz --strip-components=1 -C /home/jitpack/tools/jdk17
JAVA_HOME=/home/jitpack/tools/jdk17/
PATH="$JAVA_HOME/bin:$PATH"

Running mvn --version and java --version gives you this:

19. + mvn --version
20. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
21. Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
22. Maven home: /opt/apache-maven-3.6.1
23. Java version: 17.0.3, vendor: Eclipse Adoptium, runtime: /home/jitpack/tools/jdk17
24. Default locale: en, platform encoding: UTF-8
25. OS name: "linux", version: "4.18.0-13-generic", arch: "amd64", family: "unix"
26. + java --version
27. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
28. openjdk 17.0.3 2022-04-19
29. OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
30. OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
voidpointer0x00 commented 2 years ago

This makes sense, thanks :) I'll try it and tell if it works for me :)