sbt assembly cannot create jar getting java.lang.UnsupportedOperationException

18.6k views Asked by At

I am using

scala 1.12.10
akka 2.6.3
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0")

However when executing sbt assembly I am getting:

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:109)
    at sbt.xMain.run(Main.scala:76)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:111)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:131)
    at xsbt.boot.Launch$.run(Launch.scala:111)
    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:37)
    at xsbt.boot.Launch$.launch(Launch.scala:120)
    at xsbt.boot.Launch$.apply(Launch.scala:20)
    at xsbt.boot.Boot$.runImpl(Boot.scala:56)
    at xsbt.boot.Boot$.main(Boot.scala:18)
    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

running java 18

java -version
openjdk version "18" 2022-03-22
OpenJDK Runtime Environment (build 18+36-2087)
OpenJDK 64-Bit Server VM (build 18+36-2087, mixed mode, sharing)
4

There are 4 answers

1
igx On BEST ANSWER

Using java 8 solved this issue as AminMal suggested

2
swapyonubuntu On

It was deprecated and for removal in 17 so in 18 it is not expected to be working ref: https://openjdk.java.net/jeps/411 can you try

System.setSecurityManager(null)

Credits: https://stackoverflow.com/a/67940001/1811348

0
blackraven On

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

I also encountered this problem while using Java 19 and Java 18. After that, I downloaded Java 17 and configured the Project Structure, and the problem went away. Steps I took:

(1) Download Java Development Kit version 17, Google search "download java 17".

(2) To install, I run the downloaded file "jdk-17.0.6_windows-x64_bin.exe" (for Windows).

(3) Configure to use Java 17, go to
File -> Project Structure -> Project -> (dropdown) SDK
and you'd see the installed Java 17 under "Detected SDKs"

enter image description here

0
Filippo OrrĂ¹ On

I encountered this issue when checking out an older Scala project. The solution was to change the project/build.properties file.

Before:

sbt.version=1.2.4

After:

sbt.version=1.6.2