0

None of the instructions available on the JetBrains website or elsewhere allow me to create a Kotlin project, so I assume (as a beginner to Kotlin) I must be missing something. The process of new project creation in JetBrains IDE's is generally quite straightforward and natural (e.g. Python in PyCharm, or even Haskell or Mathematica in IntelliJ); but with Kotlin, I always reach a dead end.

In IntelliJ I'm given several choices for creating a new project, For example, I can select "Kotlin" and choose one of the options there (e.g. "JVM | IDEA")

enter image description here

or choose "Java" and then "Kotlin/JVM"

enter image description here

but in both cases, I then arrive at a dead end, unable to create a new Kotlin source (.kt) file to begin my project, since no such file is among the choices presented:

enter image description here

Confusingly, I am able to add Kotlin source files to non Kotlin projects (e.g. Mathematica):

enter image description here

What am I missing? What is the correct way to create a basic Kotlin project in IntelliJ?

orome
  • 45,163
  • 57
  • 202
  • 418
  • Do you create the file in the source root? See https://www.jetbrains.com/help/idea/configuring-content-roots.html and https://stackoverflow.com/a/43319356/104891. – CrazyCoder Apr 23 '19 at 21:27
  • @CrazyCoder I checked the box to create a content root in `src`, and attempt to create the file there. – orome Apr 23 '19 at 21:31
  • 1
    Make sure the directory you are creating the file in is marked as Source root and is displayed in blue color in the project view. – CrazyCoder Apr 23 '19 at 21:32
  • @CrazyCoder Interesting: There appears to be a bug. The project creation process offers an option (which I select, and is selected by default) to "create a source root", but that doesn't happen. Though the directory is created, it is not marked as a source root. – orome Apr 23 '19 at 21:40
  • Sorry, can't reproduce: https://i.imgur.com/rE20IEC.png https://i.imgur.com/WWCbPFF.png. – CrazyCoder Apr 23 '19 at 21:41
  • @CrazyCoder Any thoughts on why my IDE would be failing to mark the created directory as a source root? Could other plugins be interfering (e.g., Mathematica, Haskell), or could there be a setting somewhere that got flipped into the wrong state? – orome Apr 23 '19 at 21:43
  • Please report at https://youtrack.jetbrains.com/issues/KT with the steps to reproduce, sample project attached and [idea.log](https://intellij-support.jetbrains.com/hc/articles/207241085). – CrazyCoder Apr 23 '19 at 21:47

1 Answers1

0

Better late than never and it still applies because the intellij documentation is still s**it.

  • I am using Intellij Ultimate 2021.2.

If you are a newbie you MUST follow the following in order to be able to write your "Hello World" application:

enter image description here

Why? Because otherwise the following happens:

  1. You will need to configure Gradle or Maven
  2. For some god knows what reason, you will then have to configure your project structure which I tried, and I could not get println to resolve even
  3. You will have errors saying the JVM is not configured

Why on Earth!! Intellij designers opt for this setup method is beyond me...cause I am using the Ultimate edition and it still is like this...so if you are using the community edition, it will be the same I am guessing.

I have now spent 2 hours trying to figure out why each project I have so far created with the defaults is not resolving the code in the 5 lines of code. Anyhooo, if you follow the above, what you get is this: enter image description here

And NOT THIS:: enter image description here

Beezer
  • 1,084
  • 13
  • 18