Search code examples
javaintellij-ideacompilation

This file in the editor in not runnable intelliJ idea using java


I installed intelliJ idea for the first time to code in java, before this IDE I used VS Code for the development and compilation. After installing I opened previously written code folders in IntelliJ which has the run button in grey showing "this file in the editor is not runnable".

this is the directory structure with the code

Previously in VS Code these files were easily compiled but in IntelliJ idea I have no clue why it is happening.


Solution

  • You should create a Java project using the IntelliJ idea first, so it will create all the necessary files for the IDE to recognize it as a native Java project.

    Then, you can copy and paste your existing file codes into the src folder, respecting the Java module organization of:
    src > main > java > your Files/Packages

    Also, while creating your Java project, I recommend you to create it using Gradle, it will simplify a lot to maintaining the project dependencies.

    References:


    VS Code vs. IntelliJ Idea for Java projects

    • VS Code is a rich text editor like Sublime Text and Atom;
      • You can turn VS Code into an IDE like, using plugins.
    • IntelliJ Idea is a thoroughly professional IDE (Integrated development environment).

    For Java projects, I recommend using IntelliJ Idea, however for a general-purpose code practice, go for VS Code for sure, its flexibility is incredible.