4

I need java 8 for a gradle project of mine and want to enable others to use it "out of the box" without changing their environment. So I want to add a specific jdk to version control and make gradle (and gradle wrapper) use it.

I found this: How do I tell Gradle to use specific JDK version? but it doesn't say how to specify a relative path.

In gradle.properties I have:

org.gradle.java.home = <path to jdk>

how can I use it with a relative path? It's in the parent directory, so it would be something like:

org.gradle.java.home = ../resources/jdk8

thanks

Community
  • 1
  • 1
Jay
  • 598
  • 4
  • 7

2 Answers2

0

You can edit org.gradle.java.home of file gradle.properties to point to a relative location. For example, suppose your JVM is in directory java/jdk inside your Gradle project root, you can edit the file with:

org.gradle.java.home=./java/jdk

Eduardo
  • 319
  • 2
  • 14
  • Note that this fails if you try to run Gradle from inside IntelliJ: https://stackoverflow.com/questions/28726011/intellij-idea-gradle-plugin-unable-to-use-relative-paths-specified-in-gradle-pro – CletusW Nov 10 '20 at 06:32
-1

Assuming you're using the gradle wrapper, you could edit the batch/shell file to specify the JAVA_HOME as a local path.

Shorn
  • 19,077
  • 15
  • 90
  • 168
  • Great, thanks, that worked, a solution that would also work for the regular gradle would be neat but this is ok. – Jay Jan 12 '17 at 11:19