sbt assembly cannot create jar getting java.lang.UnsupportedOperationException
Asked Answered
H

4

9

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)
Hollywood answered 11/4, 2022 at 17:42 Comment(3)
You should probably use java 8 or java 11Extrasensory
Thanks @Extrasensory you are correct, using java 8 solved itHollywood
Java 17 is ok too.Scurlock
H
7

Using java 8 solved this issue as AminMal suggested

Hollywood answered 12/4, 2022 at 18:29 Comment(1)
Java 17 is ok too.Scurlock
N
6

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
Narial answered 13/11, 2022 at 14:25 Comment(0)
C
0

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://mcmap.net/q/1314457/-how-can-i-configure-disable-or-override-the-sbt-securitymanager

Catholicity answered 11/4, 2022 at 18:15 Comment(2)
Adding this line to the app will not help because the sbt assembly failsHollywood
switching back to Java 17 works for the instant.Scurlock
L
0

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

Licensee answered 18/1, 2023 at 5:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.