Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA_HOME is not set and no 'java' command could be found in your PATH. bitbucket pipeline [duplicate]

Tags:

java

bitbucket

Hi i tried to execute a gradle command in bitbucket pipeline

definitions:
  services:
    java:
      image: openjdk:8
pipelines:
  default:
    - step:
        name: Build And Test
        services:
          - java
        script:
          - bash ./gradlew clean build
          - bash ./gradlew test
    - step:
        name: configure gcloud
        deployment: test
        image: google/cloud-sdk:214.0.0-alpine
        services:
          - java
          - docker
        caches:
          - gradle
        script:
          - gcloud auth configure-docker --quiet
          - docker login -u _json_key -p "$GCR_JSON_KEY" https://gcr.io
          - bash ./gradlew bake -Penv=test -PisRelease=false --info --stacktrace

when it tried to execute the latest task

it give the error JAVA_HOME is not set and no 'java' command could be found in your PATH.

AS you see there's a java image and it works in the first step but in the second step if failed and this is the issue.

like image 887
M1M6 Avatar asked Aug 30 '18 11:08

M1M6


People also ask

How do you fix error JAVA_HOME is not set and no Java command could be found in your path?

Download Liberica JDK and on installation it will automatically set JAVA_HOME environment variable. Now you just go to Android Studio -> Project Structure -> SDK -> Point all jdk path to liberica jdk installation directory and apply. You are done. Just restart android studio and gradle command will work.

What if JAVA_HOME is not set?

All you need to do to fix this error is edit the JAVA_HOME variable and point it to the correct directory. The JAVA_HOME environment variable must point to the root of the installation folder of a JDK.

How do you fix please set the JAVA_HOME variable in your environment to match the location of your Java installation?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.

Where does Jenkins set Java home?

Go to Manage Jenkins – Configure System, to the Global properties section and enable Environment variables. Add an environment variable for JAVA_HOME and fill the path with /var/jenkins_home/tools/hudson.


1 Answers

You had set JAVA_HOME? If not, read here

To set JAVA_HOME, do the following:

a. Right click My Computer and select Properties.

b. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.

like image 186
KunLun Avatar answered Oct 05 '22 18:10

KunLun