Updated launch4j
This commit is contained in:
@@ -1 +0,0 @@
|
||||
/build
|
||||
Binary file not shown.
@@ -1,52 +1,52 @@
|
||||
<project name="SimpleApp" default="exe" basedir=".">
|
||||
<property name="src" location="src" />
|
||||
<property name="lib" location="lib" />
|
||||
<property name="build" location="build" />
|
||||
<property name="launch4j.dir" location="../.." />
|
||||
|
||||
<path id="dist.classpath">
|
||||
<pathelement path="${build}" />
|
||||
<fileset dir="${lib}">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<target name="init">
|
||||
<tstamp />
|
||||
<mkdir dir="${build}" />
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="compile the source">
|
||||
<javac srcdir="${src}" destdir="${build}" classpathref="dist.classpath" source="1.6" debug="on" includeantruntime="false" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="create the jar">
|
||||
<fileset dir="${lib}" id="lib.dist.fileset">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
<pathconvert pathsep=" " property="dist.classpath" refid="lib.dist.fileset">
|
||||
<map from="${lib}" to=".\lib" />
|
||||
</pathconvert>
|
||||
<!-- Put everything in ${build} into a jar file -->
|
||||
<jar jarfile="${ant.project.name}.jar">
|
||||
<fileset dir="${build}" includes="**/*" />
|
||||
<manifest>
|
||||
<!-- SET YOUR MAIN CLASS HERE -->
|
||||
<attribute name="Main-Class" value="net.sf.launch4j.example.SimpleApp" />
|
||||
<attribute name="Class-Path" value=". ${dist.classpath}" />
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="exe" depends="jar">
|
||||
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${launch4j.dir}/launch4j.jar
|
||||
:${launch4j.dir}/lib/xstream.jar" />
|
||||
<launch4j configFile="./l4j/SimpleApp.xml" />
|
||||
</target>
|
||||
|
||||
<target name="clean" description="clean up">
|
||||
<delete dir="${build}" />
|
||||
<delete file="${ant.project.name}.jar" />
|
||||
<delete file="${ant.project.name}.exe" />
|
||||
</target>
|
||||
</project>
|
||||
<project name="SimpleApp" default="exe" basedir=".">
|
||||
<property name="src" location="src" />
|
||||
<property name="lib" location="lib" />
|
||||
<property name="build" location="build" />
|
||||
<property name="launch4j.dir" location="../.." />
|
||||
|
||||
<path id="dist.classpath">
|
||||
<pathelement path="${build}" />
|
||||
<fileset dir="${lib}">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<target name="init">
|
||||
<tstamp />
|
||||
<mkdir dir="${build}" />
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init" description="compile the source">
|
||||
<javac srcdir="${src}" destdir="${build}" classpathref="dist.classpath" source="1.8" debug="on" includeantruntime="false" />
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile" description="create the jar">
|
||||
<fileset dir="${lib}" id="lib.dist.fileset">
|
||||
<include name="**/*.jar" />
|
||||
</fileset>
|
||||
<pathconvert pathsep=" " property="dist.classpath" refid="lib.dist.fileset">
|
||||
<map from="${lib}" to=".\lib" />
|
||||
</pathconvert>
|
||||
<!-- Put everything in ${build} into a jar file -->
|
||||
<jar jarfile="${ant.project.name}.jar">
|
||||
<fileset dir="${build}" includes="**/*" />
|
||||
<manifest>
|
||||
<!-- SET YOUR MAIN CLASS HERE -->
|
||||
<attribute name="Main-Class" value="net.sf.launch4j.example.SimpleApp" />
|
||||
<attribute name="Class-Path" value=". ${dist.classpath}" />
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="exe" depends="jar">
|
||||
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${launch4j.dir}/launch4j.jar
|
||||
:${launch4j.dir}/lib/xstream.jar" />
|
||||
<launch4j configFile="./l4j/SimpleApp.xml" />
|
||||
</target>
|
||||
|
||||
<target name="clean" description="clean up">
|
||||
<delete dir="${build}" />
|
||||
<delete file="${ant.project.name}.jar" />
|
||||
<delete file="${ant.project.name}.exe" />
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<launch4jConfig>
|
||||
<headerType>gui</headerType>
|
||||
<jar>SimpleApp.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<outfile>../SimpleApp.exe</outfile>
|
||||
<errTitle>SimpleApp</errTitle>
|
||||
<chdir>.</chdir>
|
||||
<icon>SimpleApp.ico</icon>
|
||||
<restartOnCrash>true</restartOnCrash>
|
||||
<jre>
|
||||
<minVersion>1.6.0</minVersion>
|
||||
</jre>
|
||||
<splash>
|
||||
<file>splash.bmp</file>
|
||||
<waitForWindow>true</waitForWindow>
|
||||
<timeout>60</timeout>
|
||||
<timeoutErr>true</timeoutErr>
|
||||
</splash>
|
||||
<launch4jConfig>
|
||||
<headerType>gui</headerType>
|
||||
<jar>SimpleApp.jar</jar>
|
||||
<dontWrapJar>true</dontWrapJar>
|
||||
<outfile>../SimpleApp.exe</outfile>
|
||||
<errTitle>SimpleApp</errTitle>
|
||||
<chdir>.</chdir>
|
||||
<icon>SimpleApp.ico</icon>
|
||||
<restartOnCrash>true</restartOnCrash>
|
||||
<jre>
|
||||
<path>%JAVA_HOME%;%PATH%</path>
|
||||
<minVersion>1.8.0</minVersion>
|
||||
</jre>
|
||||
<splash>
|
||||
<file>splash.bmp</file>
|
||||
<waitForWindow>true</waitForWindow>
|
||||
<timeout>60</timeout>
|
||||
<timeoutErr>true</timeoutErr>
|
||||
</splash>
|
||||
</launch4jConfig>
|
||||
@@ -1,195 +1,195 @@
|
||||
/*
|
||||
Launch4j (http://launch4j.sourceforge.net/)
|
||||
Cross-platform Java application wrapper for creating Windows native executables.
|
||||
|
||||
Copyright (c) 2004, 2015 Grzegorz Kowal
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.sf.launch4j.example;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
public class SimpleApp extends JFrame {
|
||||
public SimpleApp(String[] args) {
|
||||
super("Java Application");
|
||||
|
||||
if (args.length == 1 && "throw".equals(args[0])) {
|
||||
throw new IllegalStateException("Exception thrown from SimpleApp.");
|
||||
}
|
||||
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setBounds (screenSize.width / 4, screenSize.height / 4, screenSize.width / 2, screenSize.height / 2);
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.exit(0);
|
||||
}});
|
||||
|
||||
initializeMenu();
|
||||
initializeTextArea(args);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public static void setLAF() {
|
||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||
Toolkit.getDefaultToolkit().setDynamicLayout(true);
|
||||
System.setProperty("sun.awt.noerasebackground","true");
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to set LookAndFeel");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
setLAF();
|
||||
new SimpleApp(args);
|
||||
}
|
||||
|
||||
private final void initializeMenu() {
|
||||
JMenu menu = new JMenu("Exit with code");
|
||||
|
||||
menu.add(new JMenuItem(new AbstractAction("Exit with code 0") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
}));
|
||||
|
||||
menu.add(new JMenuItem(new AbstractAction("Exit with code 100 and restart the application") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(100);
|
||||
}
|
||||
}));
|
||||
|
||||
JMenuBar mb = new JMenuBar();
|
||||
mb.setOpaque(true);
|
||||
mb.add(menu);
|
||||
setJMenuBar(mb);
|
||||
}
|
||||
|
||||
private final void initializeTextArea(String[] args) {
|
||||
JTextArea textArea = new JTextArea();
|
||||
textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
|
||||
textArea.setEditable(false);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setViewportView(textArea);
|
||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
getContentPane().add(scrollPane);
|
||||
|
||||
textArea.setText(getMainProperties(args));
|
||||
textArea.append(getAllProperties());
|
||||
textArea.append(getEnvironmentVariables());
|
||||
}
|
||||
|
||||
private final String getMainProperties(String[] args) {
|
||||
StringBuffer sb = new StringBuffer("Java version: ");
|
||||
sb.append(System.getProperty("java.version"));
|
||||
sb.append("\nJava home: ");
|
||||
sb.append(System.getProperty("java.home"));
|
||||
sb.append("\nCurrent dir: ");
|
||||
sb.append(System.getProperty("user.dir"));
|
||||
sb.append("\nCommand line args: {");
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (i > 0)
|
||||
{
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(args[i]);
|
||||
}
|
||||
|
||||
sb.append("}\n");
|
||||
|
||||
final int mb = 1024 * 1024;
|
||||
sb.append("Free memory (MB): ");
|
||||
sb.append(Runtime.getRuntime().freeMemory() / mb);
|
||||
sb.append("\nTotal memory (MB): ");
|
||||
sb.append(Runtime.getRuntime().totalMemory() / mb);
|
||||
sb.append("\nMax memory (MB): ");
|
||||
sb.append(Runtime.getRuntime().maxMemory() / mb);
|
||||
sb.append("\n");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private final String getAllProperties() {
|
||||
StringBuffer sb = new StringBuffer("\n========== All properties ==========\n");
|
||||
|
||||
List<String> keys = new ArrayList<String>();
|
||||
keys.addAll(System.getProperties().stringPropertyNames());
|
||||
Collections.sort(keys);
|
||||
|
||||
for (String key : keys) {
|
||||
sb.append(key);
|
||||
sb.append(": ");
|
||||
sb.append(System.getProperty(key));
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private final String getEnvironmentVariables() {
|
||||
StringBuffer sb = new StringBuffer("\n========== Environment variables ==========\n");
|
||||
|
||||
List<String> keys = new ArrayList<String>();
|
||||
keys.addAll(System.getenv().keySet());
|
||||
Collections.sort(keys);
|
||||
|
||||
for (String key : keys) {
|
||||
sb.append(key);
|
||||
sb.append(": ");
|
||||
sb.append(System.getenv(key));
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
/*
|
||||
Launch4j (http://launch4j.sourceforge.net/)
|
||||
Cross-platform Java application wrapper for creating Windows native executables.
|
||||
|
||||
Copyright (c) 2004, 2015 Grzegorz Kowal
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.sf.launch4j.example;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
public class SimpleApp extends JFrame {
|
||||
public SimpleApp(String[] args) {
|
||||
super("Java Application");
|
||||
|
||||
if (args.length == 1 && "throw".equals(args[0])) {
|
||||
throw new IllegalStateException("Exception thrown from SimpleApp.");
|
||||
}
|
||||
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setBounds (screenSize.width / 4, screenSize.height / 4, screenSize.width / 2, screenSize.height / 2);
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.exit(0);
|
||||
}});
|
||||
|
||||
initializeMenu();
|
||||
initializeTextArea(args);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public static void setLAF() {
|
||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||
Toolkit.getDefaultToolkit().setDynamicLayout(true);
|
||||
System.setProperty("sun.awt.noerasebackground","true");
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to set LookAndFeel");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
setLAF();
|
||||
new SimpleApp(args);
|
||||
}
|
||||
|
||||
private final void initializeMenu() {
|
||||
JMenu menu = new JMenu("Exit with code");
|
||||
|
||||
menu.add(new JMenuItem(new AbstractAction("Exit with code 0") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
}));
|
||||
|
||||
menu.add(new JMenuItem(new AbstractAction("Exit with code 100 and restart the application") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(100);
|
||||
}
|
||||
}));
|
||||
|
||||
JMenuBar mb = new JMenuBar();
|
||||
mb.setOpaque(true);
|
||||
mb.add(menu);
|
||||
setJMenuBar(mb);
|
||||
}
|
||||
|
||||
private final void initializeTextArea(String[] args) {
|
||||
JTextArea textArea = new JTextArea();
|
||||
textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
|
||||
textArea.setEditable(false);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setViewportView(textArea);
|
||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
getContentPane().add(scrollPane);
|
||||
|
||||
textArea.setText(getMainProperties(args));
|
||||
textArea.append(getAllProperties());
|
||||
textArea.append(getEnvironmentVariables());
|
||||
}
|
||||
|
||||
private final String getMainProperties(String[] args) {
|
||||
StringBuffer sb = new StringBuffer("Java version: ");
|
||||
sb.append(System.getProperty("java.version"));
|
||||
sb.append("\nJava home: ");
|
||||
sb.append(System.getProperty("java.home"));
|
||||
sb.append("\nCurrent dir: ");
|
||||
sb.append(System.getProperty("user.dir"));
|
||||
sb.append("\nCommand line args: {");
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (i > 0)
|
||||
{
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(args[i]);
|
||||
}
|
||||
|
||||
sb.append("}\n");
|
||||
|
||||
final int mb = 1024 * 1024;
|
||||
sb.append("Free memory (MB): ");
|
||||
sb.append(Runtime.getRuntime().freeMemory() / mb);
|
||||
sb.append("\nTotal memory (MB): ");
|
||||
sb.append(Runtime.getRuntime().totalMemory() / mb);
|
||||
sb.append("\nMax memory (MB): ");
|
||||
sb.append(Runtime.getRuntime().maxMemory() / mb);
|
||||
sb.append("\n");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private final String getAllProperties() {
|
||||
StringBuffer sb = new StringBuffer("\n========== All properties ==========\n");
|
||||
|
||||
List<String> keys = new ArrayList<String>();
|
||||
keys.addAll(System.getProperties().stringPropertyNames());
|
||||
Collections.sort(keys);
|
||||
|
||||
for (String key : keys) {
|
||||
sb.append(key);
|
||||
sb.append(": ");
|
||||
sb.append(System.getProperty(key));
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private final String getEnvironmentVariables() {
|
||||
StringBuffer sb = new StringBuffer("\n========== Environment variables ==========\n");
|
||||
|
||||
List<String> keys = new ArrayList<String>();
|
||||
keys.addAll(System.getenv().keySet());
|
||||
Collections.sort(keys);
|
||||
|
||||
for (String key : keys) {
|
||||
sb.append(key);
|
||||
sb.append(": ");
|
||||
sb.append(System.getenv(key));
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user