I'm trying to setup my Kotlin project to run in WS...
# intellij
j
I'm trying to setup my Kotlin project to run in WSL, but I just get this error and have no clue on how to fix it.
I have installed
default-jre
, but can't figure out how get intellij to use this
running any gradle tasks like this
./gradlew build
, works without any problems. But I would like IntelliJ to be fully compatable with my project
c
gradle jdk is set to the same as your JAVA_HOME?
j
I have no clue. I just know this and none of the options under "Gradle JVM" work
echo $JAVA_HOME
returns nothing when running in ubuntu terminal
c
I don't use windows or WSL for that matter, but I do know that I've had a bunch of issues with the JDKs not matching up with the one that is set for my project and the one that is output when I echo. Personally, I would focus on trying to get JAVA_HOME to echo properly as I think a lot of things in intellij require it.
j
I always have a bunch of issues with gradle and jvm settings, which is why I started using this:
Copy code
compileKotlin { kotlinOptions.jvmTarget = "15" }
compileTestKotlin { kotlinOptions.jvmTarget = "15" }
java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(15))
    }
}
But I don't think intellij uses this for anything?
I will try and figure out the JAVA_HOME variable 👍
c
Intellij seems to look here for env vars https://github.com/JetBrains/intellij-community/blob/master/plugins/terminal/resources/jediterm-bash.in and so with that said I think it you find that you can't echo JAVA_HOME inside of terminal then that might be your problem
I've also seen that "shell integration" being selected is sometimes a culprit. Anyway. I hope I did not mislead you. Just giving you a heads up that this was the issue for me (but not on windows or wsl).
j
I have setup intellij to use wsl ubuntu in the terminal settings, that worked in windows projects and now in wsl projects it's also working fine. Seems it's just gradle/kotlin that is not working.
I got it working!
c
Oooh! What was it?
j
just ran
./gradlew build
which then did downloaded all of the required stuff, then when opening that gradle jvm settings page, it now gave me the option to select WSL version
c
Ah nice. 💯
I'm picking up a windows laptop in about ~3 months and def want to use WSL so hoefully this info will come in handy. 😃
👍 1
j
or not, it gave me a new error and without any information...
image.png
😭 1
Got it working now. Need to make sure that: •
Project Structure > Project > Project SDK
is using a (WSL) version. •
Settings > Build > Build Tools > Gradle
has: ◦ A WSL path for
Gradle user home
Use Gradle from
is set to
gradle-wrapper.properties file
Gradle JVM
is using a (WSL) version And if intellij can't find any WSL versions, just run
./gradlew build
. And if this command doesn't work, then you can always google it 😛
🎉 1
Nah not fully working, I'll just give up and try again in a few months. I'm guessing JetBrains are working on improving the experience on this.
😭 1
c
Maybe worth filing a bug?
Maybe I will try more in my free time. Too time expensive to get it to work in work hours 😛
287 Views