Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a standalone application with Maven

How do I create a desktop (standalone/Swing) application with Maven?

I'm using Eclipse 3.6.

like image 838
fresh_dev Avatar asked Nov 12 '11 18:11

fresh_dev


People also ask

Can Java create standalone application?

The following example is a stand-alone Java™ API program. This program can be compiled and can be run as a stand-alone program from command prompt or from within an IDE like Rational® Software Architect.

Can we create standalone application in spring boot?

Spring Boot makes it easy to create stand-alone, production-grade Spring-based applications. Spring Boot provides various starters for building standalone or more traditional war deployments.

How do I create a Maven project locally?

To build a Maven project via the command line, you use the mvn command from the command line. The command must be executed in the directory which contains the relevant pom file. You pass the build life cycle, phase or goal as parameter to this command.

Can we create Maven project without installing Maven?

There's no easy way to simulate what Maven does without Maven. If you absolutely can't install maven on the server, build your artifacts on another server (or locally) and move them onto the server via scp.


1 Answers

  1. Create a Maven project as follows:

    mvn archetype:generate -DgroupId=com.yourapp.app 
                           -DartifactId=swingapp  
                           -Dversion=1.0-SNAPSHOT
    
  2. Add the following entry to your pom file:

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.yourapp.app.YourMainClass</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
    </build>
    
  3. Import the project into Eclipse as a Maven project, then run as Java application.

like image 85
Mahmoud Saleh Avatar answered Sep 18 '22 07:09

Mahmoud Saleh