IntelliJ IDEA 2023.3 Help

Resource files

Resources include properties files, images, DTDs, and XML files. 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

  • getResourceAsStream() for icons and other files

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. The following file types are recognized as resources by default:

  • .dtd

  • .jpeg

  • .properties

  • .gif

  • .jpg

  • .tld

  • .html

  • .png

  • .xml

The pattern of recognized resource files can be configured as a regular expression in the Compiler dialog (Settings Ctrl+Alt+S | Build, Execution, Deployment | Compiler). Using the Resource Patterns field, you can add your own file extensions and create a custom list of resources.

For an example on how to add images to your project, refer to Example: Import an image.

Last modified: 15 March 2024