title: Bazel with Java 11 on Ubuntu
body: <p>I am trying to use Java 11 for my Java Homework. It works fine on my OS X machine, but I have JDK 13 installed on my machine. My instructor uses Ubuntu and does not have the latest java installed. How Can I get Bazel to use JAVA 11 without requiring my instructor to update his JDK.</p>
  
  <p>My .bazelrc is as follows:</p>
  
  <pre><code>test --test_output=errors
  test --cache_test_results=yes
  
  
  test --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
  </code></pre>
  
  <p>And when I run:</p>
  
  <pre><code>bazel test java/test/edu/berkeley/cs/util:{hashset,hashmap}
  </code></pre>
  
  <p>I get this wonderfull error. </p>
  
  <pre><code>Starting local Bazel server and connecting to it...
  INFO: Writing tracer profile to '/home/tomgrant/.cache/bazel/_bazel_tomgrant/75fd013422b9b35862a74918dc983c19/command.profile.gz'
  INFO: Analyzed 2 targets (23 packages loaded, 287 targets configured).
  INFO: Found 2 test targets...
  INFO: Deleting stale sandbox base /home/tomgrant/.cache/bazel/_bazel_tomgrant/75fd013422b9b35862a74918dc983c19/sandbox
  ERROR: /home/tomgrant/.cache/bazel/_bazel_tomgrant/75fd013422b9b35862a74918dc983c19/external/bazel_tools/tools/jdk/BUILD:319:1: Action external/bazel_tools/tools/jdk/platformclasspath.jar failed (Exit 1) java failed: error executing command external/remotejdk11_linux/bin/java -XX:+IgnoreUnrecognizedVMOptions '--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED' -cp ... (remaining 4 argument(s) skipped)
  
  Use --sandbox_debug to see verbose messages from the sandbox
  Exception in thread "main" java.lang.IllegalArgumentException: external/local_jdk
      at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.isCurrentPlatform(Locations.java:1862)
      at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.update(Locations.java:1851)
      at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.handleOption(Locations.java:1798)
      at jdk.compiler/com.sun.tools.javac.file.Locations.handleOption(Locations.java:2062)
      at jdk.compiler/com.sun.tools.javac.file.BaseFileManager.handleOption(BaseFileManager.java:269)
      at jdk.compiler/com.sun.tools.javac.file.BaseFileManager$2.handleFileManagerOption(BaseFileManager.java:222)
      at jdk.compiler/com.sun.tools.javac.main.Option.process(Option.java:1138)
      at jdk.compiler/com.sun.tools.javac.main.Option.handleOption(Option.java:1086)
      at jdk.compiler/com.sun.tools.javac.file.BaseFileManager.handleOption(BaseFileManager.java:232)
      at jdk.compiler/com.sun.tools.javac.main.Arguments.doProcessArgs(Arguments.java:390)
      at jdk.compiler/com.sun.tools.javac.main.Arguments.processArgs(Arguments.java:347)
      at jdk.compiler/com.sun.tools.javac.main.Arguments.init(Arguments.java:246)
      at jdk.compiler/com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:185)
      at DumpPlatformClassPath.dumpJDK9AndNewerBootClassPath(DumpPlatformClassPath.java:106)
      at DumpPlatformClassPath.main(DumpPlatformClassPath.java:67)
  Caused by: java.nio.file.NoSuchFileException: external/local_jdk
      at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
      at java.base/sun.nio.fs.UnixFileSystemProvider.isSameFile(UnixFileSystemProvider.java:333)
      at java.base/java.nio.file.Files.isSameFile(Files.java:1530)
      at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.isCurrentPlatform(Locations.java:1860)
      ... 14 more
  INFO: Elapsed time: 8.063s, Critical Path: 0.26s
  INFO: 3 processes: 3 linux-sandbox.
  FAILED: Build did NOT complete successfully
  //java/test/edu/berkeley/cs/util:hashset                              NO STATUS
  
  FAILED: Build did NOT complete successfully
  </code></pre>
  
  <p>If anyone can solve this will be glad to send you a bag of Blue Bottle beans or something similar that costs $20 =D</p>