Using different jdk for junit testing

I’m trying to use a different JDK to run my tests because gradle is running with java 7 and I want to run my tests with jdk 8. I am running gradle 2.3.

I set this option:

test {
   executable = "/path/to/jdk/bin/javac"

But I get the error

:testjavac: invalid flag:
Usage: javac <options> <source files>

I have also set my options for compiling the source and test code using a different JDK, but that works fine. It’s just the running of the tests.

What am I doing incorrectly here?

Answered my own question here. I was passing the path to javac, not java.