<< Designing Address Book - Contact List, Part 1 | Home | GUI design - Contact List, Part 2 >>

How to add resources to IntelliJ IDEA and NetBeans

Add image, sound, video or JAR files to your project in IntelliJ IDEA or NetBeans

From my web site log files I learn that some of the visitors been looking for a way to add resources (images, videos, sounds, libraries and others) to their mobile or other projects through NetBeans and IntelliJ IDEA.Until this day, I haven't got anything in regards of this topic so here we come. I will show you how I usually do it. I'm not sure if it is correct way to do it (if it is wrong and you know more appropriate way please do let me know) so consider it as sort of hack. On the end of this entry you can find link to download an example of small mobile application created in NetBeans with Java Platform Micro Edition SDK 3.0, it will also work with Sony Ericsson SDK 2.5.0.3. It will not work under Sun Java Wireless Toolkit 2.5.2 as this does not include Mobile Media API (JSR-135) library that I used for playing MP3 files in provided example.

In the industry it became sort of standard to mark resource folder as "res" in project structure. The way to create "res" folder is the same as any other sub-directory in your project.
NetBeans: under Projects tab right click on the package/directory to which you wish to attach resource folder >> select New >> Java Package
Create New Java Package
give a name to new package "res" and press Finish.
Package name
After this you can simply copy & paste files you want to include in your project (images -jpg, gif, png, svg; sound -mp3, midi; video -avi; and many more) through Windows Explorer or Command Prompt/Line.

Adding resources to IntelliJ IDEA is no different from what I showed above with NetBeans. However there is slight difference between these two if the resource file that needs to be added is Java archive or JAR as you may know it. One extra action has to be done and that is registering JAR with project so we can use functions provided by JAR ( most common would be connector for GUI or web application to enable them communicate with database).

NetBeans: right click on your project to which you wish to add JAR >> select PROPERTIES. In the pop-up window, in CATEGORIES (left side listing) select Libraries & Resources >>on the right press Add JAR/Folder and navigate to place where is the driver or any other library you wish to add >> highlight file/s you want to include and press OK.
NetBeans adding JAR file
These file/s will then be displayed in Libraries and Resources and you need to press OK.
NetBeans resource file added

IntelliJ IDEA: right click on the project >> select Module Settings. From the pop-up window in Project Settings( left side listing) select Libraries.
IntelliJ adding JAR file
Click on the small yellowish plus sign over second column and provide internal name for this library.
IntelliJ create name for internal purpose
Next press Attach Jar Directories and navigate to the directory that holds the JAR file.Once directory holding JAR file found, select it and press OK.
IntelliJ JAR file added
Once this done I normally press Apply (to make sure that linked files references are uploaded properly, this will show progress bar and I can see which resources are uploaded) and then press OK.


Example of Java Mobile project from NetBeans, AddingResources.rar




Add a comment Send a TrackBack