Unable to run Java code with Intellij IDEA

后端 未结 12 2503
说谎
说谎 2020-12-14 05:18

I have just downloaded the IDE, and I want to edit my first Java file with it, I\'m not interested in creating a whole project, just editing the single file.

So I op

12条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 05:51

    Move your code inside of the src folder. Once it's there, it'll be compiled on-the-fly every time it's saved.

    IntelliJ only recognizes files in specific locations as part of the project - namely, anything inside of a blue folder is specifically considered to be source code.

    Also - while I can't see all of your source code - be sure that it's proper Java syntax, with a class declared the same as the file and that it has a main method (specifically public static void main(String[] args)). IntelliJ won't run code without a main method (rather, it can't - neither it nor Java would know where to start).

提交回复
热议问题