resource classpath problem intellij 9.0.2


I seem to be having a rather peculiar problem.  I need to add a .otf file (Open Type Font) to the classpath, however it never gets taken into the buildpath.  And the really weird thing is, when I take another more standard build file (like .properties or .jpg) and put it in the same directory using IntelliJ it DOES get taken into the build.  I'd test with some other way to build this project but that's kind of hard to do with me not knowing a lot about Ant.
At any rate.  If I rename my .otf file to .otf.jpg it's ok, but that's not a very neat solution.

Doesn anyone know what's going on?  Maybe there's some kind of file filter excluding certain files?

Thanks in advance.


Hi Thomas,

I'm afraid it's not clear what do you want to get. Let's clarify that a bit.

  1. 'Adding resource to classpath' is basically putting it to location that is known to the target application class loader. I.e. 'put *.otf file to classpath' means put it to directory that is marked as a 'source root' at IDEA;
  2. What is meant under 'add resource to the build path'? What kind of build you perform - IDEA artifact, custom ant/maven/shell script etc?

Regards, Denis


I mean it in the simpelest way possible.

I define a "resources" directory in my IDEA project and set it as build path in the module settings.  Then I use the filesystem to copy-paste a file into it.  When choosing "make module" the output specified in the module settings builds the projects classes and resources.  This is where the problem lies, any resource (jpg, properties,...) gets built in the output while the otf file doesn't.  When I rename the .otf file to it's there.
I don't think it's a Java problem, I haven't been working long with IDEA and I've always been able to add any given file to the classpath.

The idea is to load the .otf file into a Font loader using getClass().getResource(....).


Of course I do keep missing on the "build path" "classpath" names.

I add the .otf file to the "classpath" and doesn't end up at the classes and resources output.
I rename the .otf file to and it does end up there.



I think if you go into Settings -> Compiler and add a pattern for your extension in the "Resource Patterns" box it should work as expected.  You'll notice .jpg and .properties are there by default which is why it works when you rename your files with those extensions.


Just tried your use-case:

  1. Put attached file to directory configured as 'source root' at IDEA;
  2. Performed 'make module' action for the module in which source root *.otf file was put;

Result: 'VectoraLH-Roman.otf' file is copied to module output directory.

Tested with IDEA 9.0.2 Community Edition.


That simple huh.  I failed to check the compiler, as resources aren't "compiled."


Why on earth should there be a filter pattern by default??


I recognize this is an old thread, but I'm getting this exact same problem in IntelliJ community edition 9.0.2, but with a Wavefront .obj file.

Tried the solution suggested here and it's not working.

1. File is located in "assets/Models/Tank.obj", off of project root, added "assets" as a Source root in the project structure.
2. Added "?*.obj" to the end of the patterns list in Compiler under Project Settings.
3. Rebuild project, and it does not show up in the out directory.

If I rename the "Tank.obj" file to "" it copies over just fine.  Running 9.0.2, build # IC-95.66.  

Edit: Just updated to 9.0.3 and still having the same issue.

Any thoughts on this variation of the problem?


I'd recommend that you double check your resource pattern list to make sure you used a semi-colon and not a comma (I've made that error in the past), and that there is not an unintentional space in there somewhere. For example, this pattern:

  • ?*.properties;?*.xml;?*.gif;?*.png;?*.jpeg;?*.jpg;?*.html;?*.dtd;?*.tld;?*.ftl; ?*.obj

will not work because there is a space after the semicolon before the ?*.obj. This results in a sub-pattern of " ?*.obj" rather than "?*.obj".  The fact that everything works when you rename the file to a .properties file clearly indicates there is a problem/typo in your pattern somewhere.


Re-checked it to be sure there were no spaces, and it's still not working.  Here's the exact string in the pattern box (minus the quotes, of course-- including them to show lack of spaces):

  • "?*.properties;?*.xml;?*.gif;?*.png;?*.jpeg;?*.jpg;?*.html;?*.dtd;?*.tld;?*.ftl;?*.obj"

I also tried the following with no success:

  • "?*.obj;?*.properties;?*.xml;?*.gif;?*.png;?*.jpeg;?*.jpg;?*.html;?*.dtd;?*.tld;?*.ftl"

Please sign in to leave a comment.