Cannot reference internal launcher resource

Help
mserioli
2013-03-28
2013-06-12
  • mserioli

    mserioli - 2013-03-28

    I'm using launch4j with maven in order to create an .exe of my application.

    I've put a .docx file inside /src/main/resources/reportTemplate/file.docx

    I load the file inside my app in this way:

    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(
        new FileInputStream(
            getClass().getResource("/reportTemplate/file.docx").getFile()));
    

    When I launch the application inside Netbeans everything works.. but when I launch .exe from a windows machine (32 or 64 bit) I get an exception:

    file:\M:\pathtojar\app-gui.exe!\reportTemplate\file.docx -> Specified path is not valid!

    I've looked inside .exe and the file \reportTemplate\file.docx is there! Maybe because i'm developing on linux and testing .exe on windows?

    Here is my build section of pom:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.7.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                    <shadedClassifierName>shaded</shadedClassifierName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.akathist.maven.plugins.launch4j</groupId>
                <artifactId>launch4j-maven-plugin</artifactId>
                <version>1.5.1</version>
                <executions>
                    <execution>
                        <id>l4j-clui</id>
                        <phase>package</phase>
                        <goals>
                            <goal>launch4j</goal>
                        </goals>
                        <configuration>
                            <headerType>gui</headerType>
                            <outfile>target/app-gui.exe</outfile>
                            <jar>target/${project.artifactId}-${project.version}-shaded.jar</jar>
                            <errTitle>App Err</errTitle>
                            <classPath>
                                <mainClass>ui.Main</mainClass>
                            </classPath>
                            <jre>
                                <minVersion>1.6.0</minVersion>
                                <initialHeapSize>128</initialHeapSize>
                                <maxHeapSize>1024</maxHeapSize>
                            </jre>
                            <versionInfo>
                                <fileVersion>1.0.0.0</fileVersion>
                                <txtFileVersion>1.0.0.0</txtFileVersion>
                                <fileDescription>Desc</fileDescription>
                                <copyright>C</copyright>
                                <productVersion>1.0.0.0</productVersion>
                                <txtProductVersion>1.0.0.0</txtProductVersion>
                                <productName>Product</productName>
                                <internalName>Product</internalName>
                                <originalFilename>App.exe</originalFilename>
                            </versionInfo>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    Thank you for any response! Marco

     
  • mserioli

    mserioli - 2013-03-28

    Solved by putting:

    getClass().getResourceAsStream.("/reportTemplate/file.docx")
    

    Thank you

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks