start a jetty server from Java Web Start
I am very new to Jetty Server and Java Web Start.Can any body help me out to start jetty server from java web start.
I found sample example .I am trying to work out it.
The server is starting from the standalone with the command java Jetty
but when i am trying to run from the jnlp file i am not able to do that.
I did the following things.
Simple java file
JNLP file.
jar cf jetty.jar Jetty.class
keytool -genkey -keystore jettyKeys -alias jetty
jarsigner -keystore jettyKeys jetty.jar jetty
When i try to run jnlp file java web start is starting but jetty server is not starting.
Thanks in advance.
My Java file
--------------------
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerCollection;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.HashUserRealm;
import org.mortbay.jetty.security.UserRealm;
import org.mortbay.jetty.webapp.WebAppContext;
public class Jetty {
static public void main(String args[])throws Exception {
Server server = new Server();
Connector connector = new SelectChannelConnector();
connector.setPort(8081);
server.setConnectors(new Connector[]{connector});
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/");
webappcontext.setWar("C:/jetty-6.1.1/webapps/mywar.war");
HandlerCollection handlers= new HandlerCollection();
handlers.setHandlers(new Handler[]{webappcontext, new DefaultHandler()});
server.setHandler(handlers);
HashUserRealm myrealm = new HashUserRealm("MyRealm");
server.setUserRealms(new UserRealm[]{myrealm});
try{
server.start();
server.join();
}catch(Exception e){
e.printStackTrace();
}
}
}
My JNLP File
-------------------
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+"
codebase="file:///D:/Ramakrishna Dex/workspace/JavaWebStartExample/"
>
<information>
<title>Jetty Server</title>
<vendor>Java Developer Connection</vendor>
<homepage href="/jetty" />
<description>Demonstration of JNLP</description>
</information>
<offline-allowed/>
<security>
<j2ee-application-client-permissions/>
</security>
<resources>
<j2se version="1.2+" />
<jar href="jetty.jar"/>
</resources>
<application-desc main-class="Jetty" />
</jnlp>