Questions tagged [kotlin-script]

Use only for issues strictly related with Kotlin scripts running in command line, not for generic Kotlin questions

Kotlin can also be used as a scripting language using the Kotlin command line compiler to run scripts.

Working with the Command Line Compiler

30 questions
1
vote
0 answers

Kotlin Script Exception in BasicJvmScriptEvaluator

I am trying to use scripts in my project using Kotlin scripts. I followed the official kotlin tutorial which works fine. Then I wanted to wrap my scripts into an object by setting the constructorArgs private val config =…
micartey
  • 128
  • 6
1
vote
2 answers

java.lang.NoSuchMethodError in Kotlin Script

I wrote a little piece of code using skrape.it in Kotlin (Github Repository Link). I wrote it in a standard gradle project and it works perfectly fine. fun main() { val result = skrape(HttpFetcher) { request { this.url =…
findusl
  • 2,454
  • 8
  • 32
  • 51
1
vote
1 answer

Azure DevOps Pipeline - How to run Kotlin script - *.kts files

To run a Kotlin script one needs to execute: kotlinc -script myScript.kts Do I need to download the Kotlin command-line compiler to have access to it, or there is an easier way?
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
1
vote
1 answer

Kotlin Script: Import class across directories/packages

I'm new to Kotlin so forgive me if this is an easy question. I'm writing a kotlin script that I hope will utilize a custom Hashtable implementation to store data from a file. I'm having trouble getting the script to find the HashTable class. Here is…
1
vote
1 answer

How to compile kotlin script to a jar

I have a kotlin script file named CheckUtils.kts. I want to compile the CheckUtils.kts to a jar which can be run with "java -jar CheckUtils.jar". I try to use kotlinc to compile kts file to a jar, but i failed. kotlinc src/CheckUtils.kts…
1
vote
1 answer

How to run shell tools from kotlin scrip

I am trying to rewrite several sh-scripts into kotlin scripts. How can I run shell commands or execute binaries accessible in the PATH variable from a kotlin script?
jactor-rises
  • 2,395
  • 2
  • 22
  • 44
1
vote
1 answer

Kotlin script fails to run on Windows - org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException

when running: kotlinc -script Day1.kts Day1.kts: println("hello") I get: WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil…
Luís Soares
  • 5,726
  • 4
  • 39
  • 66
1
vote
1 answer

Kscript: script compilation failed. What's the issue?

I can't execute a simple Kotlin script because of compilation failed due to an invalid argument. This is my Kotlin script: #!/usr/bin/env kscript println("Helloooo") Then I've writter my very simple script, I've add executable permission to…
gmgulla
  • 11
  • 1
1
vote
1 answer

How do you resolve a 'java.lang.NoClassDefFoundError' when importing libraries in Kscript?

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…
Dan Largo
  • 1,075
  • 3
  • 11
  • 25
1
vote
1 answer

Evaluate kotlin script file with dependencies

Question: how to execute set of kotlin files in runtime and return result of the one kts file from them? I write system, which is able to execute kts file with instructions. For current moment it supports the following execution schema: main.kts -…
Manushin Igor
  • 3,398
  • 1
  • 26
  • 40
1
vote
1 answer

Kotlin script unable to instantiate class

Attempt at Kotlin Cookbook by Ken Kousen -- 1.5 Executing a Kotlin Script produces 'unable to instantiate class' error. $ cat southpole.kts import java.time.* …
CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
0
votes
1 answer

How to determine why process fails in kotlin script

I am developing a kotlin script which executes code on the platform which it is running on. Platform code is called using this method from the script: fun exec(command: String, vararg arguments: String, runLive: Boolean = !isDebug): OutputStream { …
jactor-rises
  • 2,395
  • 2
  • 22
  • 44
0
votes
0 answers

Kotlin script failing to build

I am trying to get Kotlin scripting to work but both Gradle and IntelliJ IDEA are failing to build the project as they are unable to find the methods that are defined in the base script definition. For a sample project, see…
0
votes
1 answer

Try to find KotlinToJVMBytecodeCompiler.compileScript method in Kotlin 1.4.10

During migration my java project from Kotlin 1.2 to 1.4 I ran into a problem that there is no such method as KotlinToJVMBytecodeCompiler.compileScript() in v 1.4 Class script =…
-1
votes
1 answer

Kotlin script: main function does not get called locally, unlike in online judge

I am trying to participate in online Codeforces contests using Kotlin. My understanding is I should use Kotlin script if my code is contained within a single file. If I run the following file locally (version 1.6.10): kotlin just_main.main.kts //…
xjcl
  • 12,848
  • 6
  • 67
  • 89
1
2