Use jdk.GetJavaExecutable() in tools.

Bug: 124239658
Change-Id: Ia2fce6eb5f25000f519d499f70fb54d04c7dfd66
diff --git a/tools/build_r8lib.py b/tools/build_r8lib.py
index 5368f6f..980715e 100755
--- a/tools/build_r8lib.py
+++ b/tools/build_r8lib.py
@@ -10,6 +10,7 @@
 
 import argparse
 import gradle
+import jdk
 import os
 import subprocess
 import toolhelper
@@ -76,7 +77,8 @@
 
 def test_d8sample(paths):
   with utils.TempDir() as path:
-    args = ['java', '-cp', '%s:%s' % (SAMPLE_JAR, ":".join(paths)),
+    args = [jdk.GetJavaExecutable(),
+            '-cp', '%s:%s' % (SAMPLE_JAR, ":".join(paths)),
             'com.android.tools.apiusagesample.D8ApiUsageSample',
             '--output', path,
             '--min-api', str(API_LEVEL),
@@ -94,7 +96,8 @@
     # R8CommandParser should have been minified in LIB_JAR.
     # Just in case R8CommandParser is also present in LIB_JAR, we put
     # SAMPLE_JAR first on the classpath to use its version of R8CommandParser.
-    args = ['java', '-cp', '%s:%s' % (SAMPLE_JAR, ":".join(paths)),
+    args = [jdk.GetJavaExecutable(),
+            '-cp', '%s:%s' % (SAMPLE_JAR, ":".join(paths)),
             'com.android.tools.r8.R8CommandParser',
             '--output', path + "/output.zip",
             '--min-api', str(API_LEVEL),
@@ -111,7 +114,8 @@
     # R8CommandParser should have been minified in LIB_JAR.
     # Just in case R8CommandParser is also present in LIB_JAR, we put
     # SAMPLE_JAR first on the classpath to use its version of R8CommandParser.
-    args = ['java', '-cp', '%s:%s' % (SAMPLE_JAR, ":".join(paths)),
+    args = [jdk.GetJavaExecutable(),
+            '-cp', '%s:%s' % (SAMPLE_JAR, ":".join(paths)),
             'com.android.tools.r8.R8CommandParser',
             '--classfile',
             '--output', path + "/output.jar",