Listing 1: cfeverywhere.java

import java.io.IOException;

public class cfeverywhere {
	private static final String WIN_ID = "Windows";
	boolean isJettyStarted;
	String[] args;

	public static boolean isWindowsPlatform(){
        String os = System.getProperty("os.name");
        if ( os != null && os.startsWith(WIN_ID))
            return true;
        else
            return false;
    }

	public static void main(String[] args) throws IOException {

		boolean windows = isWindowsPlatform();
		int  delayMilliseconds = 20000;
		String cmd = null;
		String applicationUrl = "http://localhost:8080/derbyemployeesdrilldown.cfm";

		System.out.println("Starting CFEverywhere...");
		// start jetty in a new thread
		new JettyThread(args).start();
		// start Derby in a new thread
		new DerbyThread(args).start();

		System.out.println("..waiting to launch browser...");
		java.lang.Object sync = new java.lang.Object();
		try{
			synchronized(sync){
				sync.wait(delayMilliseconds);
			}
		} catch(InterruptedException e){}

		 
		System.out.println("Launching browser to " + applicationUrl);
		if (windows){
			cmd = "rundll32 url.dll,FileProtocolHandler " + applicationUrl;
		} else {
			cmd = "open " + applicationUrl;
		}
		//execute the command
		Runtime.getRuntime().exec(cmd);

	}

	
	
	
}

Listing 2: JettyThread.java

public class JettyThread extends Thread{

	boolean isStarted;
	String[] myargs;

	public JettyThread(String[] args){
		isStarted = false;
		myargs = args;
	}
	public void run() {
		if (!isStarted){
			org.mortbay.jetty.Server.main(myargs);
		}
		isStarted = !isStarted;
		try {
            sleep((long)(1000));
        } catch (InterruptedException e) {}
	}
}

Listing 3: DerbyThread.java

import org.apache.derby.drda.NetworkServerControl;


public class DerbyThread extends Thread{

	boolean isStarted;
	String[] myargs;

	public DerbyThread(String[] args){
		isStarted = false;
		myargs = args;
	}
	public void run(){
		if (!isStarted){
			try{
				NetworkServerControl server = new NetworkServerControl();
				server.start(null);
			}catch(Exception e){}
		}
		isStarted = !isStarted;
		try {
            sleep((long)(1000));
        } catch (InterruptedException e) {}
	}
}

Listing 4: Cfeverywhere.hta

<head>
<script language="JavaScript">
newHeight = 480;
newWidth = 640;
self.resizeTo(newWidth,newHeight);
</script>

<script language='vbscript'>
Set WshShell = CreateObject( "WScript.Shell" )
WshShell.Run "start.bat",0,false
WshShell.Run "startdb.bat",0,false
sub closeOut
        WshShell.Run "stop.bat",0,false
		WshShell2.Run "stopdb.bat",0,false
End sub
</script>
<HTA:APPLICATION ID="WbrtChange"
icon="ttools_32.ico"
BORDER="dialog"
BORDERSTYLE="normal"
maximizeButton="no"
minimizeButton="no"
showInTaskbar="yes"
SCROLL="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"/>
<style>
iframe{
        border: none;
        margin: 0;
        padding: 0;
        height:480;
        width:640;
}

body{
        border: none;
        margin: 0;
        padding: 0;
        overflow : hidden;
}

</style>
</head>
 <body onunload="closeOut()">
<iframe scrolling="No" src="wait.html"></iframe>
</body>


Listing 5: wait.html

<html>
<head>
        <title>Loading CFEverywhere...</title>
        <meta http-equiv="refresh"
content="30;url=http://127.0.0.1:8080/derbyemployeesdrilldown.cfm">
</head>
<body>
        <img src="loading.gif" height="240" width="320" >
</body>
</html>