Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a swing application using maven?

Tags:

I was trying to start new swing application using maven, so I started searching on maven documentation but (frustratingly) found no clue. So I'm asking:

  • what is the archetype used?
  • what are the dependencies?
  • how to build swing app in maven [is there is plugin to do so]?
like image 991
Mustafa Abuelfadl Avatar asked Feb 03 '10 11:02

Mustafa Abuelfadl


People also ask

How do you create a swing project in Java?

Step 1: Create a new Java project by selecting " java project " from the Select a wizard and click on Next button. Step 2: Give a project name click finish. Step 3: Create a new package in the src folder.

What is groupId and artifactId in Maven project example?

Maven uses a set of identifiers, also called coordinates, to uniquely identify a project and specify how the project artifact should be packaged: groupId – a unique base name of the company or group that created the project. artifactId – a unique name of the project. version – a version of the project.


2 Answers

  • what is the archetype used?

A swing application is a standard JAR so just use the standard archetype:

mvn archetype:generate -DgroupId=com.mycompany.app \
                       -DartifactId=myswingapp     \
                       -Dversion=1.0-SNAPSHOT
  • what are the dependencies?

If you plan to use the standard Swing API only, there aren't no extra dependencies to declare. But if you want to use things like JGoodies, MiGLayout, SwingX, Flamingo, SwingFX etc then you'll have to add the appropriate artifacts and repositories. But there is no universal answer to your question.

  • how to build swing app in maven [is there is plugin to do so ]?

A Swing app is not really particular. I would maybe just consider using Java Web Start (and the Maven Webstart plugin) or maybe a cross platform installer like IzPack (and the Maven IzPack Plugin). But you have time for that, you need an application before :)

like image 79
Pascal Thivent Avatar answered Sep 25 '22 02:09

Pascal Thivent


Basically, if you are only using Swing (I mean if you do not want additional features such as SwingX for example), then you will not need to add specific information in your pom.xml file, as everything needed for Swing development is already embedded in the JDK.

Concerning the build process, there is also nothing specific additions here. However, you may need be interesed in:

  • Creating an executable JAR.
  • Making a big JAR, that also contains all the dependencies.
like image 32
Romain Linsolas Avatar answered Sep 23 '22 02:09

Romain Linsolas