Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am trying to learn Scala through the
Creative Scala
guide. However, I get an error when I try to run on terminal the command below that is on page 12.
Now change to the directory we just created and run SBT.
cd creative-scala-template
./sbt.sh
The error I get is:
Unrecognized VM option 'CMSClassUnloadingEnabled'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
It seems that the problem is with sbt?
I tried to follow the top comment in this other question, that says to go to the folder /usr/local/etc/sbtopts
and do some changes, but my folder /usr/local/
is empty.
Can anyone tells me what I am likely doing wrong, please?
By doing java -version
I get:
openjdk version "18.0.2" 2022-07-19
OpenJDK Runtime Environment (build 18.0.2+9-61)
OpenJDK 64-Bit Server VM (build 18.0.2+9-61, mixed mode, sharing)
And sbt -version
gets me:
sbt version in this project: 1.7.1
sbt script version: 1.7.1
After the solution by Tim, I am now getting a different error when running ./sbt.sh
. Does anyone knows how to fix this?
java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
at java.base/java.lang.System.setSecurityManager(System.java:416)
at sbt.TrapExit$.installManager(TrapExit.scala:53)
at sbt.StandardMain$.runManaged(Main.scala:128)
at sbt.xMain.run(Main.scala:89)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:56)
at xsbt.boot.Boot$.main(Boot.scala:18)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
In this case, the option is defined in the sbt.sh
file itself, included in the template project. This option was removed in Java 14 and later, and the guide you are using was developed with an earlier Java version.
You can edit this file and delete the text -XX:+CMSClassUnloadingEnabled
from it.
All of the other options currently in that file are still supported as of Java 18.
The resulting command will look like this:
java -Xmx3g -Xms1g -XX:+TieredCompilation -XX:ReservedCodeCacheSize=256m -XX:+UseNUMA -XX:+UseParallelGC -jar sbt-launch.jar "$@"
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.