JDeveloper: Controlling which Resources (Files) are Copied into the Projects Output Directory

Some projects need resource files available in the output directory together with the class files. This is a fairly common task, however it’s not obvious how to archive this for all types of resources.

IF you never have had the problem, that a resource file you used in your project did not turn up in the output directory, you probably have used only default resource files like ‘properties’, ‘wsdl’ or ‘XML’ files. These files are copied into the output path by default.

Lets assume you have a resource e.g. a tiff file (*.tiff) or a TrueType font (*.ttf) which you need in your project and finally in the jar or adflib you build from the project. Lets add a dummy file ‘MyFont.ttf’ in a new folder named ‘res’ under the base path of the model projcect ‘de.hahn.blog.controlresourcefiles’. After this the model application looks like

Model Project after adding Font File

Model Project after adding Font File

No problem with this. Now if you compile the model project and check the output path Q:\QT\BlogControlResourceFiles\CRFModel\classes in this sample, you’ll notice that the folder ‘res’ and file ‘MyFont.ttf’ is not in the directory tree

Output Path after Compile

Output Path after Compile

If you check the path configuration of the project, it shows that the folder and the file should have been there

Project Path

Project Path

Well, the problem is an other configuration for the project. If you check the compiler node in the project properties you see that there is a filter which defines which file types are copied into the output path of the project

Project Compiler  Settings

Project Compiler Settings

As you see there is no entry for type ‘.ttf’ which means that files with this suffix are not copied into the output directory. The solution to the problem is to simply add the suffix ‘.ttf’ to the filter and compile the project again. After this the file ‘MyFont.ttf’ can be found in the projects output directory.

If you have any resource of a type (file suffix) you want to automatically copied into the projects output directory, you simple add the missing suffix to the filter.

9 thoughts on “JDeveloper: Controlling which Resources (Files) are Copied into the Projects Output Directory

    • I don’t see any connection to this post. If you need help on reading tiff files you should post this in the OTN JDev & ADF forum.

    • Brian, this isn’t a question related to the post.
      You should ask this on the OTN forum.
      There you should provide more info on the use case and your Jdev version. In general fonts are specified using skins.

      • Here is a line in your post :
        “Lets assume you have a resource e.g. a tiff file (*.tiff) or a TrueType font (*.ttf) which you need in your project and finally in the jar or adflib you build from the project. ”
        Sure this is related, if one specifies a font that is not in another environment then you will have to package it up so JDev can find/use said font.
        My question just asks the step prior to this step. How did you specify a non standard font in Jdev. So when one uses said Jar file it will use the font you want not the default.

      • Exactly this is the point why it’s not related. The post is about packaging resources into a jar, war or ear file, not about what to do with them later on. So all I can tell is that I would look into skins.

  1. Well then you are only giving a partial solution to a problem for which two people have asked about. You are quick to defer, and your focus seem limited. But as you said I will follow up somewhere else on skins.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.