Wednesday, May 25, 2022

How to fix SBT error: error during sbt launcher: java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release

This is the log of the error:

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:127)

        at sbt.xMain$.run(Main.scala:67)

        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)

        at java.base/java.lang.reflect.Method.invoke(Method.java:577)

        at sbt.internal.XMainConfiguration.run(XMainConfiguration.scala:45)

        at sbt.xMain.run(Main.scala:39)

        at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)

        at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)

        at xsbt.boot.Launch$.run(Launch.scala:149)

        at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)

        at xsbt.boot.Launch$.launch(Launch.scala:159)

        at xsbt.boot.Launch$.apply(Launch.scala:44)

        at xsbt.boot.Launch$.apply(Launch.scala:21)

        at xsbt.boot.Boot$.runImpl(Boot.scala:78)

        at xsbt.boot.Boot$.run(Boot.scala:73)

        at xsbt.boot.Boot$.main(Boot.scala:21)

        at xsbt.boot.Boot.main(Boot.scala)

[error] [launcher] error during sbt launcher: java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release

This error is caused by running SBT with Java JDK 18 because in Java 17, the security manager is deprecrated, so to solve this we must change our JDK version to something else like JDK 8 or JDK 11.

This is how you check which version of Java your SBT is using 

sbt -v

This is how you check your java version in Mac os, go to terminal and put in:

java -version

This is how you see all the JDK you have installed in your Mac OS:

/usr/libexec/java_home -V   

To fix this error you must change the JDK version.

This is how you change your JDK version in Mac OS:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`


3 comments: