Answer the question
In order to leave comments, you need to log in
How to import a Java class into a Kotlin console project?
import java.io.File //Этот класс импортируется нормально
import org.json.JSONArray // Здесь ошибка - Unresolved reference: json
import org.json.JSONTokener // И здесь - Unresolved reference: json
fun main() {
val file = File("some.json").bufferedReader().readText()
val obj = JSONTokener(file).nextValue() as JSONArray
}
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.6.10"
application
}
group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test:1.6.0")
}
tasks.test {
useJUnit()
}
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
}
application {
mainClass.set("MainKt")
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question