I'm still new to IntelliJ and still learning how to use it. Basically I have created a program already before and I just want to use my existing .java files in IntelliJ. I tried import/open option on the intro screen of IntelliJ but when I opened the .java files there weren't any menus, no functions, and you can't run the program at all, it just seemed to open a tabbed text editor of my .java files. So I tried creating a new project, and then opening the .java files afterwards, but no dice too, the run button is blacked out and I can't run my program. I used the command prompt before and used java (filename.java) to run my program and now just migrating to use an IDE. Can somebody help? I seem to have stuck at the beginning of my IDE journey.
-
You should start by creating a new project, then adding the source as a source folder or copying the source to the projects source folder. – matt Jun 04 '20 at 12:33
-
https://stackoverflow.com/questions/18852425/intellij-does-not-show-class-when-we-right-click-and-select-new try this answer – jnrdn0011 Jun 04 '20 at 12:36
-
Thanks copying it to the src directory seemed to work. I don't understand though why they would put an option to import/open f youi have to do this. – buencamino Jun 04 '20 at 13:19
2 Answers
You cannot simply open a file using Java. IntelliJ IDEA needs several configuration like Java SDK and other configuration files in order to run it. You have to create a simple Java project and copy your already created Java file into that project's src
directory. Then you will be fine.

- 1,646
- 1
- 14
- 26
-
Thanks copying it to the src directory seemed to work. I don't understand though why they would put an option to import/open f youi have to do this. – buencamino Jun 04 '20 at 13:19
-
Import is for opening existing project. That's mostly used to import Maven projects. – Piyush Patel Jun 04 '20 at 13:35
I just opened the first folder with '...web' as part of its name :) Not sure how scientific that was.
I am using Jet Brains Itellij Idea version with this info: IntelliJ IDEA 2021.2.3 (Community Edition) Build #IC-212.5457.46, built on October 12, 2021 Runtime version: 11.0.12+7-b1504.40 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 1972M Cores: 4
Kotlin: 212-1.5.10-release-IJ5457.46
I drilled to a folder called detourweb. The app found what it needed.
Again, not sure how scientific or repeatable this method is. Assuming all developers will have some 'web' file in their project, try rolling the dice and drill to the first such file.
I don't expect a lot of up votes here, LOL. Here's an answer from a .Net Visual Studio dude.

- 827
- 1
- 10
- 14