Try this:

  • Go to Project Structure.
  • Select your module.
  • Find the folder in the tree on the right and select it.
  • Click the Sources button above that tree (with the blue folder) to make that folder a sources folder.
Answer from ColinD on Stack Overflow
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206261449-Adding-Resource-Files-to-Run-Configuration
Adding Resource Files to Run Configuration – IDEs Support (IntelliJ Platform) | JetBrains
I needed to have the file path in my Load Properties method point to "/jndi.properties"... the "/" was the thing (Like Stephen Fredrick said).... since they were in the classes folder, I had to point out that they were in the "root" of the classes folder... The program now picks up the log4j.properties file and the bindings file correctly. As I said, each IDE has it's own quirks. Once one figures them out, then IntelliJ's increase in productivity will become more and more apparent.
🌐
Crunchify
crunchify.com › technology & tools › how to add resources folder, properties at runtime into intellij classpath? adding property files to classpath
How to add Resources Folder, Properties at Runtime into IntelliJ classpath? Adding Property files to Classpath • Crunchify
May 31, 2023 - Basically IntelliJ was giving me NullPointerException as it was not able to find resource folder at runtime. Here is a code block. String propFileName = "config.properties"; InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName); prop.load(inputStream); <========= NPE here while loading config.properties file if (inputStream == null) { throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); }
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206203829-Adding-folder-to-classpath-tomcat
Adding folder to classpath - tomcat – IDEs Support (IntelliJ Platform) | JetBrains
I feel like a bit of an idiot here but am am frustrated with my attempts to add a folder to the classpath. I am running tomcat from within IJ and i have my properties file in a folder that is not part of source. (src/test/resources) What i did was to rigt click that folder and mark it as a source folder (which made it turn blue).
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206841085-Adding-property-files-to-classpath
Adding property files to classpath – IDEs Support (IntelliJ Platform) | JetBrains
September 18, 2014 - I did add the Velocity template extention to the compiler resource patterns. (*.htm). The 2nd module with the properties I need looks something like this. BatchConfig -DEV --DEVLOCAL ----properties ( properties I need) ----common ----CDE ( properties I need) -QA -PROD MyRegularJavaApp --src ---main ------- ------- If I need the properties & CDE directory on the classpath for MyRegularJavaApp; So I go to module settings for MyRegularJavaApp and go to the dependecies tab.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206234729-Resources-and-classpath-when-running-test
Resources and classpath when running test – IDEs Support (IntelliJ Platform) | JetBrains
February 9, 2012 - IDEA includes in the classpath only output directories as we do not make a difference between source root with java files and with resources on that level. Sorry for the inconvenience ... ok, thank you for your reply. I use gradle to build my project, but all I want to do is to make IDEA aware of the project resources (xml-files).
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206863325-Howto-add-a-directory-to-the-classpath-
Howto add a directory to the classpath? – IDEs Support (IntelliJ Platform) | JetBrains
February 15, 2008 - So, is there a viable way to do what I'm describing with intellij? ... You can create several modules with just classpath entries in the dependencies (https://www.jetbrains.com/help/idea/creating-and-managing-modules.html#working-with-module-dependencies), then in the run/debug configuration specify which module classpath to use. ... this seems like a viable option, will check later, also, now I'm able to search the class lib by marking the folder as source.
🌐
Pinterest
in.pinterest.com › pin › 538320961711648709
How to add resources folder, properties at runtime into ...
Skip to content · When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures · Log in · Sign up
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360003196979-Not-able-to-find-resource-file-in-classpath
Not able to find resource file in classpath – IDEs Support (IntelliJ Platform) | JetBrains
February 27, 2019 - Tomcat Version # 7.0.92 Java Version # 1.8 Intellij Idea version # 20198.3 OS # MAC ... To add file to the classpath you need to make sure it is located in folder under the project content root (as sources or resources type as you have it on the screenshot) http://www.jetbrains.com/idea/webhelp/configuring-content-roots.html .
Find elsewhere
🌐
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.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 206262219-resource-classpath-problem-intellij-9-0-2
resource classpath problem intellij 9.0.2 – IDEs Support (IntelliJ Platform) | JetBrains
June 4, 2010 - I.e. 'put *.otf file to classpath' means put it to directory that is marked as a 'source root' at IDEA; What is meant under 'add resource to the build path'? What kind of build you perform - IDEA artifact, custom ant/maven/shell script etc?
🌐
Pinterest
in.pinterest.com › pin › new-how-to-add-resources-folder-properties-at-runtime-into-intellijs-classpath-adding-property-files-to-classpath-java-inte--538320961711648709
New: How to add resources folder, properties at runtime ...
Skip to content · When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures · Log in · Sign up
🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-180549
Resource not added correctly to project classpath when in a ...
August 12, 2022 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
jetbrains.com › help › idea › resource-files.html
Resource files | IntelliJ IDEA Documentation
These files are located in the classpath of your application, and are usually loaded from the classpath using the following methods: ResourceBundle.getBundle() for properties files and resource bundles ... For more information about these methods, refer to Location-Independent Access to Resources. 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.
🌐
JetBrains
youtrack.jetbrains.com › issue › KTIJ-10927 › MPP-Intellij-runner-Run-does-not-add-resource-directory-to-classpath
MPP, Intellij runner: Run does not add resource directory to ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-133399 › IDEA-does-not-add-resourses-from-resourceDirs-to-classpath-in-Gradle-projects
IDEA does not add resourses from resourceDirs to ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Stack Overflow
stackoverflow.com › questions › 47275235 › how-do-you-properly-include-a-resource-folder-in-a-jar-artifact-in-intellij-idea › 47275495
java - How do you properly include a resource folder in a JAR artifact in IntelliJ IDEA? - Stack Overflow
November 13, 2017 - This folder is at the same directory level as the src folder. I have res marked as Resources Root. I configured my artifact to include res as a Content Directory by way of Project Structure -> Artifacts -> Add (Alt + Insert) -> JAR · Then, in the output layout tab, I pressed the Add dropdown box -> Directory Content -> res · When I run the project in Intellij, it finds the resources just fine.
🌐
JetBrains
jetbrains.com › help › idea › content-roots.html
Content roots | IntelliJ IDEA Documentation
April 17, 2026 - Create a content root for your project and configure a folder structure for your production code, your tests, and resource files.
Top answer
1 of 9
340

In Intellij 13, it looks it's slightly different again. Here are the instructions for Intellij 13:

  1. click on the Project view or unhide it by clicking on the "1: Project" button on the left border of the window or by pressing Alt + 1
  2. find your project or sub-module and click on it to highlight it, then press F4, or right click and choose "Open Module Settings" (on IntelliJ 14 it became F12)
  3. click on the dependencies tab
  4. Click the "+" button on the right and select "Jars or directories..."
  5. Find your path and click OK
  6. In the dialog with "Choose Categories of Selected File", choose Classes (even if it's properties), press OK and OK again
  7. You can now run your application and it will have the selected path in the class path
2 of 9
101

It appears that IntelliJ 11 has changed the method, and the checked answer no longer works for me. In case anyone else arrives here via a search engine, here's how I solved it in IntelliJ 11:

  1. Go to the Project Structure, click on Modules, and click on your Module
  2. Choose the "Dependencies" tab
  3. Click the "+" button on the right-hand side and select "Jars or directories..."
  4. Add the directory(ies) you want (note you can multi-select) and click OK
  5. In the dialog that comes up, select "classes" and NOT "jar directory"
  6. Make sure you're using that Module in your run target

Note that step 5 seems to be the key difference. If you select "jar directory" it will look exactly the same in the IDE but won't include the path at runtime. There appears to be no way to determine whether you've previously selected "classes" or "jar directory" after the fact.

🌐
Stack Overflow
stackoverflow.com › questions › 55953364 › intellij-including-resource-folders-in-classpath
intelliJ Including Resource Folders in Classpath - Stack Overflow
May 2, 2019 - previously with Tomcat 7.0.85 I was able to include the resource folders (including properties etc..) for my project using "-Xbootclasspath/a" But now I had to switch to Tomcat 9.0.19 and I do again