Replies: 1 comment
🛠️ Scala CLI Java Version Error (Windows) - Fix Guide❌ ProblemRunning: echo 'println("Hello")' | scala-cli -fails with: Even though Java is installed: java -version
java version "26"🧠 Root Causeentity["software","scala-cli","Scala command line tool"] is trying This causes a mismatch between: - Scala CLI default target (Java 8) - ✅ Solutions✔️ Option 1 (Recommended): Use Java LTS (17 or 21)Install Java 17 or Java 21, then run: scala-cli --jvm 17 -or scala-cli --jvm 21 -✔️ Option 2: Set JAVA_HOMESet environment variable: Then restart terminal. ✔️ Option 3: Explicit JVM pathscala-cli --java-home "C:\Program Files\Java\jdk-17" -🎯 ResultAfter fixing: - Compilation works ✔️ - No java-output-version error ✔️ - 💡 RecommendationFor Scala development: - Use Java 17 or Java 21 (LTS) - Avoid very 🚀 SummaryThis is a tooling compatibility issue, not a code issue. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
echo 'println("Hello")' | scala-cli -
Compiling project (Scala 3.8.3, JVM (8))
Error: 8 is not a valid choice for -java-output-version
scalac -help gives more information
Error compiling project (Scala 3.8.3, JVM (8))
Compilation failed
C:\Users>java -version
java version "26" 2026-03-17
Java(TM) SE Runtime Environment (build 26+35-2893)
Java HotSpot(TM) 64-Bit Server VM (build 26+35-2893, mixed mode, sharing)
All reactions