Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import images into an intelliJ Java project

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.

like image 435
Marc H Avatar asked Apr 28 '12 00:04

Marc H


People also ask

How do I import things into IntelliJ?

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.

How do I add an external library to IntelliJ?

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.

How do I import a project module in IntelliJ?

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.

How do I import a class file into IntelliJ?

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.


1 Answers

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.

like image 197
CrazyCoder Avatar answered Nov 15 '22 08:11

CrazyCoder