Note that there are some explanatory texts on larger screens.

plurals
  1. POMaven pom looking for resources outside of jar
    text
    copied!<p>I'm having trouble creating an executable jar with all dependancies and resources packaged in it. So far I have everything inside the jar, but it is looking for the resources OUTside the jar.</p> <p>Here is the structure of my project:</p> <pre><code>MyProject ----images ----resources ----src ----... </code></pre> <p>I'm able to Create the Executable Jar with dependancies packaged in, and the resources are packaged as well, however it is still looking for the resources in the "resources" folder and not IN the JAR.</p> <p>The jar looks like this:</p> <pre><code>MyProject.jar ----images ----resources ----... </code></pre> <p>When I try run it, I get this error:</p> <pre><code>java.io.FileNotFoundException: .../MyProject/target/resources/default-style.xml (No such file or directory) </code></pre> <p>So my problem is this: <strong>my dependancies and resources are packaged in the jar like I want, but upon execution it's looking for "resources/" in the "target/" folder and NOT in the JAR.</strong></p> <p>Here's my pom:</p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;!-- MyProject INFO --&gt; &lt;groupId&gt;Main&lt;/groupId&gt; &lt;artifactId&gt;MyProject&lt;/artifactId&gt; &lt;version&gt;0.0.1-beta&lt;/version&gt; &lt;name&gt;MyProject&lt;/name&gt; &lt;packaging&gt;jar&lt;/packaging&gt; &lt;!-- DEPENDANCIES --&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;custom&lt;/groupId&gt; &lt;artifactId&gt;custom&lt;/artifactId&gt; &lt;version&gt;1.0.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;jgraphx&lt;/groupId&gt; &lt;artifactId&gt;jgraphx&lt;/artifactId&gt; &lt;version&gt;1.0.0&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt; &lt;!-- RESOURCES --&gt; &lt;resources&gt; &lt;resource&gt; &lt;directory&gt;src&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;/resource&gt; &lt;resource&gt; &lt;directory&gt;${basedir}/images&lt;/directory&gt; &lt;filtering&gt;false&lt;/filtering&gt; &lt;targetPath&gt;images&lt;/targetPath&gt; &lt;/resource&gt; &lt;resource&gt; &lt;directory&gt;${basedir}/resources&lt;/directory&gt; &lt;filtering&gt;false&lt;/filtering&gt; &lt;targetPath&gt;resources&lt;/targetPath&gt; &lt;/resource&gt; &lt;/resources&gt; &lt;testResources&gt; &lt;testResource&gt; &lt;directory&gt;src&lt;/directory&gt; &lt;/testResource&gt; &lt;/testResources&gt; &lt;plugins&gt; &lt;!-- For Java 6, you need to configure the maven-compiler-plugin. Add this to your pom.xml: --&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;!-- CREATE EXECUTABLE JAR WITH DEPENDANCIES --&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;archive&gt; &lt;manifest&gt; &lt;mainClass&gt;Main.Main&lt;/mainClass&gt; &lt;/manifest&gt; &lt;/archive&gt; &lt;descriptorRefs&gt; &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt; &lt;/descriptorRefs&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;make-assembly&lt;/id&gt; &lt;!-- this is used for inheritance merges --&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;!-- bind to the packaging phase --&gt; &lt;goals&gt; &lt;goal&gt;single&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>EDIT: Looks like it might be my code instead. I'll take a look, thanks! (My company's proxy blocks most of stackoverflow so I can't reply to comments >.&lt; That's why I'm writing it here. Thanks Jigar Joshi and Aurand!)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload