How To Add Splash Screen Using Maven

4 years ago by in How To, Maven, Swing Tagged: , , ,

We can include a splash screen through Maven as shown in the following pom fragment.

<build>
  ...
  <plugins>
    ...
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <configuration>
        <archive>
          <manifestEntries>
            <SplashScreen-Image>splash-image.png</SplashScreen-Image>
          </manifestEntries>
        </archive>
      </configuration>
    </plugin>
    ...
  </plugins>
  ...
</build>

The path provided must be to an image within the generated JAR file. Therefore this image must be in a resource folder.

Following is a complete example including the main class path and assembles all dependencies into one JAR file.

<build>
  ...
  <plugins>
    ...
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <mainClass>com.javacreed.maven.examples.Main</mainClass>
          </manifest>
          <manifestEntries>
            <SplashScreen-Image>splash-image.png</SplashScreen-Image>
          </manifestEntries>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
      <executions>
        <execution>
          <id>make-my-jar-with-dependencies</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  </plugins>
  ...
</build>
Albert Attard

Albert Attard is a Java passionate and technical lead at a research group. You can find him on . Over the past years Albert worked on various Java projects including traditional server/client applications, modular applications, large data handling applications and concurrent data manipulation applications to name a few. He has a BSc degree from the University of London (Homepage) and an MSc Information Security with the same university. His MSc thesis (Book) received the 2012 SearchSecurity.co.UK award (Website).

Leave a Comment