I am working on a Java project that requires the use of several images. I'm on ubuntu linux So I have an images folder inside my src directory. So far so good but try as I might I can't seem to find a way to load or import image files into that images folder. ( I want to be able to simply go something like loadImage("images/imageToLoad.png"); )
I have tried to just drag and drop. I know that I could of course leave the program and use the linux filesystem to transfer the images but that's a pain and defeats the purpose of an IDE.
You can configure the IDE to automatically add import statements if there are no options to choose from. In the Settings/Preferences dialog ( Ctrl+Alt+S ), click Editor | General | Auto Import. Select the Add unambiguous imports on the fly checkbox, and apply the changes.
From the main menu, select File | Project Structure | Project Settings | Modules. Select the module for which you want to add a library and click Dependencies. button and select Library. In the dialog that opens, select a project or a global library that you want to add to the module.
Import an existing moduleFrom the main menu, select File | New | Module from Existing Sources. In the dialog that opens, specify the path the . iml file of the module that you want to import, and click Open. By doing so, you are attaching another module to the project without physically moving any files.
For the newer versions of Intellij, press Ctrl + Alt + Shift + s to open project settings, then choose Modules, under Dependencies tab choose the green + and add the folder in which your . class file is located.
You will have to do it in a file manager, outside of IntelliJ IDEA. To ensure that images are available in the application classpath check Settings
| Compiler
| Resource Patterns
, .png
extension needs to be listed there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With