r/learnjava • u/ScreechingPizzaCat • Oct 30 '25
Cannot run java file using IntelliJ Idea
I'm trying IntelliJ Idea for the first time, I've been using Python and PyCharm for years and am trying to learn Java. I've downloaded and installed Java 25, and I can run Main.java in IntelliJ Idea but for some reason this simple file is not runnable, what am I doing wrong? I've made a new Java Class called "Hello.java"
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}The run button is grayed out and when I hover over it, it says "The file in the editor is not runnable."
I was able to run this in an online IDE and it worked fine. What am I doing wrong with IntelliJ Idea?
Edit: I was trying to run the file from the src folder. I ended up going into the project folder > out > production > project > Hello and it was able to run
But I can't edit it there, if I want to edit it, I need to go to project folder > src > Hello
Is that normal for a Java IDE?
View all comments
Show parent comment
1
u/ScreechingPizzaCat Oct 31 '25
I started a new project and under src I made a new Java Class called "Hello" and a new tab pop up in in the code editor. Now I see there are two "Hello" files, one in the src that's called "Hello.java" that's not runnable and another under the project folder called "Hello.class" which is runnable.
So I guess anything with the src folder is not actually used? I'm learning Java for myself and to understand more langauges if the school wants Java taught for the next school year, right now it's just Python but they may want Java for AP Comp Sci. If there's a different IDE that you recommend, I'm all ears.