propagate from branch 'i2p.i2p.zzz.test' (head 0914f799641c6ec04dbe40f325f8368403167885)

to branch 'i2p.i2p' (head f3d096929c21753a2117f93d7550b751b021c2a7)
This commit is contained in:
zzz
2010-02-15 16:17:40 +00:00
183 changed files with 13772 additions and 8500 deletions

View File

@ -80,9 +80,10 @@ Public domain except as listed below:
Installer:
Launch4j 2.0.RC3:
Copyright (C) 2005 Grzegorz Kowal
See licenses/LICENSE-GPLv2.txt
Launch4j 3.0.1:
Copyright (c) 2004, 2008 Grzegorz Kowal
See licenses/LICENSE-Launch4j.txt (in binary packages)
See installer/lib/launch4j/LICENSE.txt (in source packages)
The following projects are used by Launch4j...
MinGW binutils (http://www.mingw.org/)

View File

@ -50,7 +50,7 @@ public class DoCMDS implements Runnable {
// FIX ME
// I need a better way to do versioning, but this will do for now.
public static final String BMAJ = "00", BMIN = "00", BREV = "0A", BEXT = "";
public static final String BMAJ = "00", BMIN = "00", BREV = "0B", BEXT = "";
public static final String BOBversion = BMAJ + "." + BMIN + "." + BREV + BEXT;
private Socket server;
private Properties props;

View File

@ -662,10 +662,10 @@ public class I2PSnarkServlet extends HttpServlet {
client = "Azureus";
else if ("CwsL".equals(ch))
client = "I2PSnarkXL";
else if ("ZV".equals(ch.substring(2,4)))
client = "Robert";
else if ("VUZP".equals(ch))
else if ("ZV".equals(ch.substring(2,4)) || "VUZP".equals(ch))
client = "Robert";
else if (ch.startsWith("LV")) // LVCS 1.0.2?; LVRS 1.0.4
client = "Transmission";
else
client = _("Unknown") + " (" + ch + ')';
out.write(client + "  " + peer.toString().substring(5, 9));

View File

@ -125,7 +125,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
if (initialI2PData != null) {
synchronized (slock) {
i2pout.write(initialI2PData);
//i2pout.flush();
i2pout.flush();
}
}
if (initialSocketData != null) {

View File

@ -110,10 +110,10 @@
</target>
<target name="cleandep" depends="clean" />
<target name="distclean" depends="clean">
<delete dir="./jettylib" />
<echo message="Not actually deleting the jetty libs (since they're so large)" />
</target>
<target name="reallyclean" depends="distclean">
<delete dir="./jettylib" />
</target>
<target name="totallyclean" depends="clean">
<delete dir="./jettylib" />

View File

@ -0,0 +1,617 @@
// ========================================================================
// $Id: Server.java,v 1.40 2005/10/21 13:52:11 gregwilkins Exp $
// Copyright 2002-2004 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================================================================
package org.mortbay.jetty;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.mortbay.log.LogFactory;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpServer;
import org.mortbay.jetty.servlet.ServletHttpContext;
import org.mortbay.jetty.servlet.WebApplicationContext;
import org.mortbay.util.LogSupport;
import org.mortbay.util.Resource;
import org.mortbay.xml.XmlConfiguration;
/* ------------------------------------------------------------ */
/** The Jetty HttpServer.
*
* This specialization of org.mortbay.http.HttpServer adds knowledge
* about servlets and their specialized contexts. It also included
* support for initialization from xml configuration files
* that follow the XmlConfiguration dtd.
*
* HttpContexts created by Server are of the type
* org.mortbay.jetty.servlet.ServletHttpContext unless otherwise
* specified.
*
* This class also provides a main() method which starts a server for
* each config file passed on the command line. If the system
* property JETTY_NO_SHUTDOWN_HOOK is not set to true, then a shutdown
* hook is thread is registered to stop these servers.
*
* @see org.mortbay.xml.XmlConfiguration
* @see org.mortbay.jetty.servlet.ServletHttpContext
* @version $Revision: 1.40 $
* @author Greg Wilkins (gregw)
*/
public class Server extends HttpServer
{
static Log log = LogFactory.getLog(Server.class);
private String[] _webAppConfigurationClassNames =
new String[]{"org.mortbay.jetty.servlet.XMLConfiguration", "org.mortbay.jetty.servlet.JettyWebConfiguration"};
private String _configuration;
private String _rootWebApp;
private static ShutdownHookThread hookThread = new ShutdownHookThread();
/* ------------------------------------------------------------ */
/** Constructor.
*/
public Server()
{
}
/* ------------------------------------------------------------ */
/** Constructor.
* @param configuration The filename or URL of the XML
* configuration file.
*/
public Server(String configuration)
throws IOException
{
this(Resource.newResource(configuration).getURL());
}
/* ------------------------------------------------------------ */
/** Constructor.
* @param configuration The filename or URL of the XML
* configuration file.
*/
public Server(Resource configuration)
throws IOException
{
this(configuration.getURL());
}
/* ------------------------------------------------------------ */
/** Constructor.
* @param configuration The filename or URL of the XML
* configuration file.
*/
public Server(URL configuration)
throws IOException
{
_configuration=configuration.toString();
Server.hookThread.add(this);
try
{
XmlConfiguration config=new XmlConfiguration(configuration);
config.configure(this);
}
catch(IOException e)
{
throw e;
}
catch(InvocationTargetException e)
{
log.warn(LogSupport.EXCEPTION,e.getTargetException());
throw new IOException("Jetty configuration problem: "+e.getTargetException());
}
catch(Exception e)
{
log.warn(LogSupport.EXCEPTION,e);
throw new IOException("Jetty configuration problem: "+e);
}
}
/* ------------------------------------------------------------ */
public boolean getStopAtShutdown()
{
return hookThread.contains(this);
}
/* ------------------------------------------------------------ */
public void setStopAtShutdown(boolean stop)
{
if (stop)
hookThread.add(this);
else
hookThread.remove(this);
}
/* ------------------------------------------------------------ */
/** Get the root webapp name.
* @return The name of the root webapp (eg. "root" for root.war).
*/
public String getRootWebApp()
{
return _rootWebApp;
}
/* ------------------------------------------------------------ */
/** Set the root webapp name.
* @param rootWebApp The name of the root webapp (eg. "root" for root.war).
*/
public void setRootWebApp(String rootWebApp)
{
_rootWebApp = rootWebApp;
}
/* ------------------------------------------------------------ */
/** Configure the server from an XML file.
* @param configuration The filename or URL of the XML
* configuration file.
*/
public void configure(String configuration)
throws IOException
{
URL url=Resource.newResource(configuration).getURL();
if (_configuration!=null && _configuration.equals(url.toString()))
return;
if (_configuration!=null)
throw new IllegalStateException("Already configured with "+_configuration);
try
{
XmlConfiguration config=new XmlConfiguration(url);
_configuration=url.toString();
config.configure(this);
}
catch(IOException e)
{
throw e;
}
catch(Exception e)
{
log.warn(LogSupport.EXCEPTION,e);
throw new IOException("Jetty configuration problem: "+e);
}
}
/* ------------------------------------------------------------ */
public String getConfiguration()
{
return _configuration;
}
/* ------------------------------------------------------------ */
/** Create a new ServletHttpContext.
* Ths method is called by HttpServer to creat new contexts. Thus
* calls to addContext or getContext that result in a new Context
* being created will return an
* org.mortbay.jetty.servlet.ServletHttpContext instance.
* @return ServletHttpContext
*/
protected HttpContext newHttpContext()
{
return new ServletHttpContext();
}
/* ------------------------------------------------------------ */
/** Create a new WebApplicationContext.
* Ths method is called by Server to creat new contexts for web
* applications. Thus calls to addWebApplication that result in
* a new Context being created will return an correct class instance.
* Derived class can override this method to create instance of its
* own class derived from WebApplicationContext in case it needs more
* functionality.
* @param webApp The Web application directory or WAR file.
* @return WebApplicationContext
*/
protected WebApplicationContext newWebApplicationContext(
String webApp
)
{
return new WebApplicationContext(webApp);
}
/* ------------------------------------------------------------ */
/** Add Web Application.
* @param contextPathSpec The context path spec. Which must be of
* the form / or /path/*
* @param webApp The Web application directory or WAR file.
* @return The WebApplicationContext
* @exception IOException
*/
public WebApplicationContext addWebApplication(String contextPathSpec,
String webApp)
throws IOException
{
return addWebApplication(null,contextPathSpec,webApp);
}
/* ------------------------------------------------------------ */
/** Add Web Application.
* @param virtualHost Virtual host name or null
* @param contextPathSpec The context path spec. Which must be of
* the form / or /path/*
* @param webApp The Web application directory or WAR file.
* @return The WebApplicationContext
* @exception IOException
*/
public WebApplicationContext addWebApplication(String virtualHost,
String contextPathSpec,
String webApp)
throws IOException
{
WebApplicationContext appContext =
newWebApplicationContext(webApp);
appContext.setContextPath(contextPathSpec);
addContext(virtualHost,appContext);
if(log.isDebugEnabled())log.debug("Web Application "+appContext+" added");
return appContext;
}
/* ------------------------------------------------------------ */
/** Add Web Applications.
* Add auto webapplications to the server. The name of the
* webapp directory or war is used as the context name. If a
* webapp is called "root" it is added at "/".
* @param webapps Directory file name or URL to look for auto webapplication.
* @exception IOException
*/
public WebApplicationContext[] addWebApplications(String webapps)
throws IOException
{
return addWebApplications(null,webapps,null,false);
}
/* ------------------------------------------------------------ */
/** Add Web Applications.
* Add auto webapplications to the server. The name of the
* webapp directory or war is used as the context name. If the
* webapp matches the rootWebApp it is added as the "/" context.
* @param host Virtual host name or null
* @param webapps Directory file name or URL to look for auto webapplication.
* @exception IOException
*/
public WebApplicationContext[] addWebApplications(String host,
String webapps)
throws IOException
{
return addWebApplications(host,webapps,null,false);
}
/* ------------------------------------------------------------ */
/** Add Web Applications.
* Add auto webapplications to the server. The name of the
* webapp directory or war is used as the context name. If the
* webapp matches the rootWebApp it is added as the "/" context.
* @param host Virtual host name or null
* @param webapps Directory file name or URL to look for auto
* webapplication.
* @param extract If true, extract war files
* @exception IOException
*/
public WebApplicationContext[] addWebApplications(String host,
String webapps,
boolean extract)
throws IOException
{
return addWebApplications(host,webapps,null,extract);
}
/* ------------------------------------------------------------ */
/** Add Web Applications.
* Add auto webapplications to the server. The name of the
* webapp directory or war is used as the context name. If the
* webapp matches the rootWebApp it is added as the "/" context.
* @param host Virtual host name or null
* @param webapps Directory file name or URL to look for auto
* webapplication.
* @param defaults The defaults xml filename or URL which is
* loaded before any in the web app. Must respect the web.dtd.
* If null the default defaults file is used. If the empty string, then
* no defaults file is used.
* @param extract If true, extract war files
* @exception IOException
*/
public WebApplicationContext[] addWebApplications(String host,
String webapps,
String defaults,
boolean extract)
throws IOException
{
return addWebApplications(host,webapps,defaults,extract,true,null);
}
/* ------------------------------------------------------------ */
/** Add Web Applications.
* Add auto webapplications to the server. The name of the
* webapp directory or war is used as the context name. If the
* webapp matches the rootWebApp it is added as the "/" context.
* @param host Virtual host name or null
* @param webapps Directory file name or URL to look for auto
* webapplication.
* @param defaults The defaults xml filename or URL which is
* loaded before any in the web app. Must respect the web.dtd.
* If null the default defaults file is used. If the empty string, then
* no defaults file is used.
* @param extract If true, extract war files
* @param java2CompliantClassLoader True if java2 compliance is applied to all webapplications
* @exception IOException
*/
public WebApplicationContext[] addWebApplications(String host,
String webapps,
String defaults,
boolean extract,
boolean java2CompliantClassLoader)
throws IOException
{
return addWebApplications(host,webapps,defaults,extract,java2CompliantClassLoader,null);
}
/* ------------------------------------------------------------ */
/** Add Web Applications.
* Add auto webapplications to the server. The name of the
* webapp directory or war is used as the context name. If the
* webapp matches the rootWebApp it is added as the "/" context.
* @param host Virtual host name or null
* @param webapps Directory file name or URL to look for auto
* webapplication.
* @param defaults The defaults xml filename or URL which is
* loaded before any in the web app. Must respect the web.dtd.
* If null the default defaults file is used. If the empty string, then
* no defaults file is used.
* @param extract If true, extract war files
* @param java2CompliantClassLoader True if java2 compliance is applied to all webapplications
* @param Attributes[] A set of attributes to pass to setAttribute, format is first item is the key, second item is the value.
* @exception IOException
*/
public WebApplicationContext[] addWebApplications(String host,
String webapps,
String defaults,
boolean extract,
boolean java2CompliantClassLoader,
String Attributes[])
throws IOException
{
ArrayList wacs = new ArrayList();
Resource r=Resource.newResource(webapps);
if (!r.exists())
throw new IllegalArgumentException("No such webapps resource "+r);
if (!r.isDirectory())
throw new IllegalArgumentException("Not directory webapps resource "+r);
if(Attributes != null) {
if(((Attributes.length / 2) * 2) != Attributes.length) {
throw new IllegalArgumentException("Attributes must be in pairs of key,value.");
}
}
String[] files=r.list();
for (int f=0;files!=null && f<files.length;f++)
{
String context=files[f];
if (context.equalsIgnoreCase("CVS/") ||
context.equalsIgnoreCase("CVS") ||
context.startsWith("."))
continue;
String app = r.addPath(r.encode(files[f])).toString();
if (context.toLowerCase().endsWith(".war") ||
context.toLowerCase().endsWith(".jar"))
{
context=context.substring(0,context.length()-4);
Resource unpacked=r.addPath(context);
if (unpacked!=null && unpacked.exists() && unpacked.isDirectory())
continue;
}
if (_rootWebApp!=null && (context.equals(_rootWebApp)||context.equals(_rootWebApp+"/")))
context="/";
else
context="/"+context;
WebApplicationContext wac= addWebApplication(host,
context,
app);
wac.setExtractWAR(extract);
wac.setClassLoaderJava2Compliant(java2CompliantClassLoader);
if (defaults!=null)
{
if (defaults.length()==0)
wac.setDefaultsDescriptor(null);
else
wac.setDefaultsDescriptor(defaults);
}
if(Attributes != null) {
for(int i = 0; i < Attributes.length; i++, i++) {
wac.setAttribute(Attributes[i],Attributes[i + 1]);
}
}
wacs.add(wac);
}
return (WebApplicationContext[])wacs.toArray(new WebApplicationContext[wacs.size()]);
}
/* ------------------------------------------------------------ */
/** setWebApplicationConfigurationClasses
* Set up the list of classnames of WebApplicationContext.Configuration
* implementations that will be applied to configure every webapp.
* The list can be overridden by individual WebApplicationContexts.
* @param configurationClasses
*/
public void setWebApplicationConfigurationClassNames (String[] configurationClassNames)
{
if (configurationClassNames != null)
{
_webAppConfigurationClassNames = new String[configurationClassNames.length];
System.arraycopy(configurationClassNames, 0, _webAppConfigurationClassNames, 0, configurationClassNames.length);
}
}
public String[] getWebApplicationConfigurationClassNames ()
{
return _webAppConfigurationClassNames;
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
public static void main(String[] arg)
{
String[] dftConfig={"etc/jetty.xml"};
if (arg.length==0)
{
log.info("Using default configuration: etc/jetty.xml");
arg=dftConfig;
}
final Server[] servers=new Server[arg.length];
// create and start the servers.
for (int i=0;i<arg.length;i++)
{
try
{
servers[i] = new Server(arg[i]);
servers[i].setStopAtShutdown(true);
servers[i].start();
}
catch(Exception e)
{
log.warn(LogSupport.EXCEPTION,e);
}
}
// create and start the servers.
for (int i=0;i<arg.length;i++)
{
try{servers[i].join();}
catch (Exception e){LogSupport.ignore(log,e);}
}
}
/**
* ShutdownHook thread for stopping all servers.
*
* Thread is hooked first time list of servers is changed.
*/
private static class ShutdownHookThread extends Thread {
private boolean hooked = false;
private ArrayList servers = new ArrayList();
/**
* Hooks this thread for shutdown.
* @see java.lang.Runtime#addShutdownHook(java.lang.Thread)
*/
private void createShutdownHook() {
if (!Boolean.getBoolean("JETTY_NO_SHUTDOWN_HOOK") && !hooked) {
try {
Method shutdownHook = java.lang.Runtime.class.getMethod("addShutdownHook",
new Class[] { java.lang.Thread.class });
shutdownHook.invoke(Runtime.getRuntime(), new Object[] { this });
this.hooked = true;
} catch (Exception e) {
if (log.isDebugEnabled()) log.debug("No shutdown hook in JVM ", e);
}
}
}
/**
* Add Server to servers list.
*/
public boolean add(Server server) {
createShutdownHook();
return this.servers.add(server);
}
/**
* Contains Server in servers list?
*/
public boolean contains(Server server) {
return this.servers.contains(server);
}
/**
* Append all Servers from Collection
*/
public boolean addAll(Collection c) {
createShutdownHook();
return this.servers.addAll(c);
}
/**
* Clear list of Servers.
*/
public void clear() {
createShutdownHook();
this.servers.clear();
}
/**
* Remove Server from list.
*/
public boolean remove(Server server) {
createShutdownHook();
return this.servers.remove(server);
}
/**
* Remove all Servers in Collection from list.
*/
public boolean removeAll(Collection c) {
createShutdownHook();
return this.servers.removeAll(c);
}
/**
* Stop all Servers in list.
*/
public void run() {
setName("Shutdown");
log.info("Shutdown hook executing");
Iterator it = servers.iterator();
while (it.hasNext()) {
Server svr = (Server) it.next();
if (svr == null) continue;
try {
svr.stop();
} catch (Exception e) {
log.warn(LogSupport.EXCEPTION, e);
}
log.info("Shutdown hook complete");
// Try to avoid JVM crash
try {
Thread.sleep(1000);
} catch (Exception e) {
log.warn(LogSupport.EXCEPTION, e);
}
}
}
}
}

View File

@ -124,6 +124,7 @@ public class ConfigUpdateHandler extends FormHandler {
}
if ( (_trustedKeys != null) && (_trustedKeys.length() > 0) ) {
_trustedKeys = _trustedKeys.replaceAll("\r\n", ",").replaceAll("\n", ",");
String oldKeys = new TrustedUpdate(_context).getTrustedKeysString();
if ( (oldKeys == null) || (!_trustedKeys.equals(oldKeys)) ) {
_context.router().setConfigSetting(PROP_TRUSTED_KEYS, _trustedKeys);

View File

@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: I2P routerconsole\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-11-01 02:59+0000\n"
"PO-Revision-Date: 2010-01-17 22:09+0100\n"
"PO-Revision-Date: 2010-02-13 11:50+0100\n"
"Last-Translator: \n"
"Language-Team: foo <foo@bar>\n"
"MIME-Version: 1.0\n"
@ -1223,11 +1223,11 @@ msgstr ""
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/logs_jsp.java:105
msgid "logs"
msgstr "enregistrements"
msgstr "fichier traces"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/logs_jsp.java:227
msgid "I2P Router Logs"
msgstr "Enregistrements du routeur I2P"
msgstr "Fichier traces du routeur I2P"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/logs_jsp.java:229
msgid "I2P Version & Running Environment"
@ -2213,7 +2213,7 @@ msgstr "Services I2P"
#: src/net/i2p/router/web/SummaryBarRenderer.java:48
msgid "Manage your I2P hosts file here (I2P domain name resolution)"
msgstr ""
msgstr "Gérer votre fichier 'I2P hosts' ici (I2P DNS)"
#: src/net/i2p/router/web/SummaryBarRenderer.java:50
msgid "Addressbook"
@ -2254,7 +2254,7 @@ msgstr "I2P Configuration Interne"
#: src/net/i2p/router/web/SummaryBarRenderer.java:80
#: src/net/i2p/router/web/SummaryBarRenderer.java:344
msgid "View existing tunnels and tunnel build status"
msgstr ""
msgstr "Montrer les tunnels existants et le statut de création des tunnels"
#: src/net/i2p/router/web/SummaryBarRenderer.java:86
#: src/net/i2p/router/web/SummaryBarRenderer.java:221
@ -2263,7 +2263,7 @@ msgstr "Montrer toutes les connexions actuelles aux pairs"
#: src/net/i2p/router/web/SummaryBarRenderer.java:92
msgid "Show recent peer performance profiles"
msgstr ""
msgstr "Montrer les profils de la performance récente des pairs"
#: src/net/i2p/router/web/SummaryBarRenderer.java:94
msgid "Profiles"
@ -2279,15 +2279,15 @@ msgstr ""
#: src/net/i2p/router/web/SummaryBarRenderer.java:104
msgid "Health Report"
msgstr ""
msgstr "Fichier traces du routeur"
#: src/net/i2p/router/web/SummaryBarRenderer.java:106
msgid "Logs"
msgstr "Enregistrements"
msgstr "Fichier traces"
#: src/net/i2p/router/web/SummaryBarRenderer.java:110
msgid "Show the router's workload, and how it's performing"
msgstr ""
msgstr "Montrer les tâches en cours"
#: src/net/i2p/router/web/SummaryBarRenderer.java:112
msgid "Jobs"
@ -2295,7 +2295,7 @@ msgstr "Tâches"
#: src/net/i2p/router/web/SummaryBarRenderer.java:116
msgid "Graph router performance"
msgstr ""
msgstr "Montrer la performance du routeur avec des graphes"
#: src/net/i2p/router/web/SummaryBarRenderer.java:118
msgid "Graphs"
@ -2303,7 +2303,7 @@ msgstr "Graphes"
#: src/net/i2p/router/web/SummaryBarRenderer.java:122
msgid "Textual router performance statistics"
msgstr ""
msgstr "La performance statistique du routeur en texte"
#: src/net/i2p/router/web/SummaryBarRenderer.java:134
msgid "I2P Router Help"
@ -2375,7 +2375,7 @@ msgstr ""
#: src/net/i2p/router/web/SummaryBarRenderer.java:309
msgid "Configure router bandwidth allocation"
msgstr ""
msgstr "Configurer la bande passante du routeur"
#: src/net/i2p/router/web/SummaryBarRenderer.java:311
msgid "Bandwidth in/out"
@ -2403,7 +2403,7 @@ msgstr "Participant"
#: src/net/i2p/router/web/SummaryBarRenderer.java:373
msgid "What's in the router's job queue?"
msgstr ""
msgstr "Montrer les tâches du routeur qui sont à traiter "
#: src/net/i2p/router/web/SummaryBarRenderer.java:375
msgid "Congestion"
@ -2471,7 +2471,7 @@ msgstr "WARN - Pare-feu avec UDP desactivé"
#: src/net/i2p/router/web/SummaryHelper.java:360
msgid "Add/remove/edit &amp; control your client and server tunnels"
msgstr ""
msgstr "Ajouter/enlever/éditer &amp; contrôler vos tunnels client et serveur"
#: src/net/i2p/router/web/SummaryHelper.java:360
msgid "Local Destinations"

View File

@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: I2P routerconsole\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-01-18 18:36+0000\n"
"PO-Revision-Date: 2010-01-18 18:37+0000\n"
"POT-Creation-Date: 2010-02-10 13:36+0000\n"
"PO-Revision-Date: 2010-02-10 20:19+0000\n"
"Last-Translator: 4get <forget@mail.i2p>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -36,39 +36,39 @@ msgstr "IP заблокирован"
msgid "IP banned by blocklist.txt entry {0}"
msgstr "IP заблокирован по записи в blocklist.txt: {0}"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:91
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:92
msgid "Rejecting tunnels: Shutting down"
msgstr "Не принимаем туннели: Маршрутизатор в процессе остановки"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:140
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:141
msgid "Rejecting tunnels: High message delay"
msgstr "Не принимаем туннели: Слишком большая задержка сообщений"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:176
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:177
msgid "Rejecting most tunnels: High number of requests"
msgstr "Не принимаем большую часть туннелей: Слишком много запросов"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:232
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:233
msgid "Rejecting tunnels: Limit reached"
msgstr "Не принимаем туннели: Достигнут предел количества туннелей"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:300
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:301
msgid "Rejecting tunnels: Bandwidth limit"
msgstr "Не принимаем туннели: Достигнут предел пропускной способности"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:370
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:371
msgid "Rejecting most tunnels: Bandwidth limit"
msgstr "Не принимаем большую часть туннелей: Достигнут предел пропускной способности"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:374
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:375
msgid "Accepting most tunnels"
msgstr "Принимаем большую часть туннелей"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:376
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:377
msgid "Accepting tunnels"
msgstr "Принимаем туннели"
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:486
#: ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java:487
msgid "Rejecting tunnels"
msgstr "Не принимаем туннели"
@ -80,8 +80,8 @@ msgstr "Нет транспортных протоколов (в скрытом
msgid "Unreachable on any transport"
msgstr "Недоступен по всем транспортным протоколам"
#: ../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java:373
#: ../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java:578
#: ../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java:380
#: ../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java:594
#, java-format
msgid "Excessive clock skew: {0}"
msgstr "Чрезмерное расхождение времени: {0}"
@ -1144,7 +1144,7 @@ msgstr "Редактировать"
#: ../java/src/net/i2p/router/web/ConfigClientsHelper.java:28
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configclients_jsp.java:328
msgid "Add Client"
msgstr "Добавить клиента"
msgstr "Добавить клиент"
#: ../java/src/net/i2p/router/web/ConfigClientsHelper.java:36
msgid "Class and arguments"
@ -1773,139 +1773,136 @@ msgstr "Русский"
msgid "Swedish"
msgstr "Svenska"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:56
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:58
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:310
msgid "Check for updates"
msgstr "Проверить обновления"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:63
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:65
msgid "Update available, attempting to download now"
msgstr "Доступно обновление, пытаемся загрузить"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:65
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:67
msgid "Update available, click button on left to download"
msgstr "Доступно обновление, нажмите кнопку слева для загрузки"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:67
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:69
msgid "No update available"
msgstr "Нет доступных обновлений"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:75
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:77
msgid "Updating news URL to"
msgstr "Новый URL новостей"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:83
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:85
msgid "Updating proxy host to"
msgstr "Новый адрес I2P-прокси"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:91
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:93
msgid "Updating proxy port to"
msgstr "Новый порт I2P-прокси"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:104
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:106
msgid "Updating refresh frequency to"
msgstr "Новый интервал проверки обновлений"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:111
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:113
msgid "Updating update policy to"
msgstr "Новый режим обновлений"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:120
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:122
msgid "Updating update URLs."
msgstr "Новые URL обновлений"
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:128
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:131
msgid "Updating trusted keys."
msgstr "Обновление списка доверенных ключей."
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:136
#: ../java/src/net/i2p/router/web/ConfigUpdateHandler.java:139
msgid "Updating unsigned update URL to"
msgstr "Новый URL неподписанной тестовой сборки"
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:75
#: ../java/src/net/i2p/router/web/GraphHelper.java:133
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:88
#: ../java/src/net/i2p/router/web/GraphHelper.java:136
msgid "Never"
msgstr "Никогда"
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:77
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:90
msgid "Every"
msgstr "Каждые"
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:90
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:92
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:108
msgid "Notify only"
msgstr "Только уведомлять"
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:95
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:97
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:115
msgid "Download and verify only"
msgstr "Только скачать и проверить целостность"
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:101
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:103
#: ../java/src/net/i2p/router/web/ConfigUpdateHelper.java:123
msgid "Download, verify, and restart"
msgstr "Скачать, проверить и обновить I2P"
#: ../java/src/net/i2p/router/web/GraphHelper.java:125
#: ../java/src/net/i2p/router/web/GraphHelper.java:128
msgid "Configure Graph Display"
msgstr "Настройка показа графиков"
#: ../java/src/net/i2p/router/web/GraphHelper.java:125
#: ../java/src/net/i2p/router/web/GraphHelper.java:128
msgid "Select Stats"
msgstr "Выбрать параметры"
#: ../java/src/net/i2p/router/web/GraphHelper.java:127
#: ../java/src/net/i2p/router/web/GraphHelper.java:130
msgid "Periods"
msgstr "Количество интервалов"
#: ../java/src/net/i2p/router/web/GraphHelper.java:128
#: ../java/src/net/i2p/router/web/GraphHelper.java:131
msgid "Plot averages"
msgstr "Строить график средних значений"
#: ../java/src/net/i2p/router/web/GraphHelper.java:129
#: ../java/src/net/i2p/router/web/GraphHelper.java:132
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/config_jsp.java:405
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configservice_jsp.java:332
msgid "or"
msgstr "или"
#: ../java/src/net/i2p/router/web/GraphHelper.java:129
#: ../java/src/net/i2p/router/web/GraphHelper.java:132
msgid "plot events"
msgstr "строить график количества событий"
#: ../java/src/net/i2p/router/web/GraphHelper.java:130
#: ../java/src/net/i2p/router/web/GraphHelper.java:133
msgid "Image sizes"
msgstr "Размеры графиков"
#: ../java/src/net/i2p/router/web/GraphHelper.java:130
#: ../java/src/net/i2p/router/web/GraphHelper.java:133
msgid "width"
msgstr "ширина"
#: ../java/src/net/i2p/router/web/GraphHelper.java:131
#: ../java/src/net/i2p/router/web/GraphHelper.java:134
msgid "height"
msgstr "высота"
#: ../java/src/net/i2p/router/web/GraphHelper.java:131
#: ../java/src/net/i2p/router/web/GraphHelper.java:132
#: ../java/src/net/i2p/router/web/GraphHelper.java:134
#: ../java/src/net/i2p/router/web/GraphHelper.java:135
msgid "pixels"
msgstr "пикселей"
#: ../java/src/net/i2p/router/web/GraphHelper.java:133
#: ../java/src/net/i2p/router/web/GraphHelper.java:136
msgid "Refresh delay"
msgstr "Интервал обновления"
#: ../java/src/net/i2p/router/web/GraphHelper.java:133
#: ../java/src/net/i2p/router/web/GraphHelper.java:136
msgid "hour"
msgstr "час"
#: ../java/src/net/i2p/router/web/GraphHelper.java:133
#: ../java/src/net/i2p/router/web/GraphHelper.java:136
msgid "minute"
msgstr "минута"
#: ../java/src/net/i2p/router/web/GraphHelper.java:133
#: ../java/src/net/i2p/router/web/GraphHelper.java:136
msgid "minutes"
msgstr "минут(ы)"
#: ../java/src/net/i2p/router/web/GraphHelper.java:134
#: ../java/src/net/i2p/router/web/GraphHelper.java:137
msgid "Redraw"
msgstr "Перерисовать"
@ -2312,7 +2309,7 @@ msgstr "забанен ли этот пир, недоступен, дает ош
msgid "status"
msgstr "статус"
#: ../java/src/net/i2p/router/web/ProfileOrganizerRenderer.java:321
#: ../java/src/net/i2p/router/web/ProfileOrganizerRenderer.java:313
msgid "n/a"
msgstr "нет данных"
@ -2330,51 +2327,51 @@ msgstr "Забанен до перезагрузки или истечения {
msgid "unban now"
msgstr "разбанить"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:55
#: ../java/src/net/i2p/router/web/StatsGenerator.java:56
msgid "GO"
msgstr "Перейти"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:58
#: ../java/src/net/i2p/router/web/StatsGenerator.java:59
msgid "Statistics gathered during this router's uptime"
msgstr "Статистика собрана за время с последнего запуска маршрутизатора"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:61
#: ../java/src/net/i2p/router/web/StatsGenerator.java:62
msgid "The data gathered is quantized over a 1 minute period, so should just be used as an estimate."
msgstr "Собираемые данные округляются за 1-минутные промежутки, поэтому используйте эту информацию только для приблизительной оценки."
#: ../java/src/net/i2p/router/web/StatsGenerator.java:107
#: ../java/src/net/i2p/router/web/StatsGenerator.java:108
msgid "frequency"
msgstr "частота"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:141
#: ../java/src/net/i2p/router/web/StatsGenerator.java:142
msgid "No lifetime events"
msgstr "Счетчик lifetime событий пуст"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:153
#: ../java/src/net/i2p/router/web/StatsGenerator.java:154
msgid "rate"
msgstr "интервал"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:155
#: ../java/src/net/i2p/router/web/StatsGenerator.java:156
msgid "avg value"
msgstr "среднее значение"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:184
#: ../java/src/net/i2p/router/web/StatsGenerator.java:185
msgid "events"
msgstr "событий"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:190
#: ../java/src/net/i2p/router/web/StatsGenerator.java:191
msgid "No events"
msgstr "Нет событий"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:196
#: ../java/src/net/i2p/router/web/StatsGenerator.java:197
msgid "lifetime average"
msgstr "среднее за время работы"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:198
#: ../java/src/net/i2p/router/web/StatsGenerator.java:199
msgid "peak average"
msgstr "пиковое среднее"
#: ../java/src/net/i2p/router/web/StatsGenerator.java:216
#: ../java/src/net/i2p/router/web/StatsGenerator.java:217
msgid "lifetime average value"
msgstr "среднее значение за время работы"
@ -3150,7 +3147,7 @@ msgstr "Чем выше доля транзитного трафика, тем
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configstats_jsp.java:375
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configtunnels_jsp.java:343
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configui_jsp.java:323
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:356
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:364
msgid "Cancel"
msgstr "Отменить"
@ -4007,39 +4004,43 @@ msgstr "URL новостей"
msgid "Refresh frequency"
msgstr "Интервал проверки"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:322
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:324
msgid "Update policy"
msgstr "Режим обновления"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:326
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:328
msgid "Update through the eepProxy?"
msgstr "Обновлять через I2P-прокси?"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:330
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:332
msgid "eepProxy host"
msgstr "Адрес I2P-прокси"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:334
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:336
msgid "eepProxy port"
msgstr "Порт I2P-прокси"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:338
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:340
msgid "Update URLs"
msgstr "URL обновлений"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:342
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:344
msgid "Trusted keys"
msgstr "Доверенные ключи"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:346
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:348
msgid "Update with unsigned development builds?"
msgstr "Обновлять до неподписанной тестовой сборки?"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:350
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:352
msgid "Unsigned Build URL"
msgstr "URL неподписанной тестовой сборки"
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:354
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:358
msgid "I2P updates are disabled because you do not have write permission for the install directory."
msgstr "Функция автообновления I2P недоступна: у Вас нет прав на запись в директорию I2P."
#: ../jsp/WEB-INF/classes/net/i2p/router/web/jsp/configupdate_jsp.java:362
msgid "Save"
msgstr "Сохранить"

View File

@ -380,6 +380,13 @@
<copy todir="pkg-temp/licenses/" >
<fileset dir="licenses/" />
</copy>
<!--
The license in launch4j/ is a BSD license for launch4j
The license in launch4j/head is a MIT license for the code that is actually wrapped around the jars
So we include the MIT one in our binary package
-->
<copy file="installer/lib/launch4j/head/LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-Launch4j.txt" />
<!-- Not sure if these are used or should be included -->
<copy file="installer/lib/launch4j/lib/foxtrot.LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-Foxtrot.txt" />
<copy file="installer/lib/launch4j/lib/JGoodies.Forms.LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-JGoodies-Forms.txt" />
<copy file="installer/lib/launch4j/lib/JGoodies.Looks.LICENSE.txt" tofile="pkg-temp/licenses/LICENSE-JGoodies-Looks.txt" />
@ -433,7 +440,7 @@
</target>
<target name="prepconsoleDocs" depends="prepgeoupdate">
<copy todir="pkg-temp/docs/" >
<fileset dir="." includes="readme*.html" />
<fileset dir="installer/resources/readme/" includes="readme*.html" />
<fileset dir="installer/resources/proxy" />
</copy>
</target>

View File

@ -16,7 +16,7 @@ package net.i2p;
public class CoreVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = "0.7.10";
public final static String VERSION = "0.7.11";
public static void main(String args[]) {
System.out.println("I2P Core version: " + VERSION);

View File

@ -1,3 +1,43 @@
* 2010-02-15 0.7.11 released
2010-02-13 sponge
* Fix addWebApplications API goofup
* Bump BOB version, which I forgot to do.
2010-02-13 zzz
* Floodfills: Increase max to 28 (was 15) and min to 20 (was 10)
2010-02-12 sponge
* org.mortbay.jetty.Server modified method to accept attributes for
batch webapp launches via addWebApplications.
2010-02-10 zzz
* I2PTunnelRunner: Flush initial data, for some reason it wasn't
getting flushed ever in some cases.
2010-02-10 zzz
64-bit windows installer fixes. Still no 64-bit wrapper.
Thanks eche|on for testing!
* Izpack:
Add 64-bit windows dll so installer doesn't die trying to add shortcuts
* Launch4j:
Upgrade to launch4j 3.0.1 2008-07-20.
The license is BSD for launch4j and MIT for the wrapper code in head/
Changelog is in installer/lib/launch4j/web/changelog.html
Hopefully this will fix installs for 64-bit JRE on 64-bit windows.
The previous version was 2.0-RC3 2005-08-13.
The previous license was GPLv2 for launch4j and LGPLv2.1 for the wrapper code in head/
The bin/ld.exe and bin/windres.exe files were contributed by
i2p users in 2005 so the i2p installer could be built on windows.
They have not been updated for 3.0.1, so pkg builds on windows
will presumably still get 2.0-RC3.
2010-02-06 zzz
* Console: Fix saving update keys, was broken in 0.7.10
* i2psnark: Add transmission ID
* news.xml: Wrap i2p version tags in XML comment
* Transport: Try yet again to prevent two NTCP pumpers
2010-02-04 zzz
* i2psnark: Fix sending stopped events to the tracker

View File

@ -4,7 +4,7 @@
<info>
<appname>i2p</appname>
<appversion>0.7.10</appversion>
<appversion>0.7.11</appversion>
<authors>
<author name="I2P" email="http://forum.i2p2.de/"/>
</authors>
@ -78,8 +78,21 @@
<langpack iso3="ukr"/>
</locale>
<!--
The <os> tag can be used to restrict the inclusion into the uninstaller
to a specific operating system family, architecture or version.
The inclusion into the installer will be always done.
Here's a sample :
<native type="izpack" name="ShellLink.dll">
<os family="windows"/>
</native>
This doesn't appear to be necessary, the dlls don't get put in Uninstaller/uninstaller.jar on linux
-->
<native type="izpack" name="ShellLink.dll" />
<native type="izpack" name="ShellLink_x64.dll" />
<resources>
<res id="Installer.image" src="installer/resources/i2plogo.png" />
<res id="InfoPanel.info" src="installer/resources/readme.license.txt"/>

View File

@ -1,340 +1,30 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2008 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.

View File

@ -0,0 +1,13 @@
This is launch4j 3.0.1 2008-07-20.
The license is BSD for launch4j and MIT for the wrapper code in head/
Changelog is in web/changelog.html
We upgraded to get support for 64-bit JRE on 64-bit windows.
The previous version was 2.0-RC3 2005-08-13.
The license was GPLv2 for launch4j and LGPLv2.1 for the wrapper code in head/
The bin/ld.exe and bin/windres.exe files were contributed by
i2p users so the i2p installer could be built on windows.
They have not been updated for 3.0.1.

View File

@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -1,102 +1,62 @@
<project name="launch4j" default="compile" basedir=".">
<property name="versionNumber" value="2.0.0.0" />
<property name="version" value="2.0.RC3" />
<property name="src" location="src" />
<property name="lib" location="lib" />
<property name="build" location="build" />
<property name="dist" location="${user.home}/dist/${ant.project.name}" />
<property name="jar" location="./${ant.project.name}.jar" />
<property name="launch4j.dir" location="." />
<property name="javac.compilerargs" value="" />
<path id="dist.classpath">
<pathelement path="${build}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="init">
<tstamp />
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
</target>
<target name="compile" depends="init" description="compile the source">
<javac srcdir="${src}" destdir="${build}" classpathref="dist.classpath" source="1.4" debug="on" />
<compilerarg line="${javac.compilerargs}" />
</javac>
<copy todir="${build}/images">
<fileset dir="${src}/images">
<include name="**/*" />
</fileset>
</copy>
</target>
<target name="jar" depends="compile" description="create 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="${jar}">
<fileset dir="${build}" includes="**/*" />
<manifest>
<attribute name="Main-Class" value="net.sf.launch4j.Main" />
<attribute name="Class-Path" value=". ${dist.classpath}" />
</manifest>
</jar>
<jar jarfile="./launcher.jar">
<fileset dir="${build}" includes="net/sf/launch4j/Launcher.class" />
<manifest>
<attribute name="Main-Class" value="net.sf.launch4j.Launcher" />
<attribute name="Class-Path" value=". ./${ant.project.name}.jar ${dist.classpath}" />
</manifest>
</jar>
</target>
<target name="demo" depends="jar" description="build the demos">
<ant dir="./demo/ConsoleApp" inheritAll="false" />
<ant dir="./demo/SimpleApp" inheritAll="false" />
</target>
<target name="dist.linux" depends="jar" description="generate the Linux distribution">
<!-- changes executables to default mode!
<tar tarfile="${dist}/${ant.project.name}-${version}-linux.tgz" basedir="."
compression="gzip" excludes="**/build/** **/CVS/** **/*.exe"/> -->
<exec executable="tar" failonerror="true">
<arg line="-czC .. --exclude build --exclude CVS --exclude *.bat --exclude *.exe --exclude launch4j/l4j --exclude launch4j/launcher.jar -f ${dist}/${ant.project.name}-${version}-linux.tgz ./launch4j" />
</exec>
</target>
<target name="dist.win32" depends="jar" description="generate the Windows distribution">
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${build}:./lib/xstream.jar" />
<launch4j configFile="./l4j/launch4j.xml"
fileVersion="${versionNumber}" txtFileVersion="${version}"
productVersion="${versionNumber}" txtProductVersion="${version}" />
<launch4j configFile="./l4j/launch4jc.xml"
fileVersion="${versionNumber}" txtFileVersion="${version}"
productVersion="${versionNumber}" txtProductVersion="${version}" />
<zip destfile="${dist}/${ant.project.name}-${version}-win32.zip">
<zipfileset dir="." prefix="launch4j" excludes="**/build/** **/CVS/** bin/ld bin/windres l4j/** launch4j launcher.jar" />
</zip>
</target>
<target name="dist" depends="demo, dist.linux, dist.win32, clean" description="generate all distributions" />
<target name="clean" description="clean up">
<delete file="${jar}" />
<delete file="./launcher.jar" />
<delete>
<fileset dir="." includes="*.exe"/>
</delete>
<ant dir="./demo/ConsoleApp" target="clean" inheritAll="false" />
<ant dir="./demo/SimpleApp" target="clean" inheritAll="false" />
</target>
<target name="clean.all" depends="clean" description="clean up">
<delete dir="${build}" />
</target>
</project>
<project name="launch4j" default="compile" basedir=".">
<property name="src" location="src" />
<property name="lib" location="lib" />
<property name="build" location="build" />
<property name="jar" location="./${ant.project.name}.jar" />
<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.4" debug="on" />
<copy todir="${build}/images">
<fileset dir="${src}/images">
<include name="**/*" />
</fileset>
</copy>
<copy todir="${build}">
<fileset dir="${src}">
<include name="**/*.properties" />
</fileset>
</copy>
</target>
<target name="jar" depends="compile" description="create 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="${jar}">
<fileset dir="${build}" excludes="**/messages_es.properties" />
<manifest>
<attribute name="Main-Class" value="net.sf.launch4j.Main" />
<attribute name="Class-Path" value=". ${dist.classpath}" />
</manifest>
</jar>
</target>
<target name="demo" depends="jar" description="build the demos">
<ant dir="./demo/ConsoleApp" inheritAll="false" />
<ant dir="./demo/SimpleApp" inheritAll="false" />
</target>
<target name="clean" description="clean up">
<delete dir="${build}" />
<delete file="${jar}" />
<ant dir="./demo/ConsoleApp" target="clean" inheritAll="false" />
<ant dir="./demo/SimpleApp" target="clean" inheritAll="false" />
</target>
</project>

View File

@ -1 +0,0 @@
build

View File

@ -1,59 +1,57 @@
<project name="ConsoleApp" default="exe" basedir=".">
<property name="src" location="src"/>
<property name="lib" location="lib"/>
<property name="build" location="build"/>
<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}"/>
<pathelement path="${build}" />
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
<include name="**/*.jar" />
</fileset>
</path>
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
<tstamp />
<mkdir dir="${build}" />
</target>
<target name="compile" depends="init" description="compile the source">
<javac srcdir="${src}" destdir="${build}" classpathref="dist.classpath" debug="on"/>
<javac srcdir="${src}" destdir="${build}" classpathref="dist.classpath" source="1.4" debug="on" />
</target>
<target name="jar" depends="compile" description="create the jar">
<fileset dir="${lib}" id="lib.dist.fileset">
<include name="**/*.jar"/>
<include name="**/*.jar" />
</fileset>
<pathconvert pathsep=" " property="dist.classpath" refid="lib.dist.fileset">
<map from="${lib}" to=".\lib"/>
<map from="${lib}" to=".\lib" />
</pathconvert>
<!-- Put everything in ${build} into a jar file -->
<jar jarfile="${ant.project.name}.jar">
<fileset dir="${build}" includes="**/*"/>
<fileset dir="${build}" includes="**/*" />
<manifest>
<!-- SET YOUR MAIN CLASS HERE -->
<attribute name="Main-Class" value="net.sf.launch4j.example.ConsoleApp"/>
<attribute name="Class-Path" value=". ${dist.classpath}"/>
<attribute name="Main-Class" value="net.sf.launch4j.example.ConsoleApp" />
<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
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${launch4j.dir}/launch4j.jar
:${launch4j.dir}/lib/xstream.jar" />
<launch4j>
<config headerType="1" jar="ConsoleApp.jar" outfile="ConsoleApp.exe"
errTitle="ConsoleApp" chdir="." customProcName="true" icon="l4j/ConsoleApp.ico">
<jre minVersion="1.4.0" />
</config>
<config headerType="console" jar="ConsoleApp.jar" outfile="ConsoleApp.exe" errTitle="ConsoleApp" chdir="." customProcName="true" icon="l4j/ConsoleApp.ico">
<singleInstance mutexName="net.sf.launch4j.example.ConsoleApp" />
<jre minVersion="1.4.0" />
</config>
</launch4j>
</target>
<target name="clean" description="clean up" >
<delete dir="${build}"/>
<delete file="${ant.project.name}.jar"/>
<delete file="${ant.project.name}.exe"/>
<target name="clean" description="clean up">
<delete dir="${build}" />
<delete file="${ant.project.name}.jar" />
<delete file="${ant.project.name}.exe" />
</target>
</project>

View File

@ -1,57 +1,72 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.sf.launch4j.example;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ConsoleApp {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("Hello World!\n\nJava 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"));
if (args.length > 0) {
sb.append("\nArgs: ");
for (int i = 0; i < args.length; i++) {
sb.append(args[i]);
sb.append(' ');
}
}
sb.append("\n\nEnter a line of text, Ctrl-C to stop.\n\n>");
System.out.print(sb.toString());
try {
BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = is.readLine()) != null) {
System.out.print("You wrote: " + line + "\n\n>");
}
is.close();
} catch (IOException e) {
System.err.print(e);
}
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ConsoleApp {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("Hello World!\n\nJava 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"));
if (args.length > 0) {
sb.append("\nArgs: ");
for (int i = 0; i < args.length; i++) {
sb.append(args[i]);
sb.append(' ');
}
}
sb.append("\n\nEnter a line of text, Ctrl-C to stop.\n\n>");
System.out.print(sb.toString());
try {
BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = is.readLine()) != null && !line.equalsIgnoreCase("quit")) {
System.out.print("You wrote: " + line + "\n\n>");
}
is.close();
System.exit(123);
} catch (IOException e) {
System.err.print(e);
}
}
}

View File

@ -1,340 +1,30 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.

Binary file not shown.

View File

@ -0,0 +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.4" debug="on" />
</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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

@ -0,0 +1,18 @@
<launch4jConfig>
<headerType>gui</headerType>
<jar>../SimpleApp.jar</jar>
<outfile>../SimpleApp.exe</outfile>
<errTitle>SimpleApp</errTitle>
<chdir>.</chdir>
<customProcName>true</customProcName>
<icon>SimpleApp.ico</icon>
<jre>
<minVersion>1.4.0</minVersion>
</jre>
<splash>
<file>splash.bmp</file>
<waitForWindow>true</waitForWindow>
<timeout>60</timeout>
<timeoutErr>true</timeoutErr>
</splash>
</launch4jConfig>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -0,0 +1,8 @@
Put your jar libs here and the build script will include them
in the classpath stored inside the jar manifest.
In order to run your application move the output exe file from
the dist directory to the same level as lib.
SimpleApp.exe
lib/
lib/xml.jar

View File

@ -0,0 +1 @@
To build the example application set JAVA_HOME and ANT_HOME environment variables.

View File

@ -0,0 +1,104 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
public class SimpleApp extends JFrame {
public SimpleApp(String[] args) {
super("Java Application");
final int inset = 100;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds (inset, inset,
screenSize.width - inset * 2, screenSize.height - inset * 2);
JMenu menu = new JMenu("File");
menu.add(new JMenuItem("Open"));
menu.add(new JMenuItem("Save"));
JMenuBar mb = new JMenuBar();
mb.setOpaque(true);
mb.add(menu);
setJMenuBar(mb);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(123);
}});
setVisible(true);
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"));
if (args.length > 0) {
sb.append("\nArgs: ");
for (int i = 0; i < args.length; i++) {
sb.append(args[i]);
sb.append(' ');
}
}
JOptionPane.showMessageDialog(this,
sb.toString(),
"Info",
JOptionPane.INFORMATION_MESSAGE);
}
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);
}
}

View File

@ -1,504 +1,23 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
Copyright (c) 2004, 2007 Grzegorz Kowal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Binary file not shown.

View File

@ -1,504 +1,23 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
Copyright (c) 2004, 2008 Grzegorz Kowal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -5,11 +5,11 @@ CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = consolehead.o ../head.o $(RES)
LINKOBJ = consolehead.o ../head.o $(RES)
LIBS = -L"lib" -s
INCS = -I"include"
CXXINCS = -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
OBJ = ../../head/consolehead.o ../../head/head.o $(RES)
LINKOBJ = ../../head/consolehead.o ../../head/head.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -n -s
INCS = -I"C:/Dev-Cpp/include"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
BIN = consolehead.exe
CXXFLAGS = $(CXXINCS) -fexpensive-optimizations -O3
CFLAGS = $(INCS) -fexpensive-optimizations -O3
@ -24,10 +24,10 @@ clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o "consolehead.exe" $(LIBS)
# $(CC) $(LINKOBJ) -o "consolehead.exe" $(LIBS)
consolehead.o: consolehead.c
$(CC) -c consolehead.c -o consolehead.o $(CFLAGS)
../../head/consolehead.o: consolehead.c
$(CC) -c consolehead.c -o ../../head/consolehead.o $(CFLAGS)
../head.o: ../head.c
$(CC) -c ../head.c -o ../head.o $(CFLAGS)
../../head/head.o: ../head.c
$(CC) -c ../head.c -o ../../head/head.o $(CFLAGS)

View File

@ -1,24 +1,30 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2004-2005 Grzegorz Kowal
Copyright (c) 2004, 2007 Grzegorz Kowal
Compiled with Mingw port of GCC, Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "../resource.h"
@ -27,29 +33,32 @@
int main(int argc, char* argv[])
{
setConsoleFlag();
HMODULE hLibrary = NULL;
char cmdLine[BIG_STR] = "";
int i; // causes error: 'for' loop initial declaration used outside C99 mode.
for (i = 1; i < argc; i++) {
strcat(cmdLine, argv[i]);
if (i < argc - 1) {
strcat(cmdLine, " ");
LPTSTR cmdLine = GetCommandLine();
if (*cmdLine == '"') {
if (*(cmdLine = strchr(cmdLine + 1, '"') + 1)) {
cmdLine++;
}
} else if ((cmdLine = strchr(cmdLine, ' ')) != NULL) {
cmdLine++;
} else {
cmdLine = "";
}
if (!prepare(hLibrary, cmdLine)) {
if (hLibrary != NULL) {
FreeLibrary(hLibrary);
}
return 1;
}
FreeLibrary(hLibrary);
int result = (int) execute(TRUE);
if (result == -1) {
char errMsg[BIG_STR] = "could not start the application: ";
strcat(errMsg, strerror(errno));
int result = prepare(cmdLine);
if (result == ERROR_ALREADY_EXISTS) {
char errMsg[BIG_STR] = {0};
loadString(INSTANCE_ALREADY_EXISTS_MSG, errMsg);
msgBox(errMsg);
closeLogFile();
return 2;
}
if (result != TRUE) {
signalError();
return 1;
}
result = (int) execute(TRUE);
if (result == -1) {
signalError();
} else {
return result;
}

View File

@ -7,23 +7,23 @@ Ver=1
ObjFiles=
Includes=
Libs=
PrivateResource=consolehead_private.rc
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
Linker=-n_@@_
IsCpp=0
Icon=
ExeOutput=
ObjectOutput=
ObjectOutput=..\..\head
OverrideOutput=0
OverrideOutputName=consolehead.exe
HostApplication=
Folders=
CommandLine=
UseCustomMakefile=0
CustomMakefile=
CustomMakefile=Makefile.win
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0

View File

@ -5,11 +5,11 @@ CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = guihead.o ../head.o $(RES)
LINKOBJ = guihead.o ../head.o $(RES)
LIBS = -L"lib" -mwindows
INCS = -I"include"
CXXINCS = -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
OBJ = ../../head/guihead.o ../../head/head.o $(RES)
LINKOBJ = ../../head/guihead.o ../../head/head.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -mwindows -n -s
INCS = -I"C:/Dev-Cpp/include"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
BIN = guihead.exe
CXXFLAGS = $(CXXINCS) -fexpensive-optimizations -O3
CFLAGS = $(INCS) -fexpensive-optimizations -O3
@ -24,10 +24,10 @@ clean: clean-custom
${RM} $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o "guihead.exe" $(LIBS)
# $(CC) $(LINKOBJ) -o "guihead.exe" $(LIBS)
guihead.o: guihead.c
$(CC) -c guihead.c -o guihead.o $(CFLAGS)
../../head/guihead.o: guihead.c
$(CC) -c guihead.c -o ../../head/guihead.o $(CFLAGS)
../head.o: ../head.c
$(CC) -c ../head.c -o ../head.o $(CFLAGS)
../../head/head.o: ../head.c
$(CC) -c ../head.c -o ../../head/head.o $(CFLAGS)

View File

@ -1,30 +1,38 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2004-2005 Grzegorz Kowal
Copyright (c) 2004, 2007 Grzegorz Kowal
Sylvain Mina (single instance patch)
Compiled with Mingw port of GCC, Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "../resource.h"
#include "../head.h"
#include "guihead.h"
extern FILE* hLog;
extern PROCESS_INFORMATION pi;
HWND hWnd;
@ -33,39 +41,44 @@ BOOL stayAlive = FALSE;
BOOL splash = FALSE;
BOOL splashTimeoutErr;
BOOL waitForWindow;
int splashTimeout; // tick count (s)
int splashTimeout = DEFAULT_SPLASH_TIMEOUT;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow) {
HMODULE hLibrary = NULL;
if (!prepare(hLibrary, lpCmdLine)) {
if (hLibrary != NULL) {
FreeLibrary(hLibrary);
}
int result = prepare(lpCmdLine);
if (result == ERROR_ALREADY_EXISTS) {
HWND handle = getInstanceWindow();
ShowWindow(handle, SW_SHOW);
SetForegroundWindow(handle);
closeLogFile();
return 2;
}
if (result != TRUE) {
signalError();
return 1;
}
splash = loadBoolString(hLibrary, SHOW_SPLASH);
stayAlive = loadBoolString(hLibrary, GUI_HEADER_STAYS_ALIVE);
splash = loadBool(SHOW_SPLASH)
&& strstr(lpCmdLine, "--l4j-no-splash") == NULL;
stayAlive = loadBool(GUI_HEADER_STAYS_ALIVE)
&& strstr(lpCmdLine, "--l4j-dont-wait") == NULL;
if (splash || stayAlive) {
hWnd = CreateWindowEx(WS_EX_TOOLWINDOW, "STATIC", "",
WS_POPUP | SS_BITMAP,
0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
if (splash) {
char timeout[10] = "";
if (!loadString(hLibrary, SPLASH_TIMEOUT, timeout)) {
msgBox("Cannot load splash timeout property.");
return 1;
char timeout[10] = {0};
if (loadString(SPLASH_TIMEOUT, timeout)) {
splashTimeout = atoi(timeout);
if (splashTimeout <= 0 || splashTimeout > MAX_SPLASH_TIMEOUT) {
splashTimeout = DEFAULT_SPLASH_TIMEOUT;
}
}
splashTimeout = atoi(timeout);
if (splashTimeout <= 0 || splashTimeout > 60 * 15 /* 15 minutes */) {
msgBox("Invalid splash timeout property.");
return 1;
}
splashTimeoutErr = loadBoolString(hLibrary, SPLASH_TIMEOUT_ERR);
waitForWindow = loadBoolString(hLibrary, SPLASH_WAITS_FOR_WINDOW);
splashTimeoutErr = loadBool(SPLASH_TIMEOUT_ERR)
&& strstr(lpCmdLine, "--l4j-no-splash-err") == NULL;
waitForWindow = loadBool(SPLASH_WAITS_FOR_WINDOW);
HANDLE hImage = LoadImage(hInstance, // handle of the instance containing the image
MAKEINTRESOURCE(SPLASH_BITMAP), // name or identifier of image
IMAGE_BITMAP, // type of image
@ -73,7 +86,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
0, // desired height
LR_DEFAULTSIZE);
if (hImage == NULL) {
msgBox("Cannot load splash screen.");
signalError();
return 1;
}
SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hImage);
@ -86,29 +99,47 @@ int APIENTRY WinMain(HINSTANCE hInstance,
UpdateWindow (hWnd);
}
if (!SetTimer (hWnd, ID_TIMER, 1000 /* 1s */, TimerProc)) {
signalError();
return 1;
}
}
FreeLibrary(hLibrary);
if (execute(FALSE) == -1) {
char errMsg[BIG_STR] = "Error occured while starting the application...\n";
strcat(errMsg, strerror(errno));
msgBox(errMsg);
signalError();
return 1;
}
if (!(splash || stayAlive)) {
debug("Exit code:\t0\n");
closeHandles();
return 0;
}
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
debug("Exit code:\t%d\n", dwExitCode);
closeHandles();
return dwExitCode;
}
HWND getInstanceWindow() {
char windowTitle[STR];
char instWindowTitle[STR] = {0};
if (loadString(INSTANCE_WINDOW_TITLE, instWindowTitle)) {
HWND handle = FindWindowEx(NULL, NULL, NULL, NULL);
while (handle != NULL) {
GetWindowText(handle, windowTitle, STR - 1);
if (strstr(windowTitle, instWindowTitle) != NULL) {
return handle;
} else {
handle = FindWindowEx(NULL, handle, NULL, NULL);
}
}
}
return NULL;
}
BOOL CALLBACK enumwndfn(HWND hwnd, LPARAM lParam) {
DWORD processId;
GetWindowThreadProcessId(hwnd, &processId);
@ -135,7 +166,7 @@ VOID CALLBACK TimerProc(
ShowWindow(hWnd, SW_HIDE);
if (waitForWindow && splashTimeoutErr) {
KillTimer(hwnd, ID_TIMER);
msgBox("Could not start the application, operation timed out.");
signalError();
PostQuitMessage(0);
}
} else {
@ -149,7 +180,6 @@ VOID CALLBACK TimerProc(
if (dwExitCode != STILL_ACTIVE
|| !(splash || stayAlive)) {
KillTimer(hWnd, ID_TIMER);
PostQuitMessage(0);
return;
PostQuitMessage(0);
}
}

View File

@ -12,22 +12,22 @@ ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=_@@_
Linker=-n_@@_
IsCpp=0
Icon=
ExeOutput=
ObjectOutput=
ObjectOutput=..\..\head
OverrideOutput=0
OverrideOutputName=guihead.exe
HostApplication=
Folders=
CommandLine=
UseCustomMakefile=0
CustomMakefile=
UseCustomMakefile=1
CustomMakefile=Makefile.win
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000001001000000000
CompilerSettings=0000000001001000000100
[Unit1]
FileName=guihead.c
@ -37,7 +37,7 @@ Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
BuildCmd=$(CC) -c guihead.c -o ../../head/guihead.o $(CFLAGS)
[Unit2]
FileName=guihead.h
@ -78,16 +78,6 @@ OverrideBuildCmd=0
BuildCmd=
[Unit6]
FileName=..\resource.h
Folder=guihead
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
CompileCpp=0
[Unit7]
FileName=..\resid.h
CompileCpp=0
Folder=guihead

View File

@ -1,27 +1,39 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2004-2005 Grzegorz Kowal
Copyright (c) 2004, 2007 Grzegorz Kowal
Compiled with Mingw port of GCC, Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#define ID_TIMER 1
#define DEFAULT_SPLASH_TIMEOUT 60 /* 60 seconds */
#define MAX_SPLASH_TIMEOUT 60 * 15 /* 15 minutes */
HWND getInstanceWindow();
BOOL CALLBACK enumwndfn(HWND hwnd, LPARAM lParam);
VOID CALLBACK TimerProc(
HWND hwnd, // handle of window for timer messages

View File

@ -1,43 +1,85 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2004-2005 Grzegorz Kowal
Copyright (c) 2004, 2008 Grzegorz Kowal,
Ian Roberts (jdk preference patch)
Sylvain Mina (single instance patch)
Compiled with Mingw port of GCC, Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "resource.h"
#include "head.h"
HMODULE hModule;
FILE* hLog;
BOOL console = FALSE;
BOOL wow64 = FALSE;
int foundJava = NO_JAVA_FOUND;
struct _stat statBuf;
PROCESS_INFORMATION pi;
DWORD priority;
char errTitle[STR] = "launch4j";
char javaMinVer[STR] = "";
char javaMaxVer[STR] = "";
char foundJavaVer[STR] = "";
char mutexName[STR] = {0};
char workingDir[_MAX_PATH] = "";
char cmd[_MAX_PATH] = "";
char args[BIG_STR * 2] = "";
char errUrl[256] = {0};
char errTitle[STR] = "Launch4j";
char errMsg[BIG_STR] = {0};
char javaMinVer[STR] = {0};
char javaMaxVer[STR] = {0};
char foundJavaVer[STR] = {0};
char foundJavaKey[_MAX_PATH] = {0};
char oldPwd[_MAX_PATH] = {0};
char workingDir[_MAX_PATH] = {0};
char cmd[_MAX_PATH] = {0};
char args[MAX_ARGS] = {0};
FILE* openLogFile(const char* exePath, const int pathLen) {
char path[_MAX_PATH] = {0};
strncpy(path, exePath, pathLen);
strcat(path, "\\launch4j.log");
return fopen(path, "a");
}
void closeLogFile() {
if (hLog != NULL) {
fclose(hLog);
}
}
void setWow64Flag() {
LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
if (fnIsWow64Process != NULL) {
fnIsWow64Process(GetCurrentProcess(), &wow64);
}
debug("WOW64:\t\t%s\n", wow64 ? "yes" : "no");
}
void setConsoleFlag() {
console = TRUE;
@ -51,19 +93,43 @@ void msgBox(const char* text) {
}
}
void showJavaWebPage() {
ShellExecute(NULL, "open", "http://java.com", NULL, NULL, SW_SHOWNORMAL);
void signalError() {
DWORD err = GetLastError();
if (err) {
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
debug("Error:\t\t%s\n", (LPCTSTR) lpMsgBuf);
strcat(errMsg, "\n\n");
strcat(errMsg, (LPCTSTR) lpMsgBuf);
msgBox(errMsg);
LocalFree(lpMsgBuf);
} else {
msgBox(errMsg);
}
if (*errUrl) {
debug("Open URL:\t%s\n", errUrl);
ShellExecute(NULL, "open", errUrl, NULL, NULL, SW_SHOWNORMAL);
}
closeLogFile();
}
BOOL loadString(HMODULE hLibrary, int resID, char* buffer) {
BOOL loadString(const int resID, char* buffer) {
HRSRC hResource;
HGLOBAL hResourceLoaded;
LPBYTE lpBuffer;
hResource = FindResourceEx(hLibrary, RT_RCDATA, MAKEINTRESOURCE(resID),
hResource = FindResourceEx(hModule, RT_RCDATA, MAKEINTRESOURCE(resID),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT));
if (NULL != hResource) {
hResourceLoaded = LoadResource(hLibrary, hResource);
hResourceLoaded = LoadResource(hModule, hResource);
if (NULL != hResourceLoaded) {
lpBuffer = (LPBYTE) LockResource(hResourceLoaded);
if (NULL != lpBuffer) {
@ -71,24 +137,76 @@ BOOL loadString(HMODULE hLibrary, int resID, char* buffer) {
do {
buffer[x] = (char) lpBuffer[x];
} while (buffer[x++] != 0);
// debug("Resource %d:\t%s\n", resID, buffer);
return TRUE;
}
}
} else {
SetLastError(0);
}
return FALSE;
}
BOOL loadBoolString(HMODULE hLibrary, int resID) {
char boolStr[10] = "";
loadString(hLibrary, resID, boolStr);
BOOL loadBool(const int resID) {
char boolStr[20] = {0};
loadString(resID, boolStr);
return strcmp(boolStr, TRUE_STR) == 0;
}
void regSearch(HKEY hKey, char* keyName, int searchType) {
int loadInt(const int resID) {
char intStr[20] = {0};
loadString(resID, intStr);
return atoi(intStr);
}
BOOL regQueryValue(const char* regPath, unsigned char* buffer,
unsigned long bufferLength) {
HKEY hRootKey;
char* key;
char* value;
if (strstr(regPath, HKEY_CLASSES_ROOT_STR) == regPath) {
hRootKey = HKEY_CLASSES_ROOT;
} else if (strstr(regPath, HKEY_CURRENT_USER_STR) == regPath) {
hRootKey = HKEY_CURRENT_USER;
} else if (strstr(regPath, HKEY_LOCAL_MACHINE_STR) == regPath) {
hRootKey = HKEY_LOCAL_MACHINE;
} else if (strstr(regPath, HKEY_USERS_STR) == regPath) {
hRootKey = HKEY_USERS;
} else if (strstr(regPath, HKEY_CURRENT_CONFIG_STR) == regPath) {
hRootKey = HKEY_CURRENT_CONFIG;
} else {
return FALSE;
}
key = strchr(regPath, '\\') + 1;
value = strrchr(regPath, '\\') + 1;
*(value - 1) = 0;
HKEY hKey;
unsigned long datatype;
BOOL result = FALSE;
if ((wow64 && RegOpenKeyEx(hRootKey,
key,
0,
KEY_READ | KEY_WOW64_64KEY,
&hKey) == ERROR_SUCCESS)
|| RegOpenKeyEx(hRootKey,
key,
0,
KEY_READ,
&hKey) == ERROR_SUCCESS) {
result = RegQueryValueEx(hKey, value, NULL, &datatype, buffer, &bufferLength)
== ERROR_SUCCESS;
RegCloseKey(hKey);
}
*(value - 1) = '\\';
return result;
}
void regSearch(const HKEY hKey, const char* keyName, const int searchType) {
DWORD x = 0;
unsigned long size = BIG_STR;
FILETIME time;
char buffer[BIG_STR] = "";
char buffer[BIG_STR] = {0};
while (RegEnumKeyEx(
hKey, // handle to key to enumerate
x++, // index of subkey to enumerate
@ -98,61 +216,92 @@ void regSearch(HKEY hKey, char* keyName, int searchType) {
NULL, // address of buffer for class string
NULL, // address for size of class buffer
&time) == ERROR_SUCCESS) {
if (strcmp(buffer, javaMinVer) >= 0
&& (javaMaxVer[0] == 0 || strcmp(buffer, javaMaxVer) <= 0)
&& (!*javaMaxVer || strcmp(buffer, javaMaxVer) <= 0)
&& strcmp(buffer, foundJavaVer) > 0) {
strcpy(foundJavaVer, buffer);
strcpy(foundJavaKey, keyName);
appendPath(foundJavaKey, buffer);
foundJava = searchType;
debug("Match:\t\t%s\\%s\n", keyName, buffer);
} else {
debug("Ignore:\t\t%s\\%s\n", keyName, buffer);
}
size = BIG_STR;
}
}
BOOL findJavaHome(char* path) {
void regSearchWow(const char* keyName, const int searchType) {
HKEY hKey;
char jre[] = "SOFTWARE\\JavaSoft\\Java Runtime Environment";
char sdk[] = "SOFTWARE\\JavaSoft\\Java Development Kit";
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT(jre),
debug("64-bit search:\t%s...\n", keyName);
if (wow64 && RegOpenKeyEx(HKEY_LOCAL_MACHINE,
keyName,
0,
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
KEY_READ | KEY_WOW64_64KEY,
&hKey) == ERROR_SUCCESS) {
regSearch(hKey, jre, FOUND_JRE);
regSearch(hKey, keyName, searchType | KEY_WOW64_64KEY);
RegCloseKey(hKey);
if ((foundJava & KEY_WOW64_64KEY) != NO_JAVA_FOUND)
{
debug("Using 64-bit runtime.\n");
return;
}
}
debug("32-bit search:\t%s...\n", keyName);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
keyName,
0,
KEY_READ,
&hKey) == ERROR_SUCCESS) {
regSearch(hKey, keyName, searchType);
RegCloseKey(hKey);
}
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT(sdk),
0,
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
&hKey) == ERROR_SUCCESS) {
regSearch(hKey, sdk, FOUND_SDK);
RegCloseKey(hKey);
}
void regSearchJreSdk(const char* jreKeyName, const char* sdkKeyName,
const int jdkPreference) {
if (jdkPreference == JDK_ONLY || jdkPreference == PREFER_JDK) {
regSearchWow(sdkKeyName, FOUND_SDK);
if (jdkPreference != JDK_ONLY) {
regSearchWow(jreKeyName, FOUND_JRE);
}
} else { // jdkPreference == JRE_ONLY or PREFER_JRE
regSearchWow(jreKeyName, FOUND_JRE);
if (jdkPreference != JRE_ONLY) {
regSearchWow(sdkKeyName, FOUND_SDK);
}
}
}
BOOL findJavaHome(char* path, const int jdkPreference) {
regSearchJreSdk("SOFTWARE\\JavaSoft\\Java Runtime Environment",
"SOFTWARE\\JavaSoft\\Java Development Kit",
jdkPreference);
if (foundJava == NO_JAVA_FOUND) {
regSearchJreSdk("SOFTWARE\\IBM\\Java2 Runtime Environment",
"SOFTWARE\\IBM\\Java Development Kit",
jdkPreference);
}
if (foundJava != NO_JAVA_FOUND) {
char keyBuffer[BIG_STR];
unsigned long datatype;
unsigned long bufferlength = BIG_STR;
if (foundJava == FOUND_JRE) {
strcpy(keyBuffer, jre);
} else {
strcpy(keyBuffer, sdk);
}
strcat(keyBuffer, "\\");
strcat(keyBuffer, foundJavaVer);
HKEY hKey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT(keyBuffer),
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS) {
unsigned char buffer[BIG_STR];
if (RegQueryValueEx(hKey, "JavaHome", NULL, &datatype, buffer, &bufferlength)
== ERROR_SUCCESS) {
foundJavaKey,
0,
KEY_READ | (foundJava & KEY_WOW64_64KEY),
&hKey) == ERROR_SUCCESS) {
unsigned char buffer[BIG_STR] = {0};
unsigned long bufferlength = BIG_STR;
unsigned long datatype;
if (RegQueryValueEx(hKey, "JavaHome", NULL, &datatype, buffer,
&bufferlength) == ERROR_SUCCESS) {
int i = 0;
do {
path[i] = buffer[i];
} while (path[i++] != 0);
if (foundJava == FOUND_SDK) {
strcat(path, "\\jre");
if (foundJava & FOUND_SDK) {
appendPath(path, "jre");
}
RegCloseKey(hKey);
return TRUE;
@ -164,66 +313,93 @@ BOOL findJavaHome(char* path) {
}
/*
* extract the executable name, returns path length.
* Extract the executable name, returns path length.
*/
int getExePath(char* exePath) {
HMODULE hModule = GetModuleHandle(NULL);
if (hModule == 0
|| GetModuleFileName(hModule, exePath, _MAX_PATH) == 0) {
if (GetModuleFileName(hModule, exePath, _MAX_PATH) == 0) {
return -1;
}
return strrchr(exePath, '\\') - exePath;
}
void appendPath(char* basepath, const char* path) {
if (basepath[strlen(basepath) - 1] != '\\') {
strcat(basepath, "\\");
}
strcat(basepath, path);
}
void appendJavaw(char* jrePath) {
if (console) {
strcat(jrePath, "\\bin\\java.exe");
appendPath(jrePath, "bin\\java.exe");
} else {
strcat(jrePath, "\\bin\\javaw.exe");
appendPath(jrePath, "bin\\javaw.exe");
}
}
void appendLauncher(BOOL setProcName, char* exePath, int pathLen, char* cmd) {
void appendLauncher(const BOOL setProcName, char* exePath,
const int pathLen, char* cmd) {
if (setProcName) {
char tmpspec[_MAX_PATH] = "";
char tmpfile[_MAX_PATH] = "";
char tmpspec[_MAX_PATH];
char tmpfile[_MAX_PATH];
strcpy(tmpspec, cmd);
strcat(tmpspec, LAUNCH4J_TMP_DIR);
tmpspec[strlen(tmpspec) - 1] = 0;
if (_stat(tmpspec, &statBuf) == 0) {
// remove temp launchers
// Remove temp launchers and manifests
struct _finddata_t c_file;
long hFile;
strcat(tmpspec, "\\*.exe");
appendPath(tmpspec, "*.exe");
strcpy(tmpfile, cmd);
strcat(tmpfile, LAUNCH4J_TMP_DIR);
char* filename = tmpfile + strlen(tmpfile);
if ((hFile = _findfirst(tmpspec, &c_file)) != -1L) {
do {
strcpy(filename, c_file.name);
debug("Unlink:\t\t%s\n", tmpfile);
_unlink(tmpfile);
strcat(tmpfile, MANIFEST);
debug("Unlink:\t\t%s\n", tmpfile);
_unlink(tmpfile);
} while (_findnext(hFile, &c_file) == 0);
}
_findclose(hFile);
} else {
if (_mkdir(tmpspec) != 0) {
debug("Mkdir failed:\t%s\n", tmpspec);
appendJavaw(cmd);
return;
}
}
char javaw[_MAX_PATH] = "";
char javaw[_MAX_PATH];
strcpy(javaw, cmd);
appendJavaw(javaw);
strcpy(tmpfile, cmd);
strcat(tmpfile, LAUNCH4J_TMP_DIR);
char* tmpfilename = tmpfile + strlen(tmpfile);
char* exeFilePart = exePath + pathLen + 1;
strcat(tmpfile, exeFilePart);
// Copy manifest
char manifest[_MAX_PATH] = {0};
strcpy(manifest, exePath);
strcat(manifest, MANIFEST);
if (_stat(manifest, &statBuf) == 0) {
strcat(tmpfile, exeFilePart);
strcat(tmpfile, MANIFEST);
debug("Copy:\t\t%s -> %s\n", manifest, tmpfile);
CopyFile(manifest, tmpfile, FALSE);
}
// Copy launcher
strcpy(tmpfilename, exeFilePart);
debug("Copy:\t\t%s -> %s\n", javaw, tmpfile);
if (CopyFile(javaw, tmpfile, FALSE)) {
strcpy(cmd, tmpfile);
return;
} else {
} else if (_stat(javaw, &statBuf) == 0) {
long fs = statBuf.st_size;
if (_stat(tmpfile, &statBuf) == 0 && fs == statBuf.st_size) {
debug("Reusing:\t\t%s\n", tmpfile);
strcpy(cmd, tmpfile);
return;
}
@ -232,123 +408,396 @@ void appendLauncher(BOOL setProcName, char* exePath, int pathLen, char* cmd) {
appendJavaw(cmd);
}
BOOL isJrePathOk(char* path) {
if (!*path) {
return FALSE;
void appendAppClasspath(char* dst, const char* src, const char* classpath) {
strcat(dst, src);
if (*classpath) {
strcat(dst, ";");
}
char javaw[_MAX_PATH];
strcpy(javaw, path);
appendJavaw(javaw);
return _stat(javaw, &statBuf) == 0;
}
BOOL prepare(HMODULE hLibrary, char *lpCmdLine) {
// open executable
char exePath[_MAX_PATH] = "";
BOOL isJrePathOk(const char* path) {
char javaw[_MAX_PATH];
BOOL result = FALSE;
if (*path) {
strcpy(javaw, path);
appendJavaw(javaw);
result = _stat(javaw, &statBuf) == 0;
}
debug("Check launcher:\t%s %s\n", javaw, result ? "(OK)" : "(n/a)");
return result;
}
/*
* Expand environment %variables%
*/
BOOL expandVars(char *dst, const char *src, const char *exePath, const int pathLen) {
char varName[STR];
char varValue[MAX_VAR_SIZE];
while (strlen(src) > 0) {
char *start = strchr(src, '%');
if (start != NULL) {
char *end = strchr(start + 1, '%');
if (end == NULL) {
return FALSE;
}
// Copy content up to %VAR%
strncat(dst, src, start - src);
// Insert value of %VAR%
*varName = 0;
strncat(varName, start + 1, end - start - 1);
// Remember value start for logging
char *varValue = dst + strlen(dst);
if (strcmp(varName, "EXEDIR") == 0) {
strncat(dst, exePath, pathLen);
} else if (strcmp(varName, "EXEFILE") == 0) {
strcat(dst, exePath);
} else if (strcmp(varName, "PWD") == 0) {
GetCurrentDirectory(_MAX_PATH, dst + strlen(dst));
} else if (strcmp(varName, "OLDPWD") == 0) {
strcat(dst, oldPwd);
} else if (strstr(varName, HKEY_STR) == varName) {
regQueryValue(varName, dst + strlen(dst), BIG_STR);
} else if (GetEnvironmentVariable(varName, varValue, MAX_VAR_SIZE) > 0) {
strcat(dst, varValue);
}
debug("Substitute:\t%s = %s\n", varName, varValue);
src = end + 1;
} else {
// Copy remaining content
strcat(dst, src);
break;
}
}
return TRUE;
}
void appendHeapSizes(char *dst) {
MEMORYSTATUS m;
memset(&m, 0, sizeof(m));
GlobalMemoryStatus(&m);
appendHeapSize(dst, INITIAL_HEAP_SIZE, INITIAL_HEAP_PERCENT,
m.dwAvailPhys, "-Xms");
appendHeapSize(dst, MAX_HEAP_SIZE, MAX_HEAP_PERCENT,
m.dwAvailPhys, "-Xmx");
}
void appendHeapSize(char *dst, const int absID, const int percentID,
const DWORD freeMemory, const char *option) {
const int mb = 1048576; // 1 MB
int abs = loadInt(absID);
int percent = loadInt(percentID);
int free = (long long) freeMemory * percent / (100 * mb); // 100% * 1 MB
int size = free > abs ? free : abs;
if (size > 0) {
debug("Heap %s:\t%d MB / %d%%, Free: %d MB, Heap size: %d MB\n",
option, abs, percent, freeMemory / mb, size);
strcat(dst, option);
_itoa(size, dst + strlen(dst), 10); // 10 -- radix
strcat(dst, "m ");
}
}
int prepare(const char *lpCmdLine) {
char tmp[MAX_ARGS] = {0};
hModule = GetModuleHandle(NULL);
if (hModule == NULL) {
return FALSE;
}
// Get executable path
char exePath[_MAX_PATH] = {0};
int pathLen = getExePath(exePath);
if (pathLen == -1) {
msgBox("Cannot determinate exe file name.");
return FALSE;
}
hLibrary = LoadLibrary(exePath);
if (hLibrary == NULL) {
char msg[BIG_STR] = "Cannot find file: ";
strcat(msg, exePath);
msgBox(msg);
return FALSE;
}
// error message box title
loadString(hLibrary, ERR_TITLE, errTitle);
// working dir
char tmp_path[_MAX_PATH] = "";
if (loadString(hLibrary, CHDIR, tmp_path)) {
strncpy(workingDir, exePath, pathLen);
strcat(workingDir, "/");
strcat(workingDir, tmp_path);
_chdir(workingDir);
}
// custom process name
const BOOL setProcName = loadBoolString(hLibrary, SET_PROC_NAME);
// use bundled jre or find java
if (loadString(hLibrary, JRE_PATH, tmp_path)) {
strncpy(cmd, exePath, pathLen);
strcat(cmd, "/");
strcat(cmd, tmp_path);
}
if (!isJrePathOk(cmd)) {
if (!loadString(hLibrary, JAVA_MIN_VER, javaMinVer)) {
msgBox("Cannot find bundled JRE or javaw.exe is missing.");
// Initialize logging
if (strstr(lpCmdLine, "--l4j-debug") != NULL) {
hLog = openLogFile(exePath, pathLen);
if (hLog == NULL) {
return FALSE;
}
loadString(hLibrary, JAVA_MAX_VER, javaMaxVer);
if (!findJavaHome(cmd)) {
char txt[BIG_STR] = "Cannot find Java ";
strcat(txt, javaMinVer);
debug("\n\nCmdLine:\t%s %s\n", exePath, lpCmdLine);
}
setWow64Flag();
// Set default error message, title and optional support web site url.
loadString(SUPPORT_URL, errUrl);
loadString(ERR_TITLE, errTitle);
if (!loadString(STARTUP_ERR, errMsg)) {
return FALSE;
}
// Single instance
loadString(MUTEX_NAME, mutexName);
if (*mutexName) {
SECURITY_ATTRIBUTES security;
security.nLength = sizeof(SECURITY_ATTRIBUTES);
security.bInheritHandle = TRUE;
security.lpSecurityDescriptor = NULL;
CreateMutexA(&security, FALSE, mutexName);
if (GetLastError() == ERROR_ALREADY_EXISTS) {
debug("Instance already exists.");
return ERROR_ALREADY_EXISTS;
}
}
// Working dir
char tmp_path[_MAX_PATH] = {0};
GetCurrentDirectory(_MAX_PATH, oldPwd);
if (loadString(CHDIR, tmp_path)) {
strncpy(workingDir, exePath, pathLen);
appendPath(workingDir, tmp_path);
_chdir(workingDir);
debug("Working dir:\t%s\n", workingDir);
}
// Use bundled jre or find java
if (loadString(JRE_PATH, tmp_path)) {
char jrePath[MAX_ARGS] = {0};
expandVars(jrePath, tmp_path, exePath, pathLen);
debug("Bundled JRE:\t%s\n", jrePath);
if (jrePath[0] == '\\' || jrePath[1] == ':') {
// Absolute
strcpy(cmd, jrePath);
} else {
// Relative
strncpy(cmd, exePath, pathLen);
appendPath(cmd, jrePath);
}
}
if (!isJrePathOk(cmd)) {
if (!loadString(JAVA_MIN_VER, javaMinVer)) {
loadString(BUNDLED_JRE_ERR, errMsg);
return FALSE;
}
loadString(JAVA_MAX_VER, javaMaxVer);
if (!findJavaHome(cmd, loadInt(JDK_PREFERENCE))) {
loadString(JRE_VERSION_ERR, errMsg);
strcat(errMsg, " ");
strcat(errMsg, javaMinVer);
if (*javaMaxVer) {
strcat(txt, " - ");
strcat(txt, javaMaxVer);
strcat(errMsg, " - ");
strcat(errMsg, javaMaxVer);
}
msgBox(txt);
showJavaWebPage();
loadString(DOWNLOAD_URL, errUrl);
return FALSE;
}
if (!isJrePathOk(cmd)) {
msgBox("Java found, but javaw.exe seems to be missing.");
loadString(LAUNCHER_ERR, errMsg);
return FALSE;
}
}
// Append a path to the Path environment variable
char jreBinPath[_MAX_PATH];
strcpy(jreBinPath, cmd);
strcat(jreBinPath, "\\bin");
if (!appendToPathVar(jreBinPath)) {
return FALSE;
}
// Set environment variables
char envVars[MAX_VAR_SIZE] = {0};
loadString(ENV_VARIABLES, envVars);
char *var = strtok(envVars, "\t");
while (var != NULL) {
char *varValue = strchr(var, '=');
*varValue++ = 0;
*tmp = 0;
expandVars(tmp, varValue, exePath, pathLen);
debug("Set var:\t%s = %s\n", var, tmp);
SetEnvironmentVariable(var, tmp);
var = strtok(NULL, "\t");
}
*tmp = 0;
// Process priority
priority = loadInt(PRIORITY_CLASS);
// Custom process name
const BOOL setProcName = loadBool(SET_PROC_NAME)
&& strstr(lpCmdLine, "--l4j-default-proc") == NULL;
const BOOL wrapper = loadBool(WRAPPER);
appendLauncher(setProcName, exePath, pathLen, cmd);
char jarArgs[BIG_STR] = "";
loadString(hLibrary, JAR_ARGS, jarArgs);
loadString(hLibrary, JVM_ARGS, args);
if (*args) {
strcat(args, " ");
}
strcat(args, "-jar \"");
strcat(args, exePath);
strcat(args, "\"");
if (*jarArgs) {
strcat(args, " ");
strcat(args, jarArgs);
}
if (*lpCmdLine) {
strcat(args, " ");
strcat(args, lpCmdLine);
// Heap sizes
appendHeapSizes(args);
// JVM options
if (loadString(JVM_OPTIONS, tmp)) {
strcat(tmp, " ");
} else {
*tmp = 0;
}
/*
* Load additional JVM options from .l4j.ini file
* Options are separated by spaces or CRLF
* # starts an inline comment
*/
strncpy(tmp_path, exePath, strlen(exePath) - 3);
strcat(tmp_path, "l4j.ini");
long hFile;
if ((hFile = _open(tmp_path, _O_RDONLY)) != -1) {
const int jvmOptLen = strlen(tmp);
char* src = tmp + jvmOptLen;
char* dst = src;
const int len = _read(hFile, src, MAX_ARGS - jvmOptLen - BIG_STR);
BOOL copy = TRUE;
int i;
for (i = 0; i < len; i++, src++) {
if (*src == '#') {
copy = FALSE;
} else if (*src == 13 || *src == 10) {
copy = TRUE;
if (dst > tmp && *(dst - 1) != ' ') {
*dst++ = ' ';
}
} else if (copy) {
*dst++ = *src;
}
}
*dst = 0;
if (len > 0 && *(dst - 1) != ' ') {
strcat(tmp, " ");
}
_close(hFile);
}
// msgBox(cmd);
// msgBox(args);
// msgBox(workingDir);
// Expand environment %variables%
expandVars(args, tmp, exePath, pathLen);
// MainClass + Classpath or Jar
char mainClass[STR] = {0};
char jar[_MAX_PATH] = {0};
loadString(JAR, jar);
if (loadString(MAIN_CLASS, mainClass)) {
if (!loadString(CLASSPATH, tmp)) {
return FALSE;
}
char exp[MAX_ARGS] = {0};
expandVars(exp, tmp, exePath, pathLen);
strcat(args, "-classpath \"");
if (wrapper) {
appendAppClasspath(args, exePath, exp);
} else if (*jar) {
appendAppClasspath(args, jar, exp);
}
// Deal with wildcards or >> strcat(args, exp); <<
char* cp = strtok(exp, ";");
while(cp != NULL) {
debug("Add classpath:\t%s\n", cp);
if (strpbrk(cp, "*?") != NULL) {
int len = strrchr(cp, '\\') - cp + 1;
strncpy(tmp_path, cp, len);
char* filename = tmp_path + len;
*filename = 0;
struct _finddata_t c_file;
long hFile;
if ((hFile = _findfirst(cp, &c_file)) != -1L) {
do {
strcpy(filename, c_file.name);
strcat(args, tmp_path);
strcat(args, ";");
debug(" \" :\t%s\n", tmp_path);
} while (_findnext(hFile, &c_file) == 0);
}
_findclose(hFile);
} else {
strcat(args, cp);
strcat(args, ";");
}
cp = strtok(NULL, ";");
}
*(args + strlen(args) - 1) = 0;
strcat(args, "\" ");
strcat(args, mainClass);
} else if (wrapper) {
strcat(args, "-jar \"");
strcat(args, exePath);
strcat(args, "\"");
} else {
strcat(args, "-jar \"");
strncat(args, exePath, pathLen);
appendPath(args, jar);
strcat(args, "\"");
}
// Constant command line args
if (loadString(CMD_LINE, tmp)) {
strcat(args, " ");
strcat(args, tmp);
}
// Command line args
if (*lpCmdLine) {
strcpy(tmp, lpCmdLine);
char* dst;
while ((dst = strstr(tmp, "--l4j-")) != NULL) {
char* src = strchr(dst, ' ');
if (src == NULL || *(src + 1) == 0) {
*dst = 0;
} else {
strcpy(dst, src + 1);
}
}
if (*tmp) {
strcat(args, " ");
strcat(args, tmp);
}
}
debug("Launcher:\t%s\n", cmd);
debug("Launcher args:\t%s\n", args);
debug("Args length:\t%d/32768 chars\n", strlen(args));
return TRUE;
}
void closeHandles() {
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
closeLogFile();
}
DWORD execute(BOOL wait) {
/*
* Append a path to the Path environment variable
*/
BOOL appendToPathVar(const char* path) {
char chBuf[MAX_VAR_SIZE] = {0};
const int pathSize = GetEnvironmentVariable("Path", chBuf, MAX_VAR_SIZE);
if (MAX_VAR_SIZE - pathSize - 1 < strlen(path)) {
return FALSE;
}
strcat(chBuf, ";");
strcat(chBuf, path);
return SetEnvironmentVariable("Path", chBuf);
}
DWORD execute(const BOOL wait) {
STARTUPINFO si;
memset(&pi, 0, sizeof(pi));
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
DWORD dwExitCode = -1;
char cmdline[_MAX_PATH + BIG_STR] = "\"";
char cmdline[MAX_ARGS];
strcpy(cmdline, "\"");
strcat(cmdline, cmd);
strcat(cmdline, "\" ");
strcat(cmdline, args);
if (CreateProcess(NULL, cmdline, NULL, NULL,
FALSE, 0, NULL, NULL, &si, &pi)) {
TRUE, priority, NULL, NULL, &si, &pi)) {
if (wait) {
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &dwExitCode);
debug("Exit code:\t%d\n", dwExitCode);
closeHandles();
} else {
dwExitCode = 0;

View File

@ -1,24 +1,31 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2004-2005 Grzegorz Kowal
Copyright (c) 2004, 2008 Grzegorz Kowal,
Ian Roberts (jdk preference patch)
Compiled with Mingw port of GCC, Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _LAUNCH4J_HEAD__INCLUDED_
@ -36,6 +43,7 @@
#include <tchar.h>
#include <shellapi.h>
#include <direct.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <io.h>
@ -45,25 +53,61 @@
#define FOUND_JRE 1
#define FOUND_SDK 2
#define JRE_ONLY 0
#define PREFER_JRE 1
#define PREFER_JDK 2
#define JDK_ONLY 3
#define LAUNCH4J_TMP_DIR "\\launch4j-tmp\\"
#define MANIFEST ".manifest"
#define KEY_WOW64_64KEY 0x0100
#define HKEY_STR "HKEY"
#define HKEY_CLASSES_ROOT_STR "HKEY_CLASSES_ROOT"
#define HKEY_CURRENT_USER_STR "HKEY_CURRENT_USER"
#define HKEY_LOCAL_MACHINE_STR "HKEY_LOCAL_MACHINE"
#define HKEY_USERS_STR "HKEY_USERS"
#define HKEY_CURRENT_CONFIG_STR "HKEY_CURRENT_CONFIG"
#define STR 128
#define BIG_STR 1024
#define MAX_VAR_SIZE 32767
#define MAX_ARGS 32768
#define TRUE_STR "true"
#define FALSE_STR "false"
#define debug(args...) if (hLog != NULL) fprintf(hLog, ## args);
typedef void (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
FILE* openLogFile(const char* exePath, const int pathLen);
void closeLogFile();
void msgBox(const char* text);
void showJavaWebPage();
BOOL loadString(HMODULE hLibrary, int resID, char* buffer);
BOOL loadBoolString(HMODULE hLibrary, int resID);
void regSearch(HKEY hKey, char* keyName, int searchType);
BOOL findJavaHome(char* path);
void signalError();
BOOL loadString(const int resID, char* buffer);
BOOL loadBool(const int resID);
int loadInt(const int resID);
BOOL regQueryValue(const char* regPath, unsigned char* buffer,
unsigned long bufferLength);
void regSearch(const HKEY hKey, const char* keyName, const int searchType);
void regSearchWow(const char* keyName, const int searchType);
void regSearchJreSdk(const char* jreKeyName, const char* sdkKeyName,
const int jdkPreference);
BOOL findJavaHome(char* path, const int jdkPreference);
int getExePath(char* exePath);
void catJavaw(char* jrePath);
BOOL isJrePathOk(char* path);
BOOL prepare(HMODULE hLibrary, char *lpCmdLine);
void appendPath(char* basepath, const char* path);
void appendJavaw(char* jrePath);
void appendAppClasspath(char* dst, const char* src, const char* classpath);
BOOL isJrePathOk(const char* path);
BOOL expandVars(char *dst, const char *src, const char *exePath, const int pathLen);
void appendHeapSizes(char *dst);
void appendHeapSize(char *dst, const int absID, const int percentID,
const DWORD freeMemory, const char *option);
int prepare(const char *lpCmdLine);
void closeHandles();
DWORD execute(BOOL wait);
BOOL appendToPathVar(const char* path);
DWORD execute(const BOOL wait);
#endif // _LAUNCH4J_HEAD__INCLUDED_

View File

@ -1,43 +1,71 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2004-2005 Grzegorz Kowal
Copyright (c) 2004, 2008 Grzegorz Kowal
Ian Roberts (jdk preference patch)
Compiled with Mingw port of GCC, Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// ICON
#define APP_ICON 1
#define APP_ICON 1
// BITMAP
#define SPLASH_BITMAP 1
#define SPLASH_BITMAP 1
// RCDATA
#define JRE_PATH 1
#define JAVA_MIN_VER 2
#define JAVA_MAX_VER 3
#define SHOW_SPLASH 4
#define SPLASH_WAITS_FOR_WINDOW 5
#define SPLASH_TIMEOUT 6
#define SPLASH_TIMEOUT_ERR 7
#define CHDIR 8
#define SET_PROC_NAME 9
#define ERR_TITLE 10
#define GUI_HEADER_STAYS_ALIVE 11
#define JVM_ARGS 12
#define JAR_ARGS 13
#define JRE_PATH 1
#define JAVA_MIN_VER 2
#define JAVA_MAX_VER 3
#define SHOW_SPLASH 4
#define SPLASH_WAITS_FOR_WINDOW 5
#define SPLASH_TIMEOUT 6
#define SPLASH_TIMEOUT_ERR 7
#define CHDIR 8
#define SET_PROC_NAME 9
#define ERR_TITLE 10
#define GUI_HEADER_STAYS_ALIVE 11
#define JVM_OPTIONS 12
#define CMD_LINE 13
#define JAR 14
#define MAIN_CLASS 15
#define CLASSPATH 16
#define WRAPPER 17
#define JDK_PREFERENCE 18
#define ENV_VARIABLES 19
#define PRIORITY_CLASS 20
#define DOWNLOAD_URL 21
#define SUPPORT_URL 22
#define MUTEX_NAME 23
#define INSTANCE_WINDOW_TITLE 24
#define INITIAL_HEAP_SIZE 25
#define INITIAL_HEAP_PERCENT 26
#define MAX_HEAP_SIZE 27
#define MAX_HEAP_PERCENT 28
#define STARTUP_ERR 101
#define BUNDLED_JRE_ERR 102
#define JRE_VERSION_ERR 103
#define LAUNCHER_ERR 104
#define INSTANCE_ALREADY_EXISTS_MSG 105

Binary file not shown.

View File

@ -1,7 +1,8 @@
The BSD License for the JGoodies Looks
======================================
Copyright (c) 2003 JGoodies Karsten Lentzsch. All rights reserved.
The BSD License for the JGoodies Looks
======================================
Copyright (c) 2001-2007 JGoodies Karsten Lentzsch. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,27 @@
(BSD Style License)
Copyright (c) 2003-2004, Joe Walnes
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer. 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.
Neither the name of XStream 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 OWNER 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.
(BSD Style License)
Copyright (c) 2003-2004, Joe Walnes
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer. 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.
Neither the name of XStream 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 OWNER 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.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
<!-- <requestedExecutionLevel level="highestAvailable" uiAccess="false"/> -->
<!-- <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> -->
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>

View File

@ -1,35 +0,0 @@
Launch4j Cross-platform java application wrapper for creating windows native executables.
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Head subproject (the code which is attached to the wrapped jars) is
licensed under the GNU Lesser General Public License.
Launch4j may be used for wrapping closed source, commercial applications.
The following projects are used by Launch4j...
MinGW binutils (http://www.mingw.org/)
Commons BeanUtils (http://jakarta.apache.org/commons/beanutils/)
Commons Logging (http://jakarta.apache.org/commons/logging/)
XStream (http://xstream.codehaus.org/)
JGoodies Forms (http://www.jgoodies.com/freeware/forms/)
JGoodies Looks (http://www.jgoodies.com/freeware/looks/)
Foxtrot (http://foxtrot.sourceforge.net/)
Nuvola Icon Theme (http://www.icon-king.com)
Forms were created using Abeille Forms Designer (https://abeille.dev.java.net/)
This product includes software developed by the Apache Software Foundation (http://www.apache.org/).

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

View File

@ -0,0 +1,2 @@
versionNumber=3.0.1.0
version=3.0.1

View File

@ -1,189 +1,207 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sf.launch4j.binding.InvariantViolationException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Builder {
private final Log _log;
public Builder(Log log) {
_log = log;
}
/**
* @return Output file path.
*/
public File build() throws BuilderException {
final Config c = ConfigPersister.getInstance().getConfig();
try {
c.validate();
} catch (InvariantViolationException e) {
throw new BuilderException(e.getMessage());
}
File rc = null;
File ro = null;
File outfile = null;
FileInputStream is = null;
FileOutputStream os = null;
final RcBuilder rcb = new RcBuilder();
try {
String basedir = Util.getJarBasedir();
if (basedir == null) {
basedir = ".";
}
rc = rcb.build(c);
ro = File.createTempFile("launch4j", "o");
outfile = ConfigPersister.getInstance().getOutputFile();
Cmd resCmd = new Cmd(basedir);
resCmd.addExe("/bin/windres")
.add(Util.WINDOWS_OS ? "--preprocessor=type" : "--preprocessor=cat")
.add("-J rc -O coff -F pe-i386")
.add(rc.getPath())
.add(ro.getPath());
_log.append("Compiling resources");
Util.exec(resCmd.toString(), _log);
Cmd ldCmd = new Cmd(basedir);
ldCmd.addExe("/bin/ld")
.add("-mi386pe")
.add("--oformat pei-i386")
.add((c.getHeaderType() == Config.GUI_HEADER)
? "--subsystem windows" : "--subsystem console")
.add("-s") // strip symbols
.addFile("/w32api/crt2.o")
.addFile((c.getHeaderType() == Config.GUI_HEADER)
? "/head/guihead.o" : "/head/consolehead.o")
.addFile("/head/head.o")
.addAbsFile(ro.getPath())
.addFile("/w32api/libmingw32.a")
.addFile("/w32api/libgcc.a")
.addFile("/w32api/libmsvcrt.a")
.addFile("/w32api/libkernel32.a")
.addFile("/w32api/libuser32.a")
.addFile("/w32api/libadvapi32.a")
.addFile("/w32api/libshell32.a")
.add("-o")
.addAbsFile(outfile.getPath());
_log.append("Linking");
Util.exec(ldCmd.toString(), _log);
_log.append("Wrapping");
int len;
byte[] buffer = new byte[1024];
is = new FileInputStream(
Util.getAbsoluteFile(ConfigPersister.getInstance().getConfigPath(), c.getJar()));
os = new FileOutputStream(outfile, true);
while ((len = is.read(buffer)) > 0) {
os.write(buffer, 0, len);
}
_log.append("Successfully created " + outfile.getPath());
return outfile;
} catch (IOException e) {
Util.delete(outfile);
_log.append(e.getMessage());
throw new BuilderException(e);
} catch (ExecException e) {
Util.delete(outfile);
String msg = e.getMessage();
if (msg != null && msg.indexOf("windres") != -1) {
_log.append("Generated resource file...\n");
_log.append(rcb.getContent());
}
throw new BuilderException(e);
} finally {
Util.close(is);
Util.close(os);
Util.delete(rc);
Util.delete(ro);
}
}
}
class Cmd {
private final StringBuffer _sb = new StringBuffer();
private final String _basedir;
private final boolean _quote;
public Cmd(String basedir) {
_basedir = basedir;
_quote = basedir.indexOf(' ') != -1;
}
public Cmd add(String s) {
space();
_sb.append(s);
return this;
}
public Cmd addAbsFile(String file) {
space();
boolean quote = file.indexOf(' ') != -1;
if (quote) {
_sb.append('"');
}
_sb.append(file);
if (quote) {
_sb.append('"');
}
return this;
}
public Cmd addFile(String file) {
space();
if (_quote) {
_sb.append('"');
}
_sb.append(_basedir);
_sb.append(file);
if (_quote) {
_sb.append('"');
}
return this;
}
public Cmd addExe(String file) {
return addFile(Util.WINDOWS_OS ? file + ".exe" : file);
}
private void space() {
if (_sb.length() > 0) {
_sb.append(' ');
}
}
public String toString() {
return _sb.toString();
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import net.sf.launch4j.binding.InvariantViolationException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Builder {
private final Log _log;
private final File _basedir;
public Builder(Log log) {
_log = log;
_basedir = Util.getJarBasedir();
}
public Builder(Log log, File basedir) {
_log = log;
_basedir = basedir;
}
/**
* @return Output file path.
*/
public File build() throws BuilderException {
final Config c = ConfigPersister.getInstance().getConfig();
try {
c.validate();
} catch (InvariantViolationException e) {
throw new BuilderException(e.getMessage());
}
File rc = null;
File ro = null;
File outfile = null;
FileInputStream is = null;
FileOutputStream os = null;
final RcBuilder rcb = new RcBuilder();
try {
rc = rcb.build(c);
ro = Util.createTempFile("o");
outfile = ConfigPersister.getInstance().getOutputFile();
Cmd resCmd = new Cmd(_basedir);
resCmd.addExe("windres")
.add(Util.WINDOWS_OS ? "--preprocessor=type" : "--preprocessor=cat")
.add("-J rc -O coff -F pe-i386")
.addAbsFile(rc)
.addAbsFile(ro);
_log.append(Messages.getString("Builder.compiling.resources"));
resCmd.exec(_log);
Cmd ldCmd = new Cmd(_basedir);
ldCmd.addExe("ld")
.add("-mi386pe")
.add("--oformat pei-i386")
.add((c.getHeaderType().equals(Config.GUI_HEADER))
? "--subsystem windows" : "--subsystem console")
.add("-s") // strip symbols
.addFiles(c.getHeaderObjects())
.addAbsFile(ro)
.addFiles(c.getLibs())
.add("-o")
.addAbsFile(outfile);
_log.append(Messages.getString("Builder.linking"));
ldCmd.exec(_log);
if (!c.isDontWrapJar()) {
_log.append(Messages.getString("Builder.wrapping"));
int len;
byte[] buffer = new byte[1024];
is = new FileInputStream(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), c.getJar()));
os = new FileOutputStream(outfile, true);
while ((len = is.read(buffer)) > 0) {
os.write(buffer, 0, len);
}
}
_log.append(Messages.getString("Builder.success") + outfile.getPath());
return outfile;
} catch (IOException e) {
Util.delete(outfile);
_log.append(e.getMessage());
throw new BuilderException(e);
} catch (ExecException e) {
Util.delete(outfile);
String msg = e.getMessage();
if (msg != null && msg.indexOf("windres") != -1) {
if (e.getErrLine() != -1) {
_log.append(Messages.getString("Builder.line.has.errors",
String.valueOf(e.getErrLine())));
_log.append(rcb.getLine(e.getErrLine()));
} else {
_log.append(Messages.getString("Builder.generated.resource.file"));
_log.append(rcb.getContent());
}
}
throw new BuilderException(e);
} finally {
Util.close(is);
Util.close(os);
Util.delete(rc);
Util.delete(ro);
}
}
}
class Cmd {
private final List _cmd = new ArrayList();
private final File _basedir;
private final File _bindir;
public Cmd(File basedir) {
_basedir = basedir;
String path = System.getProperty("launch4j.bindir");
if (path == null) {
_bindir = new File(basedir, "bin");
} else {
File bindir = new File(path);
_bindir = bindir.isAbsolute() ? bindir : new File(basedir, path);
}
}
public Cmd add(String s) {
StringTokenizer st = new StringTokenizer(s);
while (st.hasMoreTokens()) {
_cmd.add(st.nextToken());
}
return this;
}
public Cmd addAbsFile(File file) {
_cmd.add(file.getPath());
return this;
}
public Cmd addFile(String pathname) {
_cmd.add(new File(_basedir, pathname).getPath());
return this;
}
public Cmd addExe(String pathname) {
if (Util.WINDOWS_OS) {
pathname += ".exe";
}
_cmd.add(new File(_bindir, pathname).getPath());
return this;
}
public Cmd addFiles(List files) {
for (Iterator iter = files.iterator(); iter.hasNext();) {
addFile((String) iter.next());
}
return this;
}
public void exec(Log log) throws ExecException {
String[] cmd = (String[]) _cmd.toArray(new String[_cmd.size()]);
Util.exec(cmd, log);
}
}

View File

@ -1,38 +1,52 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 13, 2005
*/
package net.sf.launch4j;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class BuilderException extends Exception {
public BuilderException() {}
public BuilderException(Throwable t) {
super(t);
}
public BuilderException(String msg) {
super(msg);
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 13, 2005
*/
package net.sf.launch4j;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class BuilderException extends Exception {
public BuilderException() {}
public BuilderException(Throwable t) {
super(t);
}
public BuilderException(String msg) {
super(msg);
}
}

View File

@ -1,38 +1,66 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 14, 2005
*/
package net.sf.launch4j;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ExecException extends Exception {
public ExecException() {}
public ExecException(Throwable t) {
super(t);
}
public ExecException(String msg) {
super(msg);
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 14, 2005
*/
package net.sf.launch4j;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ExecException extends Exception {
private final int _errLine;
public ExecException(Throwable t, int errLine) {
super(t);
_errLine = errLine;
}
public ExecException(Throwable t) {
this(t, -1);
}
public ExecException(String msg, int errLine) {
super(msg);
_errLine = errLine;
}
public ExecException(String msg) {
this(msg, -1);
}
public int getErrLine() {
return _errLine;
}
}

View File

@ -1,62 +1,76 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2004-01-15
*/
package net.sf.launch4j;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public class FileChooserFilter extends FileFilter {
String _description;
String[] _extensions;
public FileChooserFilter(String description, String extension) {
_description = description;
_extensions = new String[] {extension};
}
public FileChooserFilter(String description, String[] extensions) {
_description = description;
_extensions = extensions;
}
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String ext = Util.getExtension(f);
for (int i = 0; i < _extensions.length; i++) {
if (ext.toLowerCase().equals(_extensions[i].toLowerCase())) {
return true;
}
}
return false;
}
public String getDescription() {
return _description;
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on 2004-01-15
*/
package net.sf.launch4j;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public class FileChooserFilter extends FileFilter {
String _description;
String[] _extensions;
public FileChooserFilter(String description, String extension) {
_description = description;
_extensions = new String[] {extension};
}
public FileChooserFilter(String description, String[] extensions) {
_description = description;
_extensions = extensions;
}
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String ext = Util.getExtension(f);
for (int i = 0; i < _extensions.length; i++) {
if (ext.toLowerCase().equals(_extensions[i].toLowerCase())) {
return true;
}
}
return false;
}
public String getDescription() {
return _description;
}
}

View File

@ -1,21 +0,0 @@
/*
* Created on Jun 4, 2005
*/
package net.sf.launch4j;
/**
* This class allows launch4j to act as a launcher instead of a wrapper.
* It's useful on Windows because an application cannot be a GUI and console one
* at the same time. So there are two launchers that start launch4j.jar: launch4j.exe
* for GUI mode and launch4jc.exe for console operation.
* The Launcher class is packed into an executable jar that contains nothing else but
* the manifest with Class-Path attribute defined as in the application jar. The jar
* is wrapped with launch4j.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Launcher {
public static void main(String[] args) {
Main.main(args);
}
}

View File

@ -1,91 +1,105 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 12, 2005
*/
package net.sf.launch4j;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public abstract class Log {
private static final Log _consoleLog = new ConsoleLog();
private static final Log _antLog = new AntLog();
public abstract void clear();
public abstract void append(String line);
public static Log getConsoleLog() {
return _consoleLog;
}
public static Log getAntLog() {
return _antLog;
}
public static Log getSwingLog(JTextArea textArea) {
return new SwingLog(textArea);
}
}
class ConsoleLog extends Log {
public void clear() {
System.out.println("\n");
}
public void append(String line) {
System.out.println("launch4j: " + line);
}
}
class AntLog extends Log {
public void clear() {
System.out.println("\n");
}
public void append(String line) {
System.out.println(line);
}
}
class SwingLog extends Log {
private final JTextArea _textArea;
public SwingLog(JTextArea textArea) {
_textArea = textArea;
}
public void clear() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_textArea.setText("");
}});
}
public void append(final String line) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_textArea.append(line + "\n");
}});
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 12, 2005
*/
package net.sf.launch4j;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public abstract class Log {
private static final Log _consoleLog = new ConsoleLog();
private static final Log _antLog = new AntLog();
public abstract void clear();
public abstract void append(String line);
public static Log getConsoleLog() {
return _consoleLog;
}
public static Log getAntLog() {
return _antLog;
}
public static Log getSwingLog(JTextArea textArea) {
return new SwingLog(textArea);
}
}
class ConsoleLog extends Log {
public void clear() {
System.out.println("\n");
}
public void append(String line) {
System.out.println("launch4j: " + line);
}
}
class AntLog extends Log {
public void clear() {
System.out.println("\n");
}
public void append(String line) {
System.out.println(line);
}
}
class SwingLog extends Log {
private final JTextArea _textArea;
public SwingLog(JTextArea textArea) {
_textArea = textArea;
}
public void clear() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_textArea.setText("");
}});
}
public void append(final String line) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_textArea.append(line + "\n");
}});
}
}

View File

@ -1,62 +1,99 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 21, 2005
*/
package net.sf.launch4j;
import java.io.File;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.ConfigPersisterException;
import net.sf.launch4j.formimpl.MainFrame;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Main {
public static final String PROGRAM_NAME = "launch4j 2.0.RC3";
public static final String PROGRAM_DESCRIPTION = PROGRAM_NAME +
" :: Cross-platform Java application wrapper for creating Windows native executables\n" +
"Copyright (C) 2005 Grzegorz Kowal\n" +
"launch4j comes with ABSOLUTELY NO WARRANTY\n" +
"This is free software, licensed under the GNU General Public License.\n" +
"This product includes software developed by the Apache Software Foundation (http://www.apache.org/).\n\n";
public static void main(String[] args) {
try {
if (args.length == 0) {
ConfigPersister.getInstance().createBlank();
MainFrame.createInstance();
} else if (args.length == 1 && !args[0].startsWith("-")) {
ConfigPersister.getInstance().load(new File(args[0]));
Builder b = new Builder(Log.getConsoleLog());
b.build();
} else {
System.out.println(PROGRAM_DESCRIPTION + "usage: launch4j config.xml");
}
} catch (ConfigPersisterException e) {
Log.getConsoleLog().append(e.getMessage());
} catch (BuilderException e) {
Log.getConsoleLog().append(e.getMessage());
}
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2008 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Apr 21, 2005
*/
package net.sf.launch4j;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.formimpl.MainFrame;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Main {
private static String _name;
private static String _description;
public static void main(String[] args) {
try {
Properties props = new Properties();
InputStream in = Main.class.getClassLoader()
.getResourceAsStream("launch4j.properties");
props.load(in);
in.close();
setDescription(props);
if (args.length == 0) {
ConfigPersister.getInstance().createBlank();
MainFrame.createInstance();
} else if (args.length == 1 && !args[0].startsWith("-")) {
ConfigPersister.getInstance().load(new File(args[0]));
Builder b = new Builder(Log.getConsoleLog());
b.build();
} else {
System.out.println(_description
+ Messages.getString("Main.usage")
+ ": launch4j config.xml");
}
} catch (Exception e) {
Log.getConsoleLog().append(e.getMessage());
}
}
public static String getName() {
return _name;
}
public static String getDescription() {
return _description;
}
private static void setDescription(Properties props) {
_name = "Launch4j " + props.getProperty("version");
_description = _name +
" (http://launch4j.sourceforge.net/)\n" +
"Cross-platform Java application wrapper" +
" for creating Windows native executables.\n\n" +
"Copyright (C) 2004, 2008 Grzegorz Kowal\n\n" +
"Launch4j comes with ABSOLUTELY NO WARRANTY.\n" +
"This is free software, licensed under the BSD License.\n" +
"This product includes software developed by the Apache Software Foundation" +
" (http://www.apache.org/).";
}
}

View File

@ -0,0 +1,78 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "net.sf.launch4j.messages";
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private static final MessageFormat FORMATTER = new MessageFormat("");
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
public static String getString(String key, String arg0) {
return getString(key, new Object[] {arg0});
}
public static String getString(String key, String arg0, String arg1) {
return getString(key, new Object[] {arg0, arg1});
}
public static String getString(String key, String arg0, String arg1, String arg2) {
return getString(key, new Object[] {arg0, arg1, arg2});
}
public static String getString(String key, Object[] args) {
try {
FORMATTER.applyPattern(RESOURCE_BUNDLE.getString(key));
return FORMATTER.format(args);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View File

@ -1,57 +1,71 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
//import net.sf.launch4j.config.Config;
//import org.apache.commons.cli.CommandLine;
//import org.apache.commons.cli.CommandLineParser;
//import org.apache.commons.cli.HelpFormatter;
//import org.apache.commons.cli.Options;
//import org.apache.commons.cli.ParseException;
//import org.apache.commons.cli.PosixParser;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class OptionParser {
// private final Options _options;
//
// public OptionParser() {
// _options = new Options();
// _options.addOption("h", "header", true, "header");
// }
//
// public Config parse(Config c, String[] args) throws ParseException {
// CommandLineParser parser = new PosixParser();
// CommandLine cl = parser.parse(_options, args);
// c.setJar(getFile(props, Config.JAR));
// c.setOutfile(getFile(props, Config.OUTFILE));
// }
//
// public void printHelp() {
// HelpFormatter formatter = new HelpFormatter();
// formatter.printHelp("launch4j", _options);
// }
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
//import net.sf.launch4j.config.Config;
//import org.apache.commons.cli.CommandLine;
//import org.apache.commons.cli.CommandLineParser;
//import org.apache.commons.cli.HelpFormatter;
//import org.apache.commons.cli.Options;
//import org.apache.commons.cli.ParseException;
//import org.apache.commons.cli.PosixParser;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class OptionParser {
// private final Options _options;
//
// public OptionParser() {
// _options = new Options();
// _options.addOption("h", "header", true, "header");
// }
//
// public Config parse(Config c, String[] args) throws ParseException {
// CommandLineParser parser = new PosixParser();
// CommandLine cl = parser.parse(_options, args);
// c.setJar(getFile(props, Config.JAR));
// c.setOutfile(getFile(props, Config.OUTFILE));
// }
//
// public void printHelp() {
// HelpFormatter formatter = new HelpFormatter();
// formatter.printHelp("launch4j", _options);
// }
}

View File

@ -1,230 +1,340 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.Jre;
import net.sf.launch4j.config.Splash;
import net.sf.launch4j.config.VersionInfo;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class RcBuilder {
// winnt.h
public static final int LANG_NEUTRAL = 0;
public static final int SUBLANG_NEUTRAL = 0;
public static final int SUBLANG_DEFAULT = 1;
public static final int SUBLANG_SYS_DEFAULT = 2;
// ICON
public static final int APP_ICON = 1;
// BITMAP
public static final int SPLASH_BITMAP = 1;
// RCDATA
public static final int JRE_PATH = 1;
public static final int JAVA_MIN_VER = 2;
public static final int JAVA_MAX_VER = 3;
public static final int SHOW_SPLASH = 4;
public static final int SPLASH_WAITS_FOR_WINDOW = 5;
public static final int SPLASH_TIMEOUT = 6;
public static final int SPLASH_TIMEOUT_ERR = 7;
public static final int CHDIR = 8;
public static final int SET_PROC_NAME = 9;
public static final int ERR_TITLE = 10;
public static final int GUI_HEADER_STAYS_ALIVE = 11;
public static final int JVM_ARGS = 12;
public static final int JAR_ARGS = 13;
private final StringBuffer _sb = new StringBuffer();
public String getContent() {
return _sb.toString();
}
public File build(Config c) throws IOException {
_sb.append("LANGUAGE ");
_sb.append(LANG_NEUTRAL);
_sb.append(", ");
_sb.append(SUBLANG_DEFAULT);
_sb.append('\n');
addVersionInfo(c.getVersionInfo());
addJre(c.getJre());
addIcon(APP_ICON, c.getIcon());
addText(ERR_TITLE, c.getErrTitle());
addText(JAR_ARGS, c.getJarArgs());
addWindowsPath(CHDIR, c.getChdir());
addTrue(SET_PROC_NAME, c.isCustomProcName());
addTrue(GUI_HEADER_STAYS_ALIVE, c.isStayAlive());
addSplash(c.getSplash());
File f = File.createTempFile("launch4j", "rc");
BufferedWriter w = new BufferedWriter(new FileWriter(f));
w.write(_sb.toString());
w.close();
return f;
}
private void addVersionInfo(VersionInfo v) {
if (v == null) {
return;
}
_sb.append("1 VERSIONINFO\n");
_sb.append("FILEVERSION ");
_sb.append(v.getFileVersion().replaceAll("\\.", ", "));
_sb.append("\nPRODUCTVERSION ");
_sb.append(v.getProductVersion().replaceAll("\\.", ", "));
_sb.append("\nFILEFLAGSMASK 0\n" +
"FILEOS 0x40000\n" +
"FILETYPE 1\n" +
"{\n" +
" BLOCK \"StringFileInfo\"\n" +
" {\n" +
" BLOCK \"040904E4\"\n" + // English
" {\n");
addVerBlockValue("CompanyName", v.getCompanyName());
addVerBlockValue("FileDescription", v.getFileDescription());
addVerBlockValue("FileVersion", v.getTxtFileVersion());
addVerBlockValue("InternalName", v.getInternalName());
addVerBlockValue("LegalCopyright", v.getCopyright());
addVerBlockValue("OriginalFilename", v.getOriginalFilename());
addVerBlockValue("ProductName", v.getProductName());
addVerBlockValue("ProductVersion", v.getTxtProductVersion());
_sb.append(" }\n }\n}\n");
}
private void addJre(Jre jre) {
addWindowsPath(JRE_PATH, jre.getPath());
addText(JAVA_MIN_VER, jre.getMinVersion());
addText(JAVA_MAX_VER, jre.getMaxVersion());
StringBuffer jvmArgs = new StringBuffer();
if (jre.getInitialHeapSize() > 0) {
jvmArgs.append("-Xms");
jvmArgs.append(jre.getInitialHeapSize());
jvmArgs.append('m');
}
if (jre.getMaxHeapSize() > 0) {
addSpace(jvmArgs);
jvmArgs.append("-Xmx");
jvmArgs.append(jre.getMaxHeapSize());
jvmArgs.append('m');
}
if (jre.getArgs() != null && jre.getArgs().length() > 0) {
addSpace(jvmArgs);
jvmArgs.append(jre.getArgs().replaceAll("\n", " "));
}
addText(JVM_ARGS, jvmArgs.toString());
}
private void addSplash(Splash splash) {
if (splash == null) {
return;
}
addTrue(SHOW_SPLASH, true);
addTrue(SPLASH_WAITS_FOR_WINDOW, splash.getWaitForWindow());
addText(SPLASH_TIMEOUT, String.valueOf(splash.getTimeout()));
addTrue(SPLASH_TIMEOUT_ERR, splash.isTimeoutErr());
addBitmap(SPLASH_BITMAP, splash.getFile());
}
private void addText(int id, String text) {
if (text == null || text.length() == 0) {
return;
}
_sb.append(id);
_sb.append(" RCDATA BEGIN \"");
_sb.append(text);
_sb.append("\\0\" END\n");
}
/**
* Stores path in Windows format with '\' separators.
*/
private void addWindowsPath(int id, String path) {
if (path == null || path.equals("")) {
return;
}
_sb.append(id);
_sb.append(" RCDATA BEGIN \"");
_sb.append(path.replaceAll("\\\\", "\\\\\\\\")
.replaceAll("/", "\\\\\\\\"));
_sb.append("\\0\" END\n");
}
private void addTrue(int id, boolean value) {
if (value) {
addText(id, "true");
}
}
private void addIcon(int id, File icon) {
if (icon == null || icon.getPath().equals("")) {
return;
}
_sb.append(id);
_sb.append(" ICON DISCARDABLE \"");
_sb.append(getPath(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), icon)));
_sb.append("\"\n");
}
private void addBitmap(int id, File bitmap) {
if (bitmap == null) {
return;
}
_sb.append(id);
_sb.append(" BITMAP \"");
_sb.append(getPath(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), bitmap)));
_sb.append("\"\n");
}
private String getPath(File f) {
return f.getPath().replaceAll("\\\\", "\\\\\\\\");
}
private void addSpace(StringBuffer sb) {
int len = sb.length();
if (len-- > 0 && sb.charAt(len) != ' ') {
sb.append(' ');
}
}
private void addVerBlockValue(String key, String value) {
_sb.append(" VALUE \"");
_sb.append(key);
_sb.append("\", \"");
if (value != null) {
_sb.append(value);
}
_sb.append("\"\n");
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.Jre;
import net.sf.launch4j.config.Msg;
import net.sf.launch4j.config.Splash;
import net.sf.launch4j.config.VersionInfo;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class RcBuilder {
// winnt.h
public static final int LANG_NEUTRAL = 0;
public static final int SUBLANG_NEUTRAL = 0;
public static final int SUBLANG_DEFAULT = 1;
public static final int SUBLANG_SYS_DEFAULT = 2;
// MANIFEST
public static final int MANIFEST = 1;
// ICON
public static final int APP_ICON = 1;
// BITMAP
public static final int SPLASH_BITMAP = 1;
// RCDATA
public static final int JRE_PATH = 1;
public static final int JAVA_MIN_VER = 2;
public static final int JAVA_MAX_VER = 3;
public static final int SHOW_SPLASH = 4;
public static final int SPLASH_WAITS_FOR_WINDOW = 5;
public static final int SPLASH_TIMEOUT = 6;
public static final int SPLASH_TIMEOUT_ERR = 7;
public static final int CHDIR = 8;
public static final int SET_PROC_NAME = 9;
public static final int ERR_TITLE = 10;
public static final int GUI_HEADER_STAYS_ALIVE = 11;
public static final int JVM_OPTIONS = 12;
public static final int CMD_LINE = 13;
public static final int JAR = 14;
public static final int MAIN_CLASS = 15;
public static final int CLASSPATH = 16;
public static final int WRAPPER = 17;
public static final int JDK_PREFERENCE = 18;
public static final int ENV_VARIABLES = 19;
public static final int PRIORITY_CLASS = 20;
public static final int DOWNLOAD_URL = 21;
public static final int SUPPORT_URL = 22;
public static final int MUTEX_NAME = 23;
public static final int INSTANCE_WINDOW_TITLE = 24;
public static final int INITIAL_HEAP_SIZE = 25;
public static final int INITIAL_HEAP_PERCENT = 26;
public static final int MAX_HEAP_SIZE = 27;
public static final int MAX_HEAP_PERCENT = 28;
public static final int STARTUP_ERR = 101;
public static final int BUNDLED_JRE_ERR = 102;
public static final int JRE_VERSION_ERR = 103;
public static final int LAUNCHER_ERR = 104;
public static final int INSTANCE_ALREADY_EXISTS_MSG = 105;
private final StringBuffer _sb = new StringBuffer();
public String getContent() {
return _sb.toString();
}
public String getLine(int line) {
return _sb.toString().split("\n")[line - 1];
}
public File build(Config c) throws IOException {
_sb.append("LANGUAGE ");
_sb.append(LANG_NEUTRAL);
_sb.append(", ");
_sb.append(SUBLANG_DEFAULT);
_sb.append('\n');
addVersionInfo(c.getVersionInfo());
addJre(c.getJre());
addManifest(MANIFEST, c.getManifest());
addIcon(APP_ICON, c.getIcon());
addText(ERR_TITLE, c.getErrTitle());
addText(DOWNLOAD_URL, c.getDownloadUrl());
addText(SUPPORT_URL, c.getSupportUrl());
addText(CMD_LINE, c.getCmdLine());
addWindowsPath(CHDIR, c.getChdir());
addText(PRIORITY_CLASS, String.valueOf(c.getPriorityClass()));
addTrue(SET_PROC_NAME, c.isCustomProcName());
addTrue(GUI_HEADER_STAYS_ALIVE, c.isStayAlive());
addSplash(c.getSplash());
addMessages(c);
if (c.getSingleInstance() != null) {
addText(MUTEX_NAME, c.getSingleInstance().getMutexName());
addText(INSTANCE_WINDOW_TITLE, c.getSingleInstance().getWindowTitle());
}
if (c.getVariables() != null && !c.getVariables().isEmpty()) {
StringBuffer vars = new StringBuffer();
append(vars, c.getVariables(), "\t");
addText(ENV_VARIABLES, vars.toString());
}
// MAIN_CLASS / JAR
addTrue(WRAPPER, !c.isDontWrapJar());
if (c.getClassPath() != null) {
addText(MAIN_CLASS, c.getClassPath().getMainClass());
addWindowsPath(CLASSPATH, c.getClassPath().getPathsString());
}
if (c.isDontWrapJar() && c.getJar() != null) {
addWindowsPath(JAR, c.getJar().getPath());
}
File f = Util.createTempFile("rc");
BufferedWriter w = new BufferedWriter(new FileWriter(f));
w.write(_sb.toString());
w.close();
return f;
}
private void addVersionInfo(VersionInfo v) {
if (v == null) {
return;
}
_sb.append("1 VERSIONINFO\n");
_sb.append("FILEVERSION ");
_sb.append(v.getFileVersion().replaceAll("\\.", ", "));
_sb.append("\nPRODUCTVERSION ");
_sb.append(v.getProductVersion().replaceAll("\\.", ", "));
_sb.append("\nFILEFLAGSMASK 0\n" +
"FILEOS 0x40000\n" +
"FILETYPE 1\n" +
"{\n" +
" BLOCK \"StringFileInfo\"\n" +
" {\n" +
" BLOCK \"040904E4\"\n" + // English
" {\n");
addVerBlockValue("CompanyName", v.getCompanyName());
addVerBlockValue("FileDescription", v.getFileDescription());
addVerBlockValue("FileVersion", v.getTxtFileVersion());
addVerBlockValue("InternalName", v.getInternalName());
addVerBlockValue("LegalCopyright", v.getCopyright());
addVerBlockValue("OriginalFilename", v.getOriginalFilename());
addVerBlockValue("ProductName", v.getProductName());
addVerBlockValue("ProductVersion", v.getTxtProductVersion());
_sb.append(" }\n }\nBLOCK \"VarFileInfo\"\n{\nVALUE \"Translation\", 0x0409, 0x04E4\n}\n}");
}
private void addJre(Jre jre) {
addWindowsPath(JRE_PATH, jre.getPath());
addText(JAVA_MIN_VER, jre.getMinVersion());
addText(JAVA_MAX_VER, jre.getMaxVersion());
addText(JDK_PREFERENCE, String.valueOf(jre.getJdkPreferenceIndex()));
addInteger(INITIAL_HEAP_SIZE, jre.getInitialHeapSize());
addInteger(INITIAL_HEAP_PERCENT, jre.getInitialHeapPercent());
addInteger(MAX_HEAP_SIZE, jre.getMaxHeapSize());
addInteger(MAX_HEAP_PERCENT, jre.getMaxHeapPercent());
StringBuffer options = new StringBuffer();
if (jre.getOptions() != null && !jre.getOptions().isEmpty()) {
addSpace(options);
append(options, jre.getOptions(), " ");
}
addText(JVM_OPTIONS, options.toString());
}
private void addSplash(Splash splash) {
if (splash == null) {
return;
}
addTrue(SHOW_SPLASH, true);
addTrue(SPLASH_WAITS_FOR_WINDOW, splash.getWaitForWindow());
addText(SPLASH_TIMEOUT, String.valueOf(splash.getTimeout()));
addTrue(SPLASH_TIMEOUT_ERR, splash.isTimeoutErr());
addBitmap(SPLASH_BITMAP, splash.getFile());
}
private void addMessages(Config c) {
Msg msg = c.getMessages();
if (msg == null) {
msg = new Msg();
}
addText(STARTUP_ERR, msg.getStartupErr());
addText(BUNDLED_JRE_ERR, msg.getBundledJreErr());
addText(JRE_VERSION_ERR, msg.getJreVersionErr());
addText(LAUNCHER_ERR, msg.getLauncherErr());
if (c.getSingleInstance() != null) {
addText(INSTANCE_ALREADY_EXISTS_MSG, msg.getInstanceAlreadyExistsMsg());
}
}
private void append(StringBuffer sb, List list, String separator) {
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i));
if (i < list.size() - 1) {
sb.append(separator);
}
}
}
private void addText(int id, String text) {
if (text == null || text.equals("")) {
return;
}
_sb.append(id);
_sb.append(" RCDATA BEGIN \"");
_sb.append(escape(text));
_sb.append("\\0\" END\n");
}
private void addTrue(int id, boolean value) {
if (value) {
addText(id, "true");
}
}
private void addInteger(int id, Integer value) {
if (value != null) {
addText(id, value.toString());
}
}
/**
* Stores path in Windows format with '\' separators.
*/
private void addWindowsPath(int id, String path) {
if (path == null || path.equals("")) {
return;
}
_sb.append(id);
_sb.append(" RCDATA BEGIN \"");
_sb.append(path.replaceAll("\\\\", "\\\\\\\\")
.replaceAll("/", "\\\\\\\\"));
_sb.append("\\0\" END\n");
}
private void addManifest(int id, File manifest) {
if (manifest == null || manifest.getPath().equals("")) {
return;
}
_sb.append(id);
_sb.append(" 24 \"");
_sb.append(getPath(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), manifest)));
_sb.append("\"\n");
}
private void addIcon(int id, File icon) {
if (icon == null || icon.getPath().equals("")) {
return;
}
_sb.append(id);
_sb.append(" ICON DISCARDABLE \"");
_sb.append(getPath(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), icon)));
_sb.append("\"\n");
}
private void addBitmap(int id, File bitmap) {
if (bitmap == null) {
return;
}
_sb.append(id);
_sb.append(" BITMAP \"");
_sb.append(getPath(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), bitmap)));
_sb.append("\"\n");
}
private String getPath(File f) {
return f.getPath().replaceAll("\\\\", "\\\\\\\\");
}
private void addSpace(StringBuffer sb) {
int len = sb.length();
if (len-- > 0 && sb.charAt(len) != ' ') {
sb.append(' ');
}
}
private void addVerBlockValue(String key, String value) {
_sb.append(" VALUE \"");
_sb.append(key);
_sb.append("\", \"");
if (value != null) {
_sb.append(escape(value));
}
_sb.append("\"\n");
}
private String escape(String text) {
return text.replaceAll("\"", "\"\"");
}
}

View File

@ -1,152 +1,197 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Util {
public static final boolean WINDOWS_OS = System.getProperty("os.name")
.toLowerCase().startsWith("windows");
private Util() {}
/**
* Returns the base directory of a jar file or null if the class is a standalone file.
* @return System specific path
*
* Based on a patch submitted by Josh Elsasser
*/
public static String getJarBasedir() {
String url = Util.class.getClassLoader()
.getResource(Util.class.getName().replace('.', '/') + ".class")
.getFile()
.replaceAll("%20", " ");
if (url.startsWith("file:")) {
String jar = url.substring(5, url.lastIndexOf('!'));
int x = jar.lastIndexOf('/');
if (x == -1) {
x = jar.lastIndexOf('\\');
}
String basedir = jar.substring(0, x + 1);
return new File(basedir).getPath();
} else {
return null;
}
}
public static File getAbsoluteFile(File basepath, File f) {
return f.isAbsolute() ? f : new File(basepath, f.getPath());
}
public static String getExtension(File f) {
String name = f.getName();
int x = name.lastIndexOf('.');
if (x != -1) {
return name.substring(x);
} else {
return "";
}
}
public static void exec(String cmd, Log log) throws ExecException {
BufferedReader is = null;
try {
if (WINDOWS_OS) {
cmd = cmd.replaceAll("/", "\\\\");
}
Process p = Runtime.getRuntime().exec(cmd);
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
while ((line = is.readLine()) != null) {
log.append(line);
}
is.close();
p.waitFor();
if (p.exitValue() != 0) {
String msg = "Exec failed (" + p.exitValue() + "): " + cmd;
log.append(msg);
throw new ExecException(msg);
}
} catch (IOException e) {
close(is);
throw new ExecException(e);
} catch (InterruptedException e) {
close(is);
throw new ExecException(e);
}
}
public static void close(final InputStream o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final OutputStream o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final Reader o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final Writer o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static boolean delete(File f) {
return (f != null) ? f.delete() : false;
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Util {
public static final boolean WINDOWS_OS = System.getProperty("os.name")
.toLowerCase().startsWith("windows");
private Util() {}
public static File createTempFile(String suffix) throws IOException {
String tmpdir = System.getProperty("launch4j.tmpdir");
if (tmpdir != null) {
if (tmpdir.indexOf(' ') != -1) {
throw new IOException(Messages.getString("Util.tmpdir"));
}
return File.createTempFile("launch4j", suffix, new File(tmpdir));
} else {
return File.createTempFile("launch4j", suffix);
}
}
/**
* Returns the base directory of a jar file or null if the class is a standalone file.
* @return System specific path
*
* Based on a patch submitted by Josh Elsasser
*/
public static File getJarBasedir() {
String url = Util.class.getClassLoader()
.getResource(Util.class.getName().replace('.', '/') + ".class")
.getFile()
.replaceAll("%20", " ");
if (url.startsWith("file:")) {
String jar = url.substring(5, url.lastIndexOf('!'));
int x = jar.lastIndexOf('/');
if (x == -1) {
x = jar.lastIndexOf('\\');
}
String basedir = jar.substring(0, x + 1);
return new File(basedir);
} else {
return new File(".");
}
}
public static File getAbsoluteFile(File basepath, File f) {
return f.isAbsolute() ? f : new File(basepath, f.getPath());
}
public static String getExtension(File f) {
String name = f.getName();
int x = name.lastIndexOf('.');
if (x != -1) {
return name.substring(x);
} else {
return "";
}
}
public static void exec(String[] cmd, Log log) throws ExecException {
BufferedReader is = null;
try {
if (WINDOWS_OS) {
for (int i = 0; i < cmd.length; i++) {
cmd[i] = cmd[i].replaceAll("/", "\\\\");
}
}
Process p = Runtime.getRuntime().exec(cmd);
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
int errLine = -1;
Pattern pattern = Pattern.compile(":\\d+:");
while ((line = is.readLine()) != null) {
log.append(line);
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
errLine = Integer.valueOf(
line.substring(matcher.start() + 1, matcher.end() - 1))
.intValue();
if (line.matches("(?i).*unrecognized escape sequence")) {
log.append(Messages.getString("Util.use.double.backslash"));
}
break;
}
}
is.close();
p.waitFor();
if (errLine != -1) {
throw new ExecException(Messages.getString("Util.exec.failed")
+ ": " + cmd, errLine);
}
if (p.exitValue() != 0) {
throw new ExecException(Messages.getString("Util.exec.failed")
+ "(" + p.exitValue() + "): " + cmd);
}
} catch (IOException e) {
close(is);
throw new ExecException(e);
} catch (InterruptedException e) {
close(is);
throw new ExecException(e);
}
}
public static void close(final InputStream o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final OutputStream o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final Reader o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final Writer o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static boolean delete(File f) {
return (f != null) ? f.delete() : false;
}
}

View File

@ -0,0 +1,61 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Jul 19, 2006
*/
package net.sf.launch4j.ant;
import java.util.ArrayList;
import java.util.List;
import net.sf.launch4j.config.ClassPath;
/**
* @author Copyright (C) 2006 Grzegorz Kowal
*/
public class AntClassPath extends ClassPath {
private final List wrappedPaths = new ArrayList();
public void setCp(String cp){
wrappedPaths.add(cp);
}
public void addCp(StringWrapper cp) {
wrappedPaths.add(cp);
}
public void unwrap() {
setPaths(StringWrapper.unwrap(wrappedPaths));
}
}

View File

@ -1,57 +1,129 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 24, 2005
*/
package net.sf.launch4j.ant;
import org.apache.tools.ant.BuildException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.Jre;
import net.sf.launch4j.config.Splash;
import net.sf.launch4j.config.VersionInfo;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class AntConfig extends Config {
public void addJre(Jre jre) {
checkNull(getJre(), "jre");
setJre(jre);
}
public void addSplash(Splash splash) {
checkNull(getSplash(), "splash");
setSplash(splash);
}
public void addVersionInfo(VersionInfo versionInfo) {
checkNull(getVersionInfo(), "versionInfo");
setVersionInfo(versionInfo);
}
private void checkNull(Object o, String name) {
if (o != null) {
throw new BuildException("Duplicate element: " + name);
}
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 24, 2005
*/
package net.sf.launch4j.ant;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.tools.ant.BuildException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.Msg;
import net.sf.launch4j.config.SingleInstance;
import net.sf.launch4j.config.Splash;
import net.sf.launch4j.config.VersionInfo;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class AntConfig extends Config {
private final List wrappedHeaderObjects = new ArrayList();
private final List wrappedLibs = new ArrayList();
private final List wrappedVariables = new ArrayList();
public void setJarPath(String path) {
setJar(new File(path));
}
public void addObj(StringWrapper obj) {
wrappedHeaderObjects.add(obj);
}
public void addLib(StringWrapper lib) {
wrappedLibs.add(lib);
}
public void addVar(StringWrapper var) {
wrappedVariables.add(var);
}
// __________________________________________________________________________________
public void addSingleInstance(SingleInstance singleInstance) {
checkNull(getSingleInstance(), "singleInstance");
setSingleInstance(singleInstance);
}
public void addClassPath(AntClassPath classPath) {
checkNull(getClassPath(), "classPath");
setClassPath(classPath);
}
public void addJre(AntJre jre) {
checkNull(getJre(), "jre");
setJre(jre);
}
public void addSplash(Splash splash) {
checkNull(getSplash(), "splash");
setSplash(splash);
}
public void addVersionInfo(VersionInfo versionInfo) {
checkNull(getVersionInfo(), "versionInfo");
setVersionInfo(versionInfo);
}
public void addMessages(Msg messages) {
checkNull(getMessages(), "messages");
setMessages(messages);
}
// __________________________________________________________________________________
public void unwrap() {
setHeaderObjects(StringWrapper.unwrap(wrappedHeaderObjects));
setLibs(StringWrapper.unwrap(wrappedLibs));
setVariables(StringWrapper.unwrap(wrappedVariables));
if (getClassPath() != null) {
((AntClassPath) getClassPath()).unwrap();
}
if (getJre() != null) {
((AntJre) getJre()).unwrap();
}
}
private void checkNull(Object o, String name) {
if (o != null) {
throw new BuildException(
Messages.getString("AntConfig.duplicate.element")
+ ": "
+ name);
}
}
}

View File

@ -0,0 +1,69 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Jul 18, 2006
*/
package net.sf.launch4j.ant;
import java.util.ArrayList;
import java.util.List;
import net.sf.launch4j.config.Jre;
/**
* @author Copyright (C) 2006 Grzegorz Kowal
*/
public class AntJre extends Jre {
private final List wrappedOptions = new ArrayList();
public void addOpt(StringWrapper opt) {
wrappedOptions.add(opt);
}
public void unwrap() {
setOptions(StringWrapper.unwrap(wrappedOptions));
}
/**
* For backwards compatibility.
*/
public void setDontUsePrivateJres(boolean dontUse) {
if (dontUse) {
setJdkPreference(JDK_PREFERENCE_JRE_ONLY);
}
else {
setJdkPreference(JDK_PREFERENCE_PREFER_JRE);
}
}
}

View File

@ -1,122 +1,162 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 24, 2005
*/
package net.sf.launch4j.ant;
import java.io.File;
import net.sf.launch4j.Builder;
import net.sf.launch4j.BuilderException;
import net.sf.launch4j.Log;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.ConfigPersisterException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Launch4jTask extends Task {
private File _configFile;
private AntConfig _config;
// Override configFile settings
private File jar;
private File outfile;
private String fileVersion;
private String txtFileVersion;
private String productVersion;
private String txtProductVersion;
public void execute() throws BuildException {
try {
if (_configFile != null && _config != null) {
throw new BuildException("Specify configFile or config");
} else if (_configFile != null) {
ConfigPersister.getInstance().load(_configFile);
Config c = ConfigPersister.getInstance().getConfig();
if (jar != null) {
c.setJar(jar);
}
if (outfile != null) {
c.setOutfile(outfile);
}
if (fileVersion != null) {
c.getVersionInfo().setFileVersion(fileVersion);
}
if (txtFileVersion != null) {
c.getVersionInfo().setTxtFileVersion(txtFileVersion);
}
if (productVersion != null) {
c.getVersionInfo().setProductVersion(productVersion);
}
if (txtProductVersion != null) {
c.getVersionInfo().setTxtProductVersion(txtProductVersion);
}
} else if (_config != null) {
ConfigPersister.getInstance().setAntConfig(_config, getProject().getBaseDir());
} else {
throw new BuildException("Specify configFile or config");
}
final Builder b = new Builder(Log.getAntLog());
b.build();
} catch (ConfigPersisterException e) {
throw new BuildException(e);
} catch (BuilderException e) {
throw new BuildException(e);
}
}
public void setConfigFile(File configFile) {
_configFile = configFile;
}
public void addConfig(AntConfig config) {
_config = config;
}
public void setFileVersion(String fileVersion) {
this.fileVersion = fileVersion;
}
public void setJar(File jar) {
this.jar = jar;
}
public void setOutfile(File outfile) {
this.outfile = outfile;
}
public void setProductVersion(String productVersion) {
this.productVersion = productVersion;
}
public void setTxtFileVersion(String txtFileVersion) {
this.txtFileVersion = txtFileVersion;
}
public void setTxtProductVersion(String txtProductVersion) {
this.txtProductVersion = txtProductVersion;
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 24, 2005
*/
package net.sf.launch4j.ant;
import java.io.File;
import net.sf.launch4j.Builder;
import net.sf.launch4j.BuilderException;
import net.sf.launch4j.Log;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.ConfigPersisterException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Launch4jTask extends Task {
private File _configFile;
private AntConfig _config;
// System properties
private File tmpdir; // launch4j.tmpdir
private File bindir; // launch4j.bindir
// Override configFile settings
private File jar;
private File outfile;
private String fileVersion;
private String txtFileVersion;
private String productVersion;
private String txtProductVersion;
public void execute() throws BuildException {
try {
if (tmpdir != null) {
System.setProperty("launch4j.tmpdir", tmpdir.getPath());
}
if (bindir != null) {
System.setProperty("launch4j.bindir", bindir.getPath());
}
if (_configFile != null && _config != null) {
throw new BuildException(
Messages.getString("Launch4jTask.specify.config"));
} else if (_configFile != null) {
ConfigPersister.getInstance().load(_configFile);
Config c = ConfigPersister.getInstance().getConfig();
if (jar != null) {
c.setJar(jar);
}
if (outfile != null) {
c.setOutfile(outfile);
}
if (fileVersion != null) {
c.getVersionInfo().setFileVersion(fileVersion);
}
if (txtFileVersion != null) {
c.getVersionInfo().setTxtFileVersion(txtFileVersion);
}
if (productVersion != null) {
c.getVersionInfo().setProductVersion(productVersion);
}
if (txtProductVersion != null) {
c.getVersionInfo().setTxtProductVersion(txtProductVersion);
}
} else if (_config != null) {
_config.unwrap();
ConfigPersister.getInstance().setAntConfig(_config,
getProject().getBaseDir());
} else {
throw new BuildException(
Messages.getString("Launch4jTask.specify.config"));
}
final Builder b = new Builder(Log.getAntLog());
b.build();
} catch (ConfigPersisterException e) {
throw new BuildException(e);
} catch (BuilderException e) {
throw new BuildException(e);
}
}
public void setConfigFile(File configFile) {
_configFile = configFile;
}
public void addConfig(AntConfig config) {
_config = config;
}
public void setBindir(File bindir) {
this.bindir = bindir;
}
public void setTmpdir(File tmpdir) {
this.tmpdir = tmpdir;
}
public void setFileVersion(String fileVersion) {
this.fileVersion = fileVersion;
}
public void setJar(File jar) {
this.jar = jar;
}
public void setJarPath(String path) {
this.jar = new File(path);
}
public void setOutfile(File outfile) {
this.outfile = outfile;
}
public void setProductVersion(String productVersion) {
this.productVersion = productVersion;
}
public void setTxtFileVersion(String txtFileVersion) {
this.txtFileVersion = txtFileVersion;
}
public void setTxtProductVersion(String txtProductVersion) {
this.txtProductVersion = txtProductVersion;
}
}

View File

@ -0,0 +1,55 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.ant;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "net.sf.launch4j.ant.messages";
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View File

@ -0,0 +1,67 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Jul 18, 2006
*/
package net.sf.launch4j.ant;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author Copyright (C) 2006 Grzegorz Kowal
*/
public class StringWrapper {
private String text;
public static List unwrap(List wrappers) {
if (wrappers.isEmpty()) {
return null;
}
List strings = new ArrayList(wrappers.size());
for (Iterator iter = wrappers.iterator(); iter.hasNext();) {
strings.add(iter.next().toString());
}
return strings;
}
public void addText(String text) {
this.text = text;
}
public String toString() {
return text;
}
}

View File

@ -0,0 +1,35 @@
#
# Launch4j (http://launch4j.sourceforge.net/)
# Cross-platform Java application wrapper for creating Windows native executables.
#
# Copyright (c) 2004, 2007 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:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the Launch4j 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 OWNER 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.
#
Launch4jTask.specify.config=Specify configFile or config
AntConfig.duplicate.element=Duplicate element

View File

@ -0,0 +1,35 @@
#
# Launch4j (http://launch4j.sourceforge.net/)
# Cross-platform Java application wrapper for creating Windows native executables.
#
# Copyright (c) 2004, 2007 Grzegorz Kowal, Patricio Mart<72>nez Ros
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the Launch4j 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 OWNER 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.
#
Launch4jTask.specify.config=Specify configFile or config
AntConfig.duplicate.element=Duplicate element

View File

@ -1,48 +1,62 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public interface Binding {
/** Used to mark components with invalid data. */
public final static Color INVALID_COLOR = Color.PINK;
/** Java Bean property bound to a component */
public String getProperty();
/** Clear component, set it to the default value. */
public void clear();
/** Java Bean property -> Component */
public void put(IValidatable bean);
/** Component -> Java Bean property */
public void get(IValidatable bean);
/** Mark component as valid */
public void markValid();
/** Mark component as invalid */
public void markInvalid();
/** Enable or disable the component */
public void setEnabled(boolean enabled);
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public interface Binding {
/** Used to mark components with invalid data. */
public final static Color INVALID_COLOR = Color.PINK;
/** Java Bean property bound to a component */
public String getProperty();
/** Clear component, set it to the default value */
public void clear(IValidatable bean);
/** Java Bean property -> Component */
public void put(IValidatable bean);
/** Component -> Java Bean property */
public void get(IValidatable bean);
/** Mark component as valid */
public void markValid();
/** Mark component as invalid */
public void markInvalid();
/** Enable or disable the component */
public void setEnabled(boolean enabled);
}

View File

@ -1,38 +1,52 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
/**
* Signals a runtime error, a missing property in a Java Bean for example.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class BindingException extends RuntimeException {
public BindingException(Throwable t) {
super(t);
}
public BindingException(String msg) {
super(msg);
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
/**
* Signals a runtime error, a missing property in a Java Bean for example.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class BindingException extends RuntimeException {
public BindingException(Throwable t) {
super(t);
}
public BindingException(String msg) {
super(msg);
}
}

View File

@ -1,247 +1,317 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JComponent;
import javax.swing.JRadioButton;
import javax.swing.JToggleButton;
import javax.swing.text.JTextComponent;
import org.apache.commons.beanutils.PropertyUtils;
/**
* Creates and handles bindings.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Bindings implements PropertyChangeListener {
private final Map _bindings = new HashMap();
private final Map _optComponents = new HashMap();
private boolean _modified = false;
/**
* Used to track component modifications.
*/
public void propertyChange(PropertyChangeEvent evt) {
if ("AccessibleValue".equals(evt.getPropertyName())
|| "AccessibleText".equals(evt.getPropertyName())) {
_modified = true;
}
}
/**
* Any of the components modified?
*/
public boolean isModified() {
return _modified;
}
public Binding getBinding(String property) {
return (Binding) _bindings.get(property);
}
private void registerPropertyChangeListener(JComponent c) {
c.getAccessibleContext().addPropertyChangeListener(this);
}
private void registerPropertyChangeListener(JComponent[] cs) {
for (int i = 0; i < cs.length; i++) {
cs[i].getAccessibleContext().addPropertyChangeListener(this);
}
}
private boolean isPropertyNull(IValidatable bean, Binding b) {
try {
for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) {
String property = (String) iter.next();
if (b.getProperty().startsWith(property)) {
return PropertyUtils.getProperty(bean, property) == null;
}
}
return false;
} catch (Exception e) {
throw new BindingException(e);
}
}
/**
* Enables or disables all components bound to properties that begin with given prefix.
*/
public void setComponentsEnabled(String prefix, boolean enabled) {
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (b.getProperty().startsWith(prefix)) {
b.setEnabled(enabled);
}
}
}
/**
* Clear all components, set them to their default values.
* Clears the _modified flag.
*/
public void clear() {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).clear();
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).clear();
}
_modified = false;
}
/**
* Copies data from the Java Bean to the UI components.
* Clears the _modified flag.
*/
public void put(IValidatable bean) {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).put(bean);
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (isPropertyNull(bean, b)) {
b.clear();
} else {
b.put(bean);
}
}
_modified = false;
}
/**
* Copies data from UI components to the Java Bean and checks it's class invariants.
* Clears the _modified flag.
* @throws InvariantViolationException
* @throws BindingException
*/
public void get(IValidatable bean) {
try {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).get(bean);
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (!isPropertyNull(bean, b)) {
b.get(bean);
}
}
bean.checkInvariants();
for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) {
String property = (String) iter.next();
IValidatable component = (IValidatable) PropertyUtils.getProperty(bean, property);
if (component != null) {
component.checkInvariants();
}
}
_modified = false; // XXX
} catch (InvariantViolationException e) {
e.setBinding(getBinding(e.getProperty()));
throw e;
} catch (Exception e) {
throw new BindingException(e);
}
}
private Bindings add(Binding b) {
if (_bindings.containsKey(b.getProperty())) {
throw new BindingException("Duplicate binding");
}
_bindings.put(b.getProperty(), b);
return this;
}
/**
* Add an optional (nullable) Java Bean component of type clazz.
*/
public Bindings addOptComponent(String property, Class clazz, JToggleButton c,
boolean enabledByDefault) {
Binding b = new OptComponentBinding(this, property, clazz, c, enabledByDefault);
if (_optComponents.containsKey(property)) {
throw new BindingException("Duplicate binding");
}
_optComponents.put(property, b);
return this;
}
/**
* Add an optional (nullable) Java Bean component of type clazz.
*/
public Bindings addOptComponent(String property, Class clazz, JToggleButton c) {
return addOptComponent(property, clazz, c, false);
}
/**
* Handles JEditorPane, JTextArea, JTextField
*/
public Bindings add(String property, JTextComponent c, String defaultValue) {
registerPropertyChangeListener(c);
return add(new JTextComponentBinding(property, c, defaultValue));
}
/**
* Handles JEditorPane, JTextArea, JTextField
*/
public Bindings add(String property, JTextComponent c) {
registerPropertyChangeListener(c);
return add(new JTextComponentBinding(property, c, ""));
}
/**
* Handles JToggleButton, JCheckBox
*/
public Bindings add(String property, JToggleButton c, boolean defaultValue) {
registerPropertyChangeListener(c);
return add(new JToggleButtonBinding(property, c, defaultValue));
}
/**
* Handles JToggleButton, JCheckBox
*/
public Bindings add(String property, JToggleButton c) {
registerPropertyChangeListener(c);
return add(new JToggleButtonBinding(property, c, false));
}
/**
* Handles JRadioButton
*/
public Bindings add(String property, JRadioButton[] cs, int defaultValue) {
registerPropertyChangeListener(cs);
return add(new JRadioButtonBinding(property, cs, defaultValue));
}
/**
* Handles JRadioButton
*/
public Bindings add(String property, JRadioButton[] cs) {
registerPropertyChangeListener(cs);
return add(new JRadioButtonBinding(property, cs, 0));
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JToggleButton;
import javax.swing.text.JTextComponent;
import org.apache.commons.beanutils.PropertyUtils;
/**
* Creates and handles bindings.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Bindings implements PropertyChangeListener {
private final Map _bindings = new HashMap();
private final Map _optComponents = new HashMap();
private boolean _modified = false;
/**
* Used to track component modifications.
*/
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
if ("AccessibleValue".equals(prop)
|| "AccessibleText".equals(prop)
|| "AccessibleVisibleData".equals(prop)) {
_modified = true;
}
}
/**
* Any of the components modified?
*/
public boolean isModified() {
return _modified;
}
public Binding getBinding(String property) {
return (Binding) _bindings.get(property);
}
private void registerPropertyChangeListener(JComponent c) {
c.getAccessibleContext().addPropertyChangeListener(this);
}
private void registerPropertyChangeListener(JComponent[] cs) {
for (int i = 0; i < cs.length; i++) {
cs[i].getAccessibleContext().addPropertyChangeListener(this);
}
}
private boolean isPropertyNull(IValidatable bean, Binding b) {
try {
for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) {
String property = (String) iter.next();
if (b.getProperty().startsWith(property)) {
return PropertyUtils.getProperty(bean, property) == null;
}
}
return false;
} catch (Exception e) {
throw new BindingException(e);
}
}
/**
* Enables or disables all components bound to properties that begin with given prefix.
*/
public void setComponentsEnabled(String prefix, boolean enabled) {
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (b.getProperty().startsWith(prefix)) {
b.setEnabled(enabled);
}
}
}
/**
* Clear all components, set them to their default values.
* Clears the _modified flag.
*/
public void clear(IValidatable bean) {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).clear(bean);
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).clear(bean);
}
_modified = false;
}
/**
* Copies data from the Java Bean to the UI components.
* Clears the _modified flag.
*/
public void put(IValidatable bean) {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).put(bean);
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (isPropertyNull(bean, b)) {
b.clear(null);
} else {
b.put(bean);
}
}
_modified = false;
}
/**
* Copies data from UI components to the Java Bean and checks it's class invariants.
* Clears the _modified flag.
* @throws InvariantViolationException
* @throws BindingException
*/
public void get(IValidatable bean) {
try {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).get(bean);
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (!isPropertyNull(bean, b)) {
b.get(bean);
}
}
bean.checkInvariants();
for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) {
String property = (String) iter.next();
IValidatable component = (IValidatable) PropertyUtils.getProperty(bean,
property);
if (component != null) {
component.checkInvariants();
}
}
_modified = false; // XXX
} catch (InvariantViolationException e) {
e.setBinding(getBinding(e.getProperty()));
throw e;
} catch (Exception e) {
throw new BindingException(e);
}
}
private Bindings add(Binding b) {
if (_bindings.containsKey(b.getProperty())) {
throw new BindingException(Messages.getString("Bindings.duplicate.binding"));
}
_bindings.put(b.getProperty(), b);
return this;
}
/**
* Add an optional (nullable) Java Bean component of type clazz.
*/
public Bindings addOptComponent(String property, Class clazz, JToggleButton c,
boolean enabledByDefault) {
Binding b = new OptComponentBinding(this, property, clazz, c, enabledByDefault);
if (_optComponents.containsKey(property)) {
throw new BindingException(Messages.getString("Bindings.duplicate.binding"));
}
_optComponents.put(property, b);
return this;
}
/**
* Add an optional (nullable) Java Bean component of type clazz.
*/
public Bindings addOptComponent(String property, Class clazz, JToggleButton c) {
return addOptComponent(property, clazz, c, false);
}
/**
* Handles JEditorPane, JTextArea, JTextField
*/
public Bindings add(String property, JTextComponent c, String defaultValue) {
registerPropertyChangeListener(c);
return add(new JTextComponentBinding(property, c, defaultValue));
}
/**
* Handles JEditorPane, JTextArea, JTextField
*/
public Bindings add(String property, JTextComponent c) {
registerPropertyChangeListener(c);
return add(new JTextComponentBinding(property, c, ""));
}
/**
* Handles JToggleButton, JCheckBox
*/
public Bindings add(String property, JToggleButton c, boolean defaultValue) {
registerPropertyChangeListener(c);
return add(new JToggleButtonBinding(property, c, defaultValue));
}
/**
* Handles JToggleButton, JCheckBox
*/
public Bindings add(String property, JToggleButton c) {
registerPropertyChangeListener(c);
return add(new JToggleButtonBinding(property, c, false));
}
/**
* Handles JRadioButton
*/
public Bindings add(String property, JRadioButton[] cs, int defaultValue) {
registerPropertyChangeListener(cs);
return add(new JRadioButtonBinding(property, cs, defaultValue));
}
/**
* Handles JRadioButton
*/
public Bindings add(String property, JRadioButton[] cs) {
registerPropertyChangeListener(cs);
return add(new JRadioButtonBinding(property, cs, 0));
}
/**
* Handles JTextArea
*/
public Bindings add(String property, JTextArea textArea, String defaultValue) {
registerPropertyChangeListener(textArea);
return add(new JTextComponentBinding(property, textArea, defaultValue));
}
/**
* Handles JTextArea lists
*/
public Bindings add(String property, JTextArea textArea) {
registerPropertyChangeListener(textArea);
return add(new JTextAreaBinding(property, textArea));
}
/**
* Handles Optional JTextArea lists
*/
public Bindings add(String property, String stateProperty,
JToggleButton button, JTextArea textArea) {
registerPropertyChangeListener(button);
registerPropertyChangeListener(textArea);
return add(new OptJTextAreaBinding(property, stateProperty, button, textArea));
}
/**
* Handles JList
*/
public Bindings add(String property, JList list) {
registerPropertyChangeListener(list);
return add(new JListBinding(property, list));
}
/**
* Handles JComboBox
*/
public Bindings add(String property, JComboBox combo, int defaultValue) {
registerPropertyChangeListener(combo);
return add(new JComboBoxBinding(property, combo, defaultValue));
}
/**
* Handles JComboBox
*/
public Bindings add(String property, JComboBox combo) {
registerPropertyChangeListener(combo);
return add(new JComboBoxBinding(property, combo, 0));
}
}

View File

@ -1,30 +1,44 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2004-01-30
*/
package net.sf.launch4j.binding;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public interface IValidatable {
public void checkInvariants();
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on 2004-01-30
*/
package net.sf.launch4j.binding;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public interface IValidatable {
public void checkInvariants();
}

View File

@ -1,53 +1,67 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Jun 23, 2003
*/
package net.sf.launch4j.binding;
/**
* @author Copyright (C) 2003 Grzegorz Kowal
*/
public class InvariantViolationException extends RuntimeException {
private final String _property;
private Binding _binding;
public InvariantViolationException(String msg) {
super(msg);
_property = null;
}
public InvariantViolationException(String property, String msg) {
super(msg);
_property = property;
}
public String getProperty() {
return _property;
}
public Binding getBinding() {
return _binding;
}
public void setBinding(Binding binding) {
_binding = binding;
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Jun 23, 2003
*/
package net.sf.launch4j.binding;
/**
* @author Copyright (C) 2003 Grzegorz Kowal
*/
public class InvariantViolationException extends RuntimeException {
private final String _property;
private Binding _binding;
public InvariantViolationException(String msg) {
super(msg);
_property = null;
}
public InvariantViolationException(String property, String msg) {
super(msg);
_property = property;
}
public String getProperty() {
return _property;
}
public Binding getBinding() {
return _binding;
}
public void setBinding(Binding binding) {
_binding = binding;
}
}

View File

@ -0,0 +1,119 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2007 Ian Roberts
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 10, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.JComboBox;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2007 Ian Roberts
*/
public class JComboBoxBinding implements Binding {
private final String _property;
private final JComboBox _combo;
private final int _defaultValue;
private final Color _validColor;
public JComboBoxBinding(String property, JComboBox combo, int defaultValue) {
if (property == null || combo == null) {
throw new NullPointerException();
}
if (property.equals("")
|| combo.getItemCount() == 0
|| defaultValue < 0 || defaultValue >= combo.getItemCount()) {
throw new IllegalArgumentException();
}
_property = property;
_combo = combo;
_defaultValue = defaultValue;
_validColor = combo.getBackground();
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
select(_defaultValue);
}
public void put(IValidatable bean) {
try {
Integer i = (Integer) PropertyUtils.getProperty(bean, _property);
if (i == null) {
throw new BindingException(
Messages.getString("JComboBoxBinding.property.null"));
}
select(i.intValue());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
PropertyUtils.setProperty(bean, _property, new Integer(_combo.getSelectedIndex()));
return;
} catch (Exception e) {
throw new BindingException(e);
}
}
private void select(int index) {
if (index < 0 || index >= _combo.getItemCount()) {
throw new BindingException(
Messages.getString("JComboBoxBinding.index.out.of.bounds"));
}
_combo.setSelectedIndex(index);
}
public void markValid() {
_combo.setBackground(_validColor);
_combo.requestFocusInWindow();
}
public void markInvalid() {
_combo.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_combo.setEnabled(enabled);
}
}

View File

@ -0,0 +1,118 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 1, 2006
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2006 Grzegorz Kowal
*/
public class JListBinding implements Binding {
private final String _property;
private final JList _list;
private final Color _validColor;
public JListBinding(String property, JList list) {
if (property == null || list == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_list = list;
_validColor = _list.getBackground();
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
_list.setModel(new DefaultListModel());
}
public void put(IValidatable bean) {
try {
DefaultListModel model = new DefaultListModel();
List list = (List) PropertyUtils.getProperty(bean, _property);
if (list != null) {
for (Iterator iter = list.iterator(); iter.hasNext();) {
model.addElement(iter.next());
}
}
_list.setModel(model);
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
DefaultListModel model = (DefaultListModel) _list.getModel();
final int size = model.getSize();
List list = new ArrayList(size);
for (int i = 0; i < size; i++) {
list.add(model.get(i));
}
PropertyUtils.setProperty(bean, _property, list);
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_list.setBackground(_validColor);
_list.requestFocusInWindow();
}
public void markInvalid() {
_list.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_list.setEnabled(enabled);
}
}

View File

@ -1,127 +1,146 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 10, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.JRadioButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JRadioButtonBinding implements Binding {
private final String _property;
private final JRadioButton[] _buttons;
private final int _defaultValue;
private final Color _validColor;
public JRadioButtonBinding(String property, JRadioButton[] buttons, int defaultValue) {
if (property == null || buttons == null) {
throw new NullPointerException();
}
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] == null) {
throw new NullPointerException();
}
}
if (property.equals("")
|| buttons.length == 0
|| defaultValue < 0 || defaultValue >= buttons.length) {
throw new IllegalArgumentException();
}
_property = property;
_buttons = buttons;
_defaultValue = defaultValue;
_validColor = buttons[0].getBackground();
}
public String getProperty() {
return _property;
}
public void clear() {
select(_defaultValue);
}
public void put(IValidatable bean) {
try {
Integer i = (Integer) PropertyUtils.getProperty(bean, _property);
if (i == null) {
throw new BindingException("Property is null");
}
select(i.intValue());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
PropertyUtils.setProperty(bean, _property, new Integer(i));
return;
}
}
throw new BindingException("Nothing selected");
} catch (Exception e) {
throw new BindingException(e);
}
}
private void select(int index) {
if (index < 0 || index >= _buttons.length) {
throw new BindingException("Button index out of bounds");
}
_buttons[index].setSelected(true);
}
public void markValid() {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
_buttons[i].setBackground(_validColor);
_buttons[i].requestFocusInWindow();
return;
}
}
throw new BindingException("Nothing selected");
}
public void markInvalid() {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
_buttons[i].setBackground(Binding.INVALID_COLOR);
return;
}
}
throw new BindingException("Nothing selected");
}
public void setEnabled(boolean enabled) {
for (int i = 0; i < _buttons.length; i++) {
_buttons[i].setEnabled(enabled);
}
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 10, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.JRadioButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JRadioButtonBinding implements Binding {
private final String _property;
private final JRadioButton[] _buttons;
private final int _defaultValue;
private final Color _validColor;
public JRadioButtonBinding(String property, JRadioButton[] buttons, int defaultValue) {
if (property == null || buttons == null) {
throw new NullPointerException();
}
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] == null) {
throw new NullPointerException();
}
}
if (property.equals("")
|| buttons.length == 0
|| defaultValue < 0 || defaultValue >= buttons.length) {
throw new IllegalArgumentException();
}
_property = property;
_buttons = buttons;
_defaultValue = defaultValue;
_validColor = buttons[0].getBackground();
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
select(_defaultValue);
}
public void put(IValidatable bean) {
try {
Integer i = (Integer) PropertyUtils.getProperty(bean, _property);
if (i == null) {
throw new BindingException(
Messages.getString("JRadioButtonBinding.property.null"));
}
select(i.intValue());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
PropertyUtils.setProperty(bean, _property, new Integer(i));
return;
}
}
throw new BindingException(
Messages.getString("JRadioButtonBinding.nothing.selected"));
} catch (Exception e) {
throw new BindingException(e);
}
}
private void select(int index) {
if (index < 0 || index >= _buttons.length) {
throw new BindingException(
Messages.getString("JRadioButtonBinding.index.out.of.bounds"));
}
_buttons[index].setSelected(true);
}
public void markValid() {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
_buttons[i].setBackground(_validColor);
_buttons[i].requestFocusInWindow();
return;
}
}
throw new BindingException(
Messages.getString("JRadioButtonBinding.nothing.selected"));
}
public void markInvalid() {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
_buttons[i].setBackground(Binding.INVALID_COLOR);
return;
}
}
throw new BindingException(
Messages.getString("JRadioButtonBinding.nothing.selected"));
}
public void setEnabled(boolean enabled) {
for (int i = 0; i < _buttons.length; i++) {
_buttons[i].setEnabled(enabled);
}
}
}

View File

@ -0,0 +1,123 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Jun 14, 2006
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JTextArea;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2006 Grzegorz Kowal
*/
public class JTextAreaBinding implements Binding {
private final String _property;
private final JTextArea _textArea;
private final Color _validColor;
public JTextAreaBinding(String property, JTextArea textArea) {
if (property == null || textArea == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_textArea = textArea;
_validColor = _textArea.getBackground();
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
put(bean);
}
public void put(IValidatable bean) {
try {
List list = (List) PropertyUtils.getProperty(bean, _property);
StringBuffer sb = new StringBuffer();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i));
if (i < list.size() - 1) {
sb.append("\n");
}
}
}
_textArea.setText(sb.toString());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
String text = _textArea.getText();
if (!text.equals("")) {
String[] items = text.split("\n");
List list = new ArrayList();
for (int i = 0; i < items.length; i++) {
list.add(items[i]);
}
PropertyUtils.setProperty(bean, _property, list);
} else {
PropertyUtils.setProperty(bean, _property, null);
}
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_textArea.setBackground(_validColor);
_textArea.requestFocusInWindow();
}
public void markInvalid() {
_textArea.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_textArea.setEnabled(enabled);
}
}

View File

@ -1,92 +1,108 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.text.JTextComponent;
import org.apache.commons.beanutils.BeanUtils;
/**
* Handles JEditorPane, JTextArea, JTextField
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JTextComponentBinding implements Binding {
private final String _property;
private final JTextComponent _textComponent;
private final String _defaultValue;
private final Color _validColor;
public JTextComponentBinding(String property, JTextComponent textComponent, String defaultValue) {
if (property == null || textComponent == null || defaultValue == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_textComponent = textComponent;
_defaultValue = defaultValue;
_validColor = _textComponent.getBackground();
}
public String getProperty() {
return _property;
}
public void clear() {
_textComponent.setText(_defaultValue);
}
public void put(IValidatable bean) {
try {
String s = BeanUtils.getProperty(bean, _property);
_textComponent.setText(s != null && !s.equals("0") ? s : ""); // XXX displays zeros as blank
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
BeanUtils.setProperty(bean, _property, _textComponent.getText());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_textComponent.setBackground(_validColor);
_textComponent.requestFocusInWindow();
}
public void markInvalid() {
_textComponent.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_textComponent.setEnabled(enabled);
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.text.JTextComponent;
import org.apache.commons.beanutils.BeanUtils;
/**
* Handles JEditorPane, JTextArea, JTextField
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JTextComponentBinding implements Binding {
private final String _property;
private final JTextComponent _textComponent;
private final String _defaultValue;
private final Color _validColor;
public JTextComponentBinding(String property, JTextComponent textComponent,
String defaultValue) {
if (property == null || textComponent == null || defaultValue == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_textComponent = textComponent;
_defaultValue = defaultValue;
_validColor = _textComponent.getBackground();
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
_textComponent.setText(_defaultValue);
}
public void put(IValidatable bean) {
try {
String s = BeanUtils.getProperty(bean, _property);
// XXX displays zeros as blank
_textComponent.setText(s != null && !s.equals("0") ? s : "");
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
BeanUtils.setProperty(bean, _property, _textComponent.getText());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_textComponent.setBackground(_validColor);
_textComponent.requestFocusInWindow();
}
public void markInvalid() {
_textComponent.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_textComponent.setEnabled(enabled);
}
}

View File

@ -1,94 +1,108 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.JToggleButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* Handles JToggleButton, JCheckBox
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JToggleButtonBinding implements Binding {
private final String _property;
private final JToggleButton _button;
private final boolean _defaultValue;
private final Color _validColor;
public JToggleButtonBinding(String property, JToggleButton button, boolean defaultValue) {
if (property == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_button = button;
_defaultValue = defaultValue;
_validColor = _button.getBackground();
}
public String getProperty() {
return _property;
}
public void clear() {
_button.setSelected(_defaultValue);
}
public void put(IValidatable bean) {
try {
// String s = BeanUtils.getProperty(o, _property);
// _checkBox.setSelected("true".equals(s));
Boolean b = (Boolean) PropertyUtils.getProperty(bean, _property);
_button.setSelected(b != null && b.booleanValue());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
PropertyUtils.setProperty(bean, _property, Boolean.valueOf(_button.isSelected()));
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_button.setBackground(_validColor);
_button.requestFocusInWindow();
}
public void markInvalid() {
_button.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_button.setEnabled(enabled);
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.JToggleButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* Handles JToggleButton, JCheckBox
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JToggleButtonBinding implements Binding {
private final String _property;
private final JToggleButton _button;
private final boolean _defaultValue;
private final Color _validColor;
public JToggleButtonBinding(String property, JToggleButton button,
boolean defaultValue) {
if (property == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_button = button;
_defaultValue = defaultValue;
_validColor = _button.getBackground();
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
_button.setSelected(_defaultValue);
}
public void put(IValidatable bean) {
try {
Boolean b = (Boolean) PropertyUtils.getProperty(bean, _property);
_button.setSelected(b != null && b.booleanValue());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
PropertyUtils.setProperty(bean, _property,
Boolean.valueOf(_button.isSelected()));
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_button.setBackground(_validColor);
_button.requestFocusInWindow();
}
public void markInvalid() {
_button.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_button.setEnabled(enabled);
}
}

View File

@ -0,0 +1,78 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.binding;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "net.sf.launch4j.binding.messages";
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private static final MessageFormat FORMATTER = new MessageFormat("");
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
public static String getString(String key, String arg0) {
return getString(key, new Object[] {arg0});
}
public static String getString(String key, String arg0, String arg1) {
return getString(key, new Object[] {arg0, arg1});
}
public static String getString(String key, String arg0, String arg1, String arg2) {
return getString(key, new Object[] {arg0, arg1, arg2});
}
public static String getString(String key, Object[] args) {
try {
FORMATTER.applyPattern(RESOURCE_BUNDLE.getString(key));
return FORMATTER.format(args);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View File

@ -1,104 +1,119 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 11, 2005
*/
package net.sf.launch4j.binding;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import javax.swing.JToggleButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class OptComponentBinding implements Binding, ActionListener {
private final Bindings _bindings;
private final String _property;
private final Class _clazz;
private final JToggleButton _button;
private final boolean _enabledByDefault;
public OptComponentBinding(Bindings bindings, String property, Class clazz,
JToggleButton button, boolean enabledByDefault) {
if (property == null || clazz == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
throw new IllegalArgumentException("Optional component must implement "
+ IValidatable.class);
}
_bindings = bindings;
_property = property;
_clazz = clazz;
_button = button;
_button.addActionListener(this);
_enabledByDefault = enabledByDefault;
}
public String getProperty() {
return _property;
}
public void clear() {
_button.setSelected(_enabledByDefault);
updateComponents();
}
public void put(IValidatable bean) {
try {
Object component = PropertyUtils.getProperty(bean, _property);
_button.setSelected(component != null);
updateComponents();
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
PropertyUtils.setProperty(bean, _property, _button.isSelected()
? _clazz.newInstance() : null);
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {}
public void markInvalid() {}
public void setEnabled(boolean enabled) {} // XXX implement?
public void actionPerformed(ActionEvent e) {
updateComponents();
}
private void updateComponents() {
_bindings.setComponentsEnabled(_property, _button.isSelected());
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on May 11, 2005
*/
package net.sf.launch4j.binding;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import javax.swing.JToggleButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class OptComponentBinding implements Binding, ActionListener {
private final Bindings _bindings;
private final String _property;
private final Class _clazz;
private final JToggleButton _button;
private final boolean _enabledByDefault;
public OptComponentBinding(Bindings bindings, String property, Class clazz,
JToggleButton button, boolean enabledByDefault) {
if (property == null || clazz == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
throw new IllegalArgumentException(
Messages.getString("OptComponentBinding.must.implement")
+ IValidatable.class);
}
_bindings = bindings;
_property = property;
_clazz = clazz;
_button = button;
_button.addActionListener(this);
_enabledByDefault = enabledByDefault;
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
_button.setSelected(_enabledByDefault);
updateComponents();
}
public void put(IValidatable bean) {
try {
Object component = PropertyUtils.getProperty(bean, _property);
_button.setSelected(component != null);
updateComponents();
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
PropertyUtils.setProperty(bean, _property, _button.isSelected()
? _clazz.newInstance() : null);
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {}
public void markInvalid() {}
public void setEnabled(boolean enabled) {} // XXX implement?
public void actionPerformed(ActionEvent e) {
updateComponents();
}
private void updateComponents() {
_bindings.setComponentsEnabled(_property, _button.isSelected());
}
}

View File

@ -0,0 +1,141 @@
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on Sep 3, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JTextArea;
import javax.swing.JToggleButton;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class OptJTextAreaBinding implements Binding, ActionListener {
private final String _property;
private final String _stateProperty;
private final JToggleButton _button;
private final JTextArea _textArea;
private final Color _validColor;
public OptJTextAreaBinding(String property, String stateProperty,
JToggleButton button, JTextArea textArea) {
if (property == null || button == null || textArea == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_stateProperty = stateProperty;
_button = button;
_textArea = textArea;
_validColor = _textArea.getBackground();
button.addActionListener(this);
}
public String getProperty() {
return _property;
}
public void clear(IValidatable bean) {
put(bean);
}
public void put(IValidatable bean) {
try {
boolean selected = "true".equals(BeanUtils.getProperty(bean,
_stateProperty));
_button.setSelected(selected);
_textArea.setEnabled(selected);
List list = (List) PropertyUtils.getProperty(bean, _property);
StringBuffer sb = new StringBuffer();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i));
if (i < list.size() - 1) {
sb.append("\n");
}
}
}
_textArea.setText(sb.toString());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
String text = _textArea.getText();
if (_button.isSelected() && !text.equals("")) {
String[] items = text.split("\n");
List list = new ArrayList();
for (int i = 0; i < items.length; i++) {
list.add(items[i]);
}
PropertyUtils.setProperty(bean, _property, list);
} else {
PropertyUtils.setProperty(bean, _property, null);
}
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_textArea.setBackground(_validColor);
_textArea.requestFocusInWindow();
}
public void markInvalid() {
_textArea.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_textArea.setEnabled(enabled);
}
public void actionPerformed(ActionEvent e) {
_textArea.setEnabled(_button.isSelected());
}
}

View File

@ -1,190 +1,259 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2004-01-30
*/
package net.sf.launch4j.binding;
import java.io.File;
import java.util.Collection;
import java.util.HashSet;
import net.sf.launch4j.Util;
import net.sf.launch4j.config.ConfigPersister;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public class Validator {
public static final String ALPHANUMERIC_PATTERN = "[\\w]*?";
public static final String ALPHA_PATTERN = "[\\w&&\\D]*?";
public static final String NUMERIC_PATTERN = "[\\d]*?";
public static final String PATH_PATTERN = "[\\w|[ .,:\\-/\\\\]]*?";
private static final String EMPTY_FIELD = "Enter: ";
private static final String FIELD_ERROR = "Invalid data: ";
private static final String RANGE_ERROR = " must be in range [";
private static final String MINIMUM = " must be at least ";
private static final String DUPLICATE = " already exists.";
private Validator() {}
public static boolean isEmpty(String s) {
return s == null || s.equals("");
}
public static void checkNotNull(Object o, String property, String name) {
if (o == null) {
signalViolation(property, EMPTY_FIELD + name);
}
}
public static void checkString(String s, int maxLength, String property, String name) {
if (s == null || s.length() == 0) {
signalViolation(property, EMPTY_FIELD + name);
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
}
public static void checkString(String s, int maxLength, String pattern,
String property, String name) {
checkString(s, maxLength, property, name);
if (!s.matches(pattern)) {
signalViolation(property, FIELD_ERROR + name);
}
}
public static void checkOptString(String s, int maxLength, String property, String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
}
public static void checkOptString(String s, int maxLength, String pattern,
String property, String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
if (!s.matches(pattern)) {
signalViolation(property, FIELD_ERROR + name);
}
}
public static void checkRange(int value, int min, int max,
String property, String name) {
if (value < min || value > max) {
StringBuffer sb = new StringBuffer(name);
sb.append(RANGE_ERROR);
sb.append(min);
sb.append('-');
sb.append(max);
sb.append(']');
signalViolation(property, sb.toString());
}
}
public static void checkRange(char value, char min, char max,
String property, String name) {
if (value < min || value > max) {
StringBuffer sb = new StringBuffer(name);
sb.append(RANGE_ERROR);
sb.append(min);
sb.append('-');
sb.append(max);
sb.append(']');
signalViolation(property, sb.toString());
}
}
public static void checkMin(int value, int min, String property, String name) {
if (value < min) {
StringBuffer sb = new StringBuffer(name);
sb.append(MINIMUM);
sb.append(min);
signalViolation(property, sb.toString());
}
}
public static void checkTrue(boolean condition, String property, String msg) {
if (!condition) {
signalViolation(property, msg);
}
}
public static void checkFalse(boolean condition, String property, String msg) {
if (condition) {
signalViolation(property, msg);
}
}
public static void checkElementsNotNullUnique(Collection c, String property, String msg) {
if (c.contains(null)
|| new HashSet(c).size() != c.size()) {
signalViolation(property, msg + DUPLICATE);
}
}
public static void checkElementsUnique(Collection c, String property, String msg) {
if (new HashSet(c).size() != c.size()) {
signalViolation(property, msg + DUPLICATE);
}
}
public static void checkFile(File f, String property, String fileDescription) {
File cfgPath = ConfigPersister.getInstance().getConfigPath();
if (f == null || (!f.exists() && !Util.getAbsoluteFile(cfgPath, f).exists())) {
signalViolation(property, fileDescription + " doesn't exist.");
}
}
public static void checkOptFile(File f, String property, String fileDescription) {
if (f != null && f.getPath().length() > 0) {
checkFile(f, property, fileDescription);
}
}
public static void checkRelativeWinPath(String path, String property, String msg) {
if (path.startsWith("/")
|| path.startsWith("\\")
|| path.indexOf(':') != -1) {
signalViolation(property, msg);
}
}
public static void signalLengthViolation(String property, String name, int maxLength) {
final StringBuffer sb = new StringBuffer(name);
sb.append(" exceeds the maximum length of ");
sb.append(maxLength);
sb.append(" characters.");
throw new InvariantViolationException(property, sb.toString());
}
public static void signalViolation(String property, String msg) {
throw new InvariantViolationException(property, msg);
}
}
/*
Launch4j (http://launch4j.sourceforge.net/)
Cross-platform Java application wrapper for creating Windows native executables.
Copyright (c) 2004, 2007 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:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Launch4j 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 OWNER 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.
*/
/*
* Created on 2004-01-30
*/
package net.sf.launch4j.binding;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import net.sf.launch4j.Util;
import net.sf.launch4j.config.ConfigPersister;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public class Validator {
public static final String ALPHANUMERIC_PATTERN = "[\\w]*?";
public static final String ALPHA_PATTERN = "[\\w&&\\D]*?";
public static final String NUMERIC_PATTERN = "[\\d]*?";
public static final String PATH_PATTERN = "[\\w|[ .,:\\-/\\\\]]*?";
public static final int MAX_STR = 128;
public static final int MAX_PATH = 260;
public static final int MAX_BIG_STR = 8192; // or 16384;
public static final int MAX_ARGS = 32767 - 2048;
private Validator() {}
public static boolean isEmpty(String s) {
return s == null || s.equals("");
}
public static void checkNotNull(Object o, String property, String name) {
if (o == null) {
signalViolation(property,
Messages.getString("Validator.empty.field", name));
}
}
public static void checkString(String s, int maxLength, String property,
String name) {
if (s == null || s.length() == 0) {
signalViolation(property,
Messages.getString("Validator.empty.field", name));
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
}
public static void checkOptStrings(List strings, int maxLength, int totalMaxLength,
String property, String name) {
if (strings == null) {
return;
}
int totalLength = 0;
for (Iterator iter = strings.iterator(); iter.hasNext();) {
String s = (String) iter.next();
checkString(s, maxLength, property, name);
totalLength += s.length();
if (totalLength > totalMaxLength) {
signalLengthViolation(property, name, totalMaxLength);
}
}
}
public static void checkString(String s, int maxLength, String pattern,
String property, String name) {
checkString(s, maxLength, property, name);
if (!s.matches(pattern)) {
signalViolation(property,
Messages.getString("Validator.invalid.data", name));
}
}
public static void checkOptStrings(List strings, int maxLength, int totalMaxLength,
String pattern, String property, String name, String msg) {
if (strings == null) {
return;
}
int totalLength = 0;
for (Iterator iter = strings.iterator(); iter.hasNext();) {
String s = (String) iter.next();
checkString(s, maxLength, property, name);
if (!s.matches(pattern)) {
signalViolation(property, msg != null
? msg
: Messages.getString("Validator.invalid.data", name));
}
totalLength += s.length();
if (totalLength > totalMaxLength) {
signalLengthViolation(property, name, totalMaxLength);
}
}
}
public static void checkOptString(String s, int maxLength, String property,
String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
}
public static void checkOptString(String s, int maxLength, String pattern,
String property, String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
if (!s.matches(pattern)) {
signalViolation(property,
Messages.getString("Validator.invalid.data", name));
}
}
public static void checkRange(int value, int min, int max,
String property, String name) {
if (value < min || value > max) {
signalViolation(property,
Messages.getString("Validator.must.be.in.range", name,
String.valueOf(min), String.valueOf(max)));
}
}
public static void checkRange(char value, char min, char max,
String property, String name) {
if (value < min || value > max) {
signalViolation(property, Messages.getString("Validator.must.be.in.range",
name, String.valueOf(min), String.valueOf(max)));
}
}
public static void checkMin(int value, int min, String property, String name) {
if (value < min) {
signalViolation(property,
Messages.getString("Validator.must.be.at.least", name,
String.valueOf(min)));
}
}
public static void checkIn(String s, String[] strings, String property,
String name) {
if (isEmpty(s)) {
signalViolation(property,
Messages.getString("Validator.empty.field", name));
}
List list = Arrays.asList(strings);
if (!list.contains(s)) {
signalViolation(property,
Messages.getString("Validator.invalid.option", name, list.toString()));
}
}
public static void checkTrue(boolean condition, String property, String msg) {
if (!condition) {
signalViolation(property, msg);
}
}
public static void checkFalse(boolean condition, String property, String msg) {
if (condition) {
signalViolation(property, msg);
}
}
public static void checkElementsNotNullUnique(Collection c, String property,
String msg) {
if (c.contains(null)
|| new HashSet(c).size() != c.size()) {
signalViolation(property,
Messages.getString("Validator.already.exists", msg));
}
}
public static void checkElementsUnique(Collection c, String property, String msg) {
if (new HashSet(c).size() != c.size()) {
signalViolation(property,
Messages.getString("Validator.already.exists", msg));
}
}
public static void checkFile(File f, String property, String fileDescription) {
File cfgPath = ConfigPersister.getInstance().getConfigPath();
if (f == null
|| f.getPath().equals("")
|| (!f.exists() && !Util.getAbsoluteFile(cfgPath, f).exists())) {
signalViolation(property,
Messages.getString("Validator.doesnt.exist", fileDescription));
}
}
public static void checkOptFile(File f, String property, String fileDescription) {
if (f != null && f.getPath().length() > 0) {
checkFile(f, property, fileDescription);
}
}
public static void checkRelativeWinPath(String path, String property, String msg) {
if (path == null
|| path.equals("")
|| path.startsWith("/")
|| path.startsWith("\\")
|| path.indexOf(':') != -1) {
signalViolation(property, msg);
}
}
public static void signalLengthViolation(String property, String name,
int maxLength) {
signalViolation(property,
Messages.getString("Validator.exceeds.max.length", name,
String.valueOf(maxLength)));
}
public static void signalViolation(String property, String msg) {
throw new InvariantViolationException(property, msg);
}
}

Some files were not shown because too many files have changed in this diff Show More