Answer the question
In order to leave comments, you need to log in
When starting a kotlin tornadofx project, I get Error running 'MainView'?
I am new to kotlin. In Intellij Idea, I tried to create a standard project with the TornadoFX plugin, at first Hello World started, but the next day an error appeared:
Error running 'MainView': Argument for @NotNull parameter 'mainClassName' of com/intellij/execution/util/JavaParametersUtil.isClassInProductionSources must not be null
MainView.kt
package com.example.demo.view
import com.example.demo.app.Styles
import tornadofx.*
class MainView : View("Hello Tornado") {
override val root = hbox {
label(title) {
addClass(Styles.heading)
}
}
}
build.gradle
buildscript {
ext.kotlin_version = '1.2.51'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin"
apply plugin: 'application'
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
compile 'no.tornado:tornadofx:1.7.14'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
mainClassName = 'com.example.demo.app.MyApp'
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'com.example.demo.app.MyApp'
)
}
from(configurations.compile.collect { entry -> zipTree(entry) }) {
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}
}
MyView.kt
package com.example.demo.view
import tornadofx.*
class MyView : View("My View") {
override val root = borderpane {
}
}
MyApp.kt
package com.example.demo.app
import com.example.demo.view.MainView
import tornadofx.App
class MyApp: App(MainView::class, Styles::class)
Styles.kt
package com.example.demo.app
import javafx.scene.text.FontWeight
import tornadofx.Stylesheet
import tornadofx.box
import tornadofx.cssclass
import tornadofx.px
class Styles : Stylesheet() {
companion object {
val heading by cssclass()
}
init {
label and heading {
padding = box(100.px)
fontSize = 20.px
fontWeight = FontWeight.BOLD
}
}
}
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