Add support for a chained main class, for running a second app in the same JVM

fix-message-formatting
Daniel Pocock 11 years ago
parent 027044dbd1
commit e8d71b740d

@ -23,6 +23,48 @@ public static void main(String[] args) throws Exception
// allow access to everything
System.setSecurityManager(null);
// optional: the name of another class with a main method
// that should be started in the same JVM:
String chainMain = System.getProperty("chain.main.class");
if(chainMain != null)
{
// optional: a space-separated list of arguments to be passed
// to the chained main() method:
String chainArgs = System.getProperty("chain.main.args");
if(chainArgs == null)
{
chainArgs = "";
}
final String[] _chainArgs = chainArgs.split("\\s");
try
{
Class<?> c = Class.forName(chainMain);
final Method m = c.getMethod("main", _chainArgs.getClass());
new Thread()
{
public void run()
{
try
{
m.invoke(null, new Object[]{_chainArgs});
}
catch (Exception ex)
{
ex.printStackTrace();
System.err.println("Exception running the " +
"chained main class, will continue anyway.");
}
}
}.start();
}
catch (Exception ex)
{
ex.printStackTrace();
System.err.println("Exception finding the chained main " +
"class, will continue anyway.");
}
}
// prepare the logger
// needed by the FileHandler-Logger
SIPCommunicator.setScHomeDir(System.getProperty("os.name"));

@ -83,6 +83,11 @@
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<property name="net.java.sip.communicator.SC_JWS_BASEDIR" value="@URL@"/>
<!-- to run an additional application in the same JVM,
declare the main class and any arguments here and
add the JARs to the list below. -->
<!-- <property name="chain.main.class" value="com.example.MyApp"/> -->
<!-- <property name="chain.main.args" value="arg1 arg2"/> -->
<!-- INTERNAL_COMMENT
Use compressed Jars if available -->
<property name="jnlp.packEnabled" value="@PACKENABLED@"/>
@ -95,6 +100,11 @@
<jar href="lib/bundle/log4j.jar" />
<jar href="lib/bundle/commons-logging.jar" />
@COMMON@
<!-- here, add any other JARs that are needed for
a chained main class or any other purpose -->
<!-- <jar href="com.example.foo.jar" /> -->
</resources>
<application-desc main-class="net.java.sip.communicator.launcher.SIPCommunicatorJWS"/>

Loading…
Cancel
Save