Universal Robots Forum

Find resources after .jar deploy

I’m trying to get a custom resource I placed on my deamon example. I’m following the UR example where:

  1. I copy my desired resource in the same way the deamon executable is copied in the pom:

    cp
    daemon/myres src/main/resources/com/ur/urcap/examples/mydaemon/impl/daemon/
    .

  2. Then i call:

    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource(“com/ur/urcap/examples/mydaemon/impl/daemon/myres”).getFile());

So, inside the final .jar is present myres file as the HelloWorld provided in the example. But after several attempts and tests i cannot acquire my resource inside InstallationNodeContribution class. I also tried putting the abs path (src/main/…), the GUI folder path and others. I’m missing some step? Where the .jar is unpacked when the URSim or the real Controller run?

Easiest way to check where your file your file is located inside the jar is lanching the command “jar -tf target/(urcapName).jar” -> the .jar is the same as the .urcap just the extension change.
(If the file is not anywhere, you should try to add a <include> in your pom.xml or assembly.xml the correct way)

Hope this help.

Or, set the < userDefaultExclude > to false in assembly.xml, and let your daemon in your resources:

    <fileSet>
        <directory>src</directory>
        <useDefaultExcludes>false</useDefaultExcludes>
    </fileSet>

Then after a mvn install:

Thank you for all the advice @mdi. I’m working on it.

Regards.
Matteo Timossi @recognitionrobotics