https://kotlinlang.org logo
n

Nthily

05/03/2021, 7:21 PM
Has anyone had this problem? I can't find the
MainClass
in the jar I generated with
Gradle
package
r

randomcat

05/03/2021, 7:22 PM
The main class isn't the issue
The kotlin stdlib is not in your classpath
n

Nthily

05/03/2021, 7:23 PM
omg
i check it
@randomcat
there still seems to be errors
r

randomcat

05/03/2021, 7:25 PM
that's not sufficient
n

Nthily

05/03/2021, 7:25 PM
omg What other dependencies do I need to add?
r

randomcat

05/03/2021, 7:25 PM
I see you're using the application plugin, you should be using the generated shell script, not the raw jar
run
./gradlew installDist
and look in
build/install
e

ephemient

05/03/2021, 7:30 PM
that, or just use
./gradlew run
n

Nthily

05/03/2021, 7:31 PM
image.png
uff
image.png
I am now trying to use
kotlinc mainKt.kt
It seems like it might work this time
😭How do I add dependency parameters to kotlinc?
r

randomcat

05/03/2021, 7:39 PM
don't, just use a build tool
n

Nthily

05/03/2021, 7:39 PM
image.png
this is too weird... i was completely unable to successfully package it into a jar using the included gradle
e

ephemient

05/03/2021, 7:41 PM
your build.gradle needs to state your dependencies
n

Nthily

05/03/2021, 7:41 PM
yes i do
image.png
Let me demonstrate it from the beginning
r

randomcat

05/03/2021, 7:42 PM
And which one of those provides
org.jetbrains.kotlin.cli
?
n

Nthily

05/03/2021, 7:42 PM
what...idk
but i can run my mainKt.kt
i check it
not at all...
image.png
e

ephemient

05/03/2021, 7:47 PM
https://youtrack.jetbrains.com/issue/KT-41657 some windows jvm are buggy apparently
n

Nthily

05/03/2021, 7:48 PM
emm
my jdk is
image.png
@ephemient thank you i check it
I also think this is a bug in jdk
look at this
e

ephemient

05/03/2021, 7:51 PM
no, that is not a bug. the jar only contains your classes, not your whole classpath
that is why you use the script generated by
installDist
n

Nthily

05/03/2021, 8:48 PM
omg!!!!!!!!
I solved it
1. update gradle to 7.0 2. add shadow
I think it's because I've added other dependencies, so I need to use shadow
e

ephemient

05/03/2021, 8:49 PM
shadow is almost certainly a workaround for something you should be doing better.
n

Nthily

05/03/2021, 8:50 PM
image.png
i can run it
@ephemient thank you!
e

ephemient

05/03/2021, 8:52 PM
don't use
java -jar
.
3 Views