maven生成exe文件

1、编写源代码

package org.pzy.exe_test;

import javax.swing.JColorChooser;
import javax.swing.JDialog;

/**
 * Hello world!
 * 
 */
public class Main extends JDialog {
	private static final long serialVersionUID = 1L;
	private final JColorChooser cc;

	public Main() {
		setSize(800, 600);
		setTitle("hasCode.com launch4j Maven Tutorial");
		cc = new JColorChooser();
		add(cc);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setVisible(true);
	}

	public static void main(final String[] args) {
		new Main();
	}

}

2、配置pom

<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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>org.pzy</groupId>
	<artifactId>exe-test</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>exe-test</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<shadedArtifactAttached>true</shadedArtifactAttached>
					<shadedClassifierName>shaded</shadedClassifierName>
					<transformers>
						<transformer
							implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
							<mainClass>org.pzy.exe_test.Main</mainClass>
						</transformer>
					</transformers>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.akathist.maven.plugins.launch4j</groupId>
				<artifactId>launch4j-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>l4j-clui</id>
						<phase>package</phase>
						<goals>
							<goal>launch4j</goal>
						</goals>
						<configuration>
							<headerType>gui</headerType>
							<jar>${project.build.directory}/${artifactId}-${version}-shaded.jar</jar>
							<outfile>${project.build.directory}/hasCode.exe</outfile>
							<downloadUrl>http://java.com/download</downloadUrl>
							<classPath>
								<mainClass>org.pzy.exe_test.Main</mainClass>
								<preCp>anything</preCp>
							</classPath>
							<icon>src/resources/0.ico</icon>
							<jre>
								<minVersion>1.7.0</minVersion>
								<jdkPreference>preferJre</jdkPreference>
							</jre>
							<versionInfo>
								<fileVersion>1.0.0.0</fileVersion>
								<txtFileVersion>${project.version}</txtFileVersion>
								<fileDescription>${project.name}</fileDescription>
								<copyright>2012 hasCode.com</copyright>
								<productVersion>1.0.0.0</productVersion>
								<txtProductVersion>1.0.0.0</txtProductVersion>
								<productName>${project.name}</productName>
								<companyName>hasCode.com</companyName>
								<internalName>hasCode</internalName>
								<originalFilename>hasCode.exe</originalFilename>
							</versionInfo>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

3、执行maven命令

package



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值