A Maven configuration for a Java Webstart (JNLP) application

Context

  • codehaus Maven JNLP plugin version 1.0-beta-3
  • Maven shade plugin version 1.6

The Plugin configuration to generate auto-executable Jar

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.6</version>
    <executions>
    <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>com.ichir.projects.MainClass</mainClass>
                </transformer>
            </transformers>
        </configuration>
    </execution>
    </executions>
</plugin>

The Plugin configuration for JNLP (via a profile)

<profiles>
    <profile>
        <id>jnlp</id>
	<build>
	    <plugins>
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>webstart-maven-plugin</artifactId>
			<version>1.0-beta-3</version>
			<executions>
				<execution>
					<phase>package</phase>
					<goals>
						<goal>jnlp</goal>
					</goals>
				</execution>
			</executions>
			<configuration>
				<codebase>http://localhost/jnlp/</codebase>
				<jnlp>
	    			    <mainClass>com.ichir.projects.MainClass</mainClass>
				</jnlp>
				<pack200>true</pack200>
				<sign>
				    <keystore>${project.basedir}/src/main/jnlp/ichir.jks</keystore>
				    <keypass>mahieddine.ichir</keypass>
				    <storepass>mahieddine.ichir</storepass>
				    <alias>ichir</alias>
				    <verify>false</verify>
				</sign>
				<verbose>true</verbose>
			</configuration>
		</plugin>
	    </plugins>
        </build>
    </profile>
</profiles>

You have to change these configurations according to your application, mainly the codebase, the mainClass (in both plugins configurations) and the keystore parameters to use your own

In order to generate the JNLP repository, run

    mvn clean install -Pjnlp

A jnlp folder is created in the target folder containing all the needed resources and the “launch.jnlp” autostart file.

It is important to put the “jnlp” velocity template.vm file in src/main/jnlp along with the keystore file.

The pom file contains other jnlp configuration properties that you should set accordingly

  • project.name
  • project.description
  • project.url
  • project.organization.name
  • project.organization.url

Downloads

References

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s