I have got Error: Unable to access jarfile /tmp/demo/build/lib/demo-0.0.1-SNAPSHOT.jar when trying to run the bootScripts file of Gradle application plugin installBootDist task.

I observed that the JARPATH in bootScripts files generated from gradle installBootDist task is wrong.

# pwd
/tmp/demo

# bash ./gradlew installBootDist

BUILD SUCCESSFUL in 3s
6 actionable tasks: 6 executed

# find build/bootScripts/ -type f
build/bootScripts/demo
build/bootScripts/demo.bat

# bash build/bootScripts/demo
Error: Unable to access jarfile /tmp/demo/build/lib/demo-0.0.1-SNAPSHOT.jar

# find build/lib*
build/libs
build/libs/demo-0.0.1-SNAPSHOT.jar

# grep lib build/bootScripts/demo*
build/bootScripts/demo:JARPATH=$APP_HOME/lib/demo-0.0.1-SNAPSHOT.jar
build/bootScripts/demo.bat:set JARPATH=%APP_HOME%\lib\demo-0.0.1-SNAPSHOT.jar

Environment:

    id 'org.springframework.boot' version '2.7.5'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'

Comment From: wilkinsona

You are not using the script as intended. The scripts in build/bootScripts/ are intermediate artifacts that are then included in a distribution. installBootDist installs a distribution of your application in build/install/demo. In this directory you will find a bin directory containing the scripts and a lib directory that contains the application's jar file. It's this install that you should use to run your application.