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.
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:
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.