Reputation: 11
My desktop app use the ScriptEngine
to do something, which I know ScriptEngine
is removed after JDK 11.
So I added a dependency like this:
implementation("org.openjdk.nashorn:nashorn-core:15.3")
and some example code like this:
val manager = ScriptEngineManager()
val engine = manager.getEngineByName("javascript")
val hookJsCode = """
function test(){
return 10;
}
"""
engine.eval(hookJsCode)
val result = engine.eval("test()")
println(result.toString())
It's ok when I run the jar but fails when I run the dmg which I distribute.
The tip message is in the following picture
I don't know what happens. Is there someone that can help me? Thanks.
PS: By the way, I use the openjdk 18 of zulu to distribute dmg. And I distribute to msi to window system it's also ok.
Upvotes: 0
Views: 52
Reputation: 24712
I also encountered error when executing runRelease
task.
I resolved the problem by creating a rules.pro
file beside my build.gradle(.kts) file with the following content:
-keep class org.openjdk.nashorn.** { *; }
-dontwarn org.openjdk.nashorn.**
# If with above you still get error, try to uncomment the below line as well:
# -dontoptimize
Then in my build.gradle(.kts) file I specified that file as Proguard config:
compose.desktop {
application {
// ...
nativeDistributions {
// ...
buildTypes.release.proguard {
// ...
configurationFiles.from("rules.pro")
Upvotes: 0