Why is `cs launch scala` (coursier tool) looking for Java in a wrong location?

200 Views Asked by At

I am using the coursier tool to prepare my Scala environment. I ran the following:

C:\Users\jaime>cs setup
Checking if a JVM is installed
Found a JVM installed under C:\Program Files\Java\jre1.8.0_271.

Checking if ~\AppData\Local\Coursier\data\bin is in PATH
  Should we add ~\AppData\Local\Coursier\data\bin to your PATH? [Y/n] Y

Checking if the standard Scala applications are installed
  Found ammonite
  Found cs
  Found coursier
  Found scala
  Found scalac
  Found sbt
  Found sbtn
  Found scalafmt


C:\Users\jaime>cs launch scala
Exception in thread "main" java.lang.Exception: C:\Program Files\Java\jre1.8.0_271\java\bin not found
        at coursier.jvm.JavaHome.$anonfun$javaBin$1(JavaHome.scala:159)
        at coursier.jvm.JavaHome.$anonfun$javaBin$1$adapted(JavaHome.scala:156)
        at coursier.util.Task$.$anonfun$flatMap$extension$1(Task.scala:14)
        at coursier.util.Task$.$anonfun$flatMap$extension$1$adapted(Task.scala:14)
        at coursier.util.Task$.wrap(Task.scala:82)
        at coursier.util.Task$.$anonfun$flatMap$2(Task.scala:14)
        at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
        at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.lang.Thread.run(Thread.java:833)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:597)
        at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:140)

I see that the root cause of the error is that the process is trying to find Java in C:\Program Files\Java\jre1.8.0_271\java\bin. When I examine the folders, I have this folder structure:

enter image description here

I think the process should be looking for C:\Program Files\Java\jdk1.8.0_271\bin, not C:\Program Files\Java\jre1.8.0_271\java\bin.

Is this path something I can manipulate or is this some kind of bug in the coursier tool? I am following the instructions at https://get-coursier.io/docs/cli-launch.

0

There are 0 best solutions below