1

I'm new to Kotlin scripting, and I'm trying to use Kscript to import libraries. I've been following the tutorials, and trying a very simple script (below) that imports a couple libraries. When I go to run the script, I get the below error (this error happens with any import I try to do). The script runs fine when I remove the imports. Any ideas on how I can fix the imports in my code?

Error message:

[kscript] Resolving dependencies...
[kscript]     Resolving org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2...Exception in thread "main" java.lang.NoClassDefFoundError: org/ietf/jgss/GSSException

My code:

#!/usr/bin/env kscript

@file:MavenRepository("central", "https://repo.maven.apache.org/maven2/")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2")

import kotlinx.coroutines.*

println("Script is running with ${args.size} args passed")

for(arg in args) {
    println("arg: $arg")
}
Dan Largo
  • 1,075
  • 3
  • 11
  • 25

1 Answers1

2

This script fails when you use jdk 9+ and causes the NoClassDefFoundError for org/ietf/jgss/GSSException on Kotlin 1.3.x.

As a workaround use jdk 1.8.

Future fix refer this Dependencies are working only with jdk8

jose praveen
  • 1,298
  • 2
  • 10
  • 17