how can I reference a local file and include it with my maven assembly when creating an executable jar?

H.Kim :

I'm trying to assemble my executable jar, but I don't know how to include a local index.aff and index.dic file with the project when I'm building it. When I execute the jar file, it simply doesn't know where the file is and throws a file-not-found exception. It works fine, during compile time, but when executing my jar file it doesn't seem to be included. Not entirely sure how to fix this. How do I include the local files with my jar without having to bring the external index.* files?

This is my maven command (it builds successfully but without the index files):

$ mvn assembly:assembly -Dfile=src/lib/language-all-4.4.jar -DpomFile=pom.xml -Durl=file:///src/lib/en-US/* -X

public HunSpellChecker(){
    hunspell = Hunspell.getInstance();
    dir = "src/lib/en-US";   //jar doesn't know how to reference this.
    try{
        en = hunspell.getDictionary(dir + "/index" );
    } catch (Exception e){
        System.out.println(e.getMessage());
    }
}
Paragoumba :

To include files that aren't java code in your jar with Maven you just have to modify the build node in your pom.xml:

    <resources>
        <resource>
            <directory>path/to/the/resources'/directory</directory>
            <includes>
                <include>specific/file</include>
            </includes>
            <excludes>
                <exclude>specific/file</exclude>
            </excludes>
            <targetPath>path/in/jar/where/to/put/resources</targetPath>
        </resource>
    </resources>

By default, all the content of <directory> will be included.
<directory>, <includes>, <excludes> and <targetPath> are all optionals, just use the ones you need. You can find more exemples here.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Maven: How to include my external jar into build executable jar

From Java

How can I include my icon when I export my project to a jar file

From Dev

How can I make a .jar file executable?

From Java

How can I creating executable JAR with SWT that runs on all platforms?

From Java

How can I create an executable jar without dependencies using Maven?

From Java

How can I create an executable JAR with dependencies using Maven?

From Dev

How can I create an executable/runnable JAR with dependencies using Maven?

From Java

gradle executable jar can't include local jar dependencies

From Java

How can I create single executable jar in my gradle project

From Java

How to include libraries/dependencies when creating a jar file?

From Java

How can I run code locally with dependencies and exclude them when creating a Jar with Maven

From Java

How can I include test classes into Maven jar and execute them?

From Java

How to include local jar files in Maven project

From Dev

How to make an executable .jar file using maven with local external libraries inside through pom without IDE?

From Java

How can I include lib into my embedded OpenLiberty jar?

From Java

How can I include external jar on my Netbeans project

From Dev

Jersey fails when creating uber jar with maven-assembly-plugin

From Dev

How can I open a text file with my executable?

From Dev

How can I check my static library attached to the executable file?

From Java

How to include package.jar with maven-assembly-plugin

From Java

How to include maven dependencies in a jar file?

From Dev

How can I use my local time as the only reference of `ntpd`?

From Dev

How do I create an executable jar file including dependencies where the main class is in Test, using Maven

From Dev

How do I correctly include a file directory into my project such that they can be packaged and referenced correctly in code when deployed?

From Dev

How to include specific .jar files with pyinstaller in executable file?

From Dev

How can I use Open Liberty dev mode with my Maven WAR project and include JavaScript and CSS files from outside my project (eg from my local machine)?

From Dev

How can I create a runnable JAR file with Maven + JavaFX

From Dev

Creating a executable far jar with dependancies (gradle or maven)

From Dev

How can I reference a local JSON file in perl on a linux box?

Related Related

  1. 1

    Maven: How to include my external jar into build executable jar

  2. 2

    How can I include my icon when I export my project to a jar file

  3. 3

    How can I make a .jar file executable?

  4. 4

    How can I creating executable JAR with SWT that runs on all platforms?

  5. 5

    How can I create an executable jar without dependencies using Maven?

  6. 6

    How can I create an executable JAR with dependencies using Maven?

  7. 7

    How can I create an executable/runnable JAR with dependencies using Maven?

  8. 8

    gradle executable jar can't include local jar dependencies

  9. 9

    How can I create single executable jar in my gradle project

  10. 10

    How to include libraries/dependencies when creating a jar file?

  11. 11

    How can I run code locally with dependencies and exclude them when creating a Jar with Maven

  12. 12

    How can I include test classes into Maven jar and execute them?

  13. 13

    How to include local jar files in Maven project

  14. 14

    How to make an executable .jar file using maven with local external libraries inside through pom without IDE?

  15. 15

    How can I include lib into my embedded OpenLiberty jar?

  16. 16

    How can I include external jar on my Netbeans project

  17. 17

    Jersey fails when creating uber jar with maven-assembly-plugin

  18. 18

    How can I open a text file with my executable?

  19. 19

    How can I check my static library attached to the executable file?

  20. 20

    How to include package.jar with maven-assembly-plugin

  21. 21

    How to include maven dependencies in a jar file?

  22. 22

    How can I use my local time as the only reference of `ntpd`?

  23. 23

    How do I create an executable jar file including dependencies where the main class is in Test, using Maven

  24. 24

    How do I correctly include a file directory into my project such that they can be packaged and referenced correctly in code when deployed?

  25. 25

    How to include specific .jar files with pyinstaller in executable file?

  26. 26

    How can I use Open Liberty dev mode with my Maven WAR project and include JavaScript and CSS files from outside my project (eg from my local machine)?

  27. 27

    How can I create a runnable JAR file with Maven + JavaFX

  28. 28

    Creating a executable far jar with dependancies (gradle or maven)

  29. 29

    How can I reference a local JSON file in perl on a linux box?

HotTag

Archive