The launcher.properties should not be under a folder called Login. It should be placed directly in the src/main/resources/com/abc/xyz folder.


It is really as simple as I said but if the resources folder is not marked as a sources folder then this may be the problem.

This is the initial class and setup:

Now create the resources folder:

This newly created folder should be automatically marked as a sources folder and if it is blue color marked then it is. Otherwise you'll have to mark it manually:

Now you'll be able to add packages to it:

And now you can add the file to it:

And rerunning the application will not give you any null value back:

And the package view will surely show the launchers.properties file as well:

Answer from maba on Stack Overflow
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 4408088791186-What-is-the-path-to-files-in-root-resources-folder
What is the path to files in root resources folder – IDEs Support (IntelliJ Platform) | JetBrains
October 12, 2021 - So I guess I'm not using the resources root correctly. Once I have a file in the resources root folder (or a folder inside of it) how do I get a path to that file? ... Once you have marked a folder as resource folder in IntelliJ, it is available in your code as via resource loader.
🌐
JetBrains
jetbrains.com › help › idea › content-roots.html
Content roots | IntelliJ IDEA Documentation
April 17, 2026 - Select the necessary module and open the Sources tab. In the right-hand pane, under Resource Folders or Test Resource Folders, click to the right of the necessary folder (folder path).
Discussions

How to set resources folder in Intellij ide - java - Stack Overflow
I run again my code ClassLoader ... the out folder. I do not know how to teach intelij the correct path 2021-02-08T20:11:06.9Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 0 How to move a file from sources directory to the resources directory with the same path in IntelliJ ... More on stackoverflow.com
🌐 stackoverflow.com
java - Adding resources in IntelliJ for Maven project - Stack Overflow
If they are not there, your IntelliJ setup is wrong. Resources do not get included in your target build. Check online for tutorials how to do this with IntelliJ idea. ... The launchers.properties is in the class path with the structure pointed by @maba. But still in the code null is returned. More on stackoverflow.com
🌐 stackoverflow.com
intellij idea - How to mark package as a resource folder? - Stack Overflow
When this is done, you put all you java classes under src/main/java/com.mycompany package and any resources under /src/main/resources/com/mycompany folder. To link them together, go to the project properties, and find the Path tab. Mark the src/main/java and src/main/resources as source folders. More on stackoverflow.com
🌐 stackoverflow.com
March 17, 2016
Mark src/main/resources directories and src/test/resources at 'resource Folder' and 'test resource folder' in IntelliJ
Continuing the discussion from The idea plugin breaks the new Intellij 13 .iml configuration: This does not work for me. Does it need to be whenMerged? I am using gradle 2.11 and intelliJ 14.1. Any pointers? More on discuss.gradle.org
🌐 discuss.gradle.org
8
0
December 21, 2015
🌐
JetBrains
jetbrains.com › help › idea › resource-files.html
Resource files | IntelliJ IDEA Documentation
When building an application, IntelliJ IDEA copies all resources into the output directory, preserving the directory structure of the resources relative to the source path.
🌐
Stack Overflow
stackoverflow.com › questions › 66108182 › how-to-set-resources-folder-in-intellij-ide-java
How to set resources folder in Intellij ide - java - Stack Overflow
Show activity on this post. In project frame, right click directory -> mark as -> Resources. Or click the Resources button in the header in your first screen shot (with that directory selected as shown).
🌐
Bloomu
javabook.bloomu.edu › addresources.html
How to Add Resources to an IntelliJ Project
Your application can load resources such as audio and image files at runtime. For this you will need to create a resources folder in the project's root directory.
Top answer
1 of 7
76

The launcher.properties should not be under a folder called Login. It should be placed directly in the src/main/resources/com/abc/xyz folder.


It is really as simple as I said but if the resources folder is not marked as a sources folder then this may be the problem.

This is the initial class and setup:

Now create the resources folder:

This newly created folder should be automatically marked as a sources folder and if it is blue color marked then it is. Otherwise you'll have to mark it manually:

Now you'll be able to add packages to it:

And now you can add the file to it:

And rerunning the application will not give you any null value back:

And the package view will surely show the launchers.properties file as well:

2 of 7
4

As @maba pointed out, your properties file should be in the same package as your class for your code to work.

So, you should have two files:

  • src/main/java/com/abc/xyz/Login.java
  • src/main/resources/com/abc/xyz/launcher.properties

If IntelliJ is showing the resource or not is beside the question. What you need to do is check if the results are included in your target artefact.

Do a build all in IntelliJ, open up the resulting WAR/JAR/EAR with your favorite ZIP viewer and browse into the "com/abc/xyz" folder. You should see both files there.

  • If they are, you are doing something wrong in your code. Check for typos, especially dots and spaces at the end or beginning (e.g. "launcher.properties[space]"), copy/paste the file name to make sure
  • If they are not there, your IntelliJ setup is wrong. Resources do not get included in your target build. Check online for tutorials how to do this with IntelliJ idea.
Top answer
1 of 3
22

This can be solved in several ways. An example of a good approach would be the following folder structure:

src
  main
     java
     resources
  test
     java
     resources

When this is done, you put all you java classes under src/main/java/com.mycompany package and any resources under /src/main/resources/com/mycompany folder.

To link them together, go to the project properties, and find the Path tab. Mark the src/main/java and src/main/resources as source folders. (see the screen-shot attached)

If you link them together, you'll be able to use getResourceAsStream() method. If you wonder why you should use the following folder structure - this is standard maven way of keeping things clean and tidy.

2 of 3
3

Directories Creation

Intellij creates directories when you ask her to create package. It is not an error.

If you create package "com", it will create the dir "com", and if you create a source file there, it will think that the file is in the package "com".

If you create package "com.next.pack", it will create three nested dirs "com", then "next", then "pack", and if you create a source file there, it will think that the file is in the package "com.next.pack".

Directories Structures

Only the path under the source root is taken as a package. Any directory(ies) can be set as a source root(s).


Resources roots

Make practically any structure of directories. Somewhere in it there is the root dir of resources. Right-click it and Mark Directory As ... Resources Root.

Notice, the same method can be used for the directories structures for tests, test classes, and test resources. Look here.

🌐
Coderanch
coderanch.com › t › 770883 › frameworks › Trouble-creating-viewing-files-resources
Trouble for creating/viewing files from the resources folder (intellij) (Spring forum at Coderanch)
March 7, 2023 - Hello, i would like your insights on a problem i have. I have a resources folder and i would like to create a new file in. My data base have at the "Article" table : path and filename. The path is « /img/articles/thumbnail/ » which is in the "resources" folder on intellij.
Find elsewhere
🌐
Gradle
discuss.gradle.org › help/discuss
Mark src/main/resources directories and src/test/resources at 'resource Folder' and 'test resource folder' in IntelliJ - Help/Discuss - Gradle Forums
December 21, 2015 - Continuing the discussion from The idea plugin breaks the new Intellij 13 .iml configuration: This does not work for me. Does it need to be whenMerged? I am using gradle 2.11 and intelliJ 14.1. Any pointers?
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 115000136190-static-base-path-to-resource-files
static base path to resource files – IDEs Support (IntelliJ Platform) | JetBrains
March 29, 2017 - IntelliJ IDEA Open API and Plugin Development · Imants Cekusins · Created March 29, 2017 15:55 · is this possible to specify base path to resource files included in plugin jar - as static constant? 1 comment · Sort by Date Votes · Imants Cekusins · Created March 30, 2017 08:04 · Comment actions Permalink · this works: add resources folder at the same level as src, mark it as resources folder.
🌐
JetBrains
jetbrains.com › help › idea › web-application-static-content.html
Configure static content resources | IntelliJ IDEA Documentation
June 17, 2024 - Store the required resources and directories below the <project root>\web folder. After deployment, the entire folder hierarchy of these resources will be copied to the server below the application root.
🌐
YouTube
youtube.com › watch
How to create a Resource folder in Java with IntelliJ and how to access it - YouTube
I will be showcasing how to create a resource folder in Intellij, and I will create a method that readers a file form the resource folder and print the input...
Published   March 5, 2021
🌐
JetBrains
jetbrains.com › help › idea › web-resource-directory-path-dialog.html
Web resource directory path dialog | IntelliJ IDEA Documentation
February 11, 2024 - Web resource directory path · The path to a directory that contains your web app resources such as web pages, images, etc
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360000655999-Creating-or-jumping-to-a-resource-folder-for-a-given-class
Creating or jumping to a resource folder for a given class – IDEs Support (IntelliJ Platform) | JetBrains
I often want to create a resource file for a class that should be in the same folder structure as the file. For example I have ... If that folder doesn't exist yet I copy the relative path of the java file, remove everything before "src", navigate to the resources folder, create a new folder and paste the path.
🌐
Reddit
reddit.com › r/intellijidea › intellij idea ce can't recognize resources folder when using gradle extension
r/IntelliJIDEA on Reddit: IntelliJ IDEA CE can't recognize resources folder when using Gradle extension
December 7, 2019 -

So, I am trying to load a BufferedImage. I know how to do this and I got the exact same code and images to work in a different IntelliJ project file without using Gradle. The issue is that I am getting this exception because it does not recognize my resources folder for whatever reason. My resources folder is marked as "Resources Root" as it should be both projects.

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: input == null!

I've been doing some searches online and it appears to be a common problem with the Gradle extension on IntelliJ but I'm struggling to comprehend the solution. I'm wondering if I can fix it just by toggling a setting so that my resources are included in the class path?

I would honestly just not use Gradle (in this situation, not knocking the program as a whole), but this is a school project where I am required to.

🌐
CodingTechRoom
codingtechroom.com › question › -access-resource-files-java-intellij
How to Access Resource Files in Java Using IntelliJ IDEA - CodingTechRoom
Their path is case-sensitive. Ensure your resource files are located in the `src/main/resources` directory or a similarly designated resources directory. Right-click on the folder in IntelliJ and select 'Mark Directory as' -> 'Resources Root'.