Questions tagged [kotlinc]

Kotlin Compiler - Comes bundled with standard Kotlin package

Compile the application using the Kotlin compiler.

$ kotlinc hello.kt -include-runtime -d hello.jar

The -d option indicates what we want the output of the compiler to be called and may be either a directory name for class files or a .jar file name. The -include-runtime option makes the resulting .jar file self-contained and runnable by including the Kotlin runtime library in it. If you want to see all available options run

$ kotlinc -help

Run the application.

$ java -jar hello.jar

61 questions
3
votes
1 answer

How to compile a Kotlin file to JavaScript?

Hi I am getting started with KotlinJS on Node and I've put a very simple kotlin file and I want to compile it using the raw kotlinc-js compiler. Without using gradle package main fun heavy() { (1..10_000_000).forEach { it*it } } fun main() { …
Some random IT boy
  • 7,569
  • 2
  • 21
  • 47
3
votes
1 answer

how to compile kotlinx.serialization libraries on the command line?

This is very close to what I'm trying to accomplish. How to compile and run kotlin program in command line with external java library I really want to learn how to compile and run simple code that includes libraries but am getting a bit lost when it…
3
votes
0 answers

How can I import com.google.* using kotlinc, the command line kotlin compiler

Source code (standalone) import com.google.gson.Gson import com.google.gson.GsonBuilder class LocationReport(var dateTimeStamp : String, var latitude : Double, var longitude : Double) { } fun main(args: Array) { …
3
votes
1 answer

Error with using json classes from within kotlin REPL and scratch files

I'm working on an Android project that needs to process json data retrieved from a web API. From within the project I successfully used the classes JSONObject and JSONArray (package org.json) without any problems. Always running compiling, running…
olik79
  • 1,402
  • 1
  • 13
  • 16
3
votes
1 answer

Kotlin Compiler: `nop`s in bytecode

I'm checking kotlinc bytecode of capturing lambdas. And trying to understand the reason why resulting bytecode has nop instructions. kotlinc -jvm-target 1.6 . private inline fun lambdaCapturing(f: () -> Int): Int = f() fun main(args: Array)…
Sergei Rybalkin
  • 3,337
  • 1
  • 14
  • 27
3
votes
2 answers

Kotlinc command line error

I follow this (https://kotlinlang.org/docs/tutorials/command-line.html) instruction. I set the environment variable (windows 7) to bin directory run "kotlinc" at the command line i get the following error (I even navigate to the bin directory from…
Daud Oladipo
  • 63
  • 1
  • 6
3
votes
1 answer

Import dependency libraries in kotlinc terminal

I am playing with kotlinc in mac terminal, however I would like to use libraries like rest client inside kotlinc. Is there a way to include? Like import in python
王子1986
  • 3,019
  • 4
  • 31
  • 43
2
votes
0 answers

Running kotlin files in VS code terminal, kotlinc not recognized

I want to run Kotlin code in VS Code rather than IntelliJ or any other IDE because it's the one I've been using for the longest time and I got used to it. I searched on YT and Google how to achieve this and basically, I got that I have to install…
yonatan goldin
  • 91
  • 1
  • 10
2
votes
2 answers

kotlinc compile multiple files/dependencies/imports

I want to compile a kotlin file with a dependency / import package_a.kt // file: package_a.kt package package_a fun function_from_package_a(){ println(" hurray function_from_package_a was called ! ") } main.kt // file: main.kt import…
Jonas Frey
  • 65
  • 6
2
votes
1 answer

How to remove debug info from compiled kotlin classes

Is there any way to make kotlin compiler stop adding debug info to compiled classfiles? Something like -g:none argument for javac?
nnesterov
  • 1,232
  • 1
  • 10
  • 27
2
votes
1 answer

How to compile and run a kotlin file which has dependencies on a jar from CLI?

I have a file called A.kt which has dependencies on B.jar. How to compile and run the kotlin file on CLI? I have tried: kotlinc A.kt -cp B.jar but this did not work. The error I get is: A.kt:11:24: error: unresolved reference: B val b = B(
Vishisht Tiwari
  • 101
  • 1
  • 8
2
votes
2 answers

Kotlin Compiler Plugin: How to check if a property has an annotation?

I am creating a Kotlin compiler plugin in which I need to check if a property of a data class has an annotation: data class User( @MyAnnotation val name: String ) I override DelegatingClassBuilder.newField in the following way: internal…
Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148
2
votes
2 answers

Annotation Processing: how to change annotation target in Kotlin code?

Quite often, when I use annotations from Java libraries in Kotlin code, I have to specify target in order to specify what element in the compilled code has to be annotated: data class User( val id: String, @get:Email val email:…
Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148
2
votes
1 answer

How to open kotlin repl using kotlin-native-linux?

I just downloaded kotlin compiler kotlin-native-linux-1.3.61.tar.gz from here: https://github.com/JetBrains/kotlin/releases/tag/v1.3.61 But when I try to open the repl, as proposed in the documentation, running:…
Marinos An
  • 9,481
  • 6
  • 63
  • 96
2
votes
0 answers

How to configure the Kotlin bytecode inspector?

I want to configure the Kotlin bytecode inspector code in AS 3.5 to use an older version of the Kotlin compiler. Is it possible? Currently I have a Kotlin 1.1 project, and I'm interested in seeing what the bytecode looked like for certain features…
macquack
  • 57
  • 6