1

I'm using Maven. When I launch my project from Eclipse, resources are exported at the root directory. But when I export it to an executable jar-file resources are located in /resources/

How can I change the path where resources are exported when i launch the project from Eclipse to match the path in executable jar-file ?

TheZopo
  • 304
  • 2
  • 12

2 Answers2

1

Use like this within <build></build> tag :

<resources>
        <resource>
            <targetPath>/resources</targetPath>
            <directory>${basedir}/src/main/resources</directory>
        </resource>
</resources>

You should keep under src/main/resources. Thats the standard.

TheZopo
  • 304
  • 2
  • 12
Ankur Srivastava
  • 855
  • 9
  • 10
  • This is a workaround. This will tells Eclipse to copy your resources in project/target/resources. You will then need to adjust your code to prefix your resource names with "/resources". This, just to be able to use the export as runnable jar menu option instead of using maven to build the jar. – cquezel Apr 02 '22 at 20:06
1

Assuming you have a working maven POM, (you haven't posted the <build> section), the error is exporting as a executable jar from eclipse.

You should use maven to do the packaging, you have 2 possible solution:

  1. maven-shade-plugin
  2. maven-assembly-plugin
minus
  • 2,646
  • 15
  • 18