Results 1 to 1 of 1
- 05-17-2013, 05:18 PM #1
Member
- Join Date
- May 2013
- Posts
- 1
- Rep Power
- 0
executeable jar file, with external resources
hi, I honestly dont know if there is a solution to my problem at all, or if I am overseeing an essential error
enviroment is a fat client swing java programm with hibernate connected to a SQLite databse.
so far, all of my resources are packed into the jar (including the the database file, all images and hibernate config files and so on)
of course i dont want to deploy my database/images/config files everytime I make changes to my software, i just want to exchange the jar and keep the rest
so is ther any maven script/archetype that buils me a jar with the the resources next to jar in lets say a "conf" folder, but so that the jar is still able to access the files in the folder ?
i managed to copy the resource via the assembly plugin into a folder, but then my jar cant access the information from the files anymore
that in advance here is my current pom.xml
Java Code:<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.srccodes.example.hibernate</groupId> <artifactId>Blechkultur</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>Blechkultur</name> <url>http://maven.apache.org</url> <dependencies> <!-- hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.1.4.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>4.1.4.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-search</artifactId> <version>4.1.1.Final</version> </dependency> <dependency> <groupId>com.oracle</groupId> <artifactId>javafx</artifactId> <version>2.2.3</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/jfxrt.jar</systemPath> </dependency> <!-- SQLite JDBC library --> <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.7.2</version> </dependency> <!-- junit test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <resources> <resource> <directory>src/main/resources</directory> <excludes> <exclude>*.*</exclude> </excludes> <filtering>false</filtering> </resource> </resources> <plugins> <!-- <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>2.2</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>de.blechkultur.Application</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>com.zenjava</groupId> <artifactId>javafx-maven-plugin</artifactId> <version>1.3</version> <configuration> <mainClass>WelcomeLogin</mainClass> </configuration> </plugin> --> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>2.3.1</version> <configuration> <archive> <!-- Make an executable jar, adjust classpath entries --> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>./lib/</classpathPrefix> <mainClass>de.blechkultur.Application</mainClass> </manifest> <!--Resources will be placed under --> <manifestEntries> <Class-Path>conf</Class-Path> --> </manifestEntries> </archive> <!--exclude files from the archive --> <!-- <excludes> <exclude>**/src/main/resources/resources/*</exclude> </excludes> --> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> <configuration> <descriptors> <descriptor>${basedir}/distribution-zip.xml</descriptor> </descriptors> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
Java Code:<?xml version="1.0" encoding="UTF-8"?> <assembly> <id>dist</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>true</includeBaseDirectory> <dependencySets> <dependencySet> <!--Include runtime dependencies --> <outputDirectory>lib</outputDirectory> <scope>runtime</scope> </dependencySet> </dependencySets> <fileSets> <fileSet> <!--Get the generated application jar --> <directory>${project.build.directory}</directory> <outputDirectory>/</outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> <fileSet> <!--Get application resources --> <directory>src/main/resources</directory> <outputDirectory>conf</outputDirectory> </fileSet> <fileSet> <!--Get misc user files --> <directory>${project.basedir}</directory> <outputDirectory>/</outputDirectory> <includes> <include>README*</include> <include>LICENSE*</include> <include>NOTICE*</include> </includes> </fileSet> </fileSets> </assembly>
Similar Threads
-
Open external file with external program
By Wietse de Vries in forum New To JavaReplies: 1Last Post: 12-31-2011, 05:52 PM -
adding resources to jar file
By Mekonom in forum New To JavaReplies: 3Last Post: 02-22-2010, 12:34 AM -
Create an executeable file for java
By cowboy in forum New To JavaReplies: 14Last Post: 11-04-2009, 12:30 AM -
External runtime resources access in Eclipse
By batkins61 in forum EclipseReplies: 0Last Post: 01-07-2009, 06:42 PM
Bookmarks