A Ant java call like :
<target name=”run”>
<java classname=”foo.bar.App” fork=”false”>
<classpath refid=”app.classpath” />
</java>
</target>
becomes :
<target name=”run”>
<java classname=”foo.bar.App” fork=”yes“>
<classpath refid=”app.classpath” />
<sysproperty key=”DEBUG” value=”true” />
<jvmarg value=”-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000″ />
</java>
</target>
and is ready to be launch and ‘remote debugged’ from a tool like Eclipse IDE.
java
java
Here is a quick (and easy) tip on how to handle static resources with Jetty6 (this is really nice and quick to setup such things for a demo ;o)). Here is the code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| package foo.bar;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.ContextHandlerCollection;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context;
/**
* @author Christophe HAMERLING - eBM WebSourcing
*
*/
public class JettyServer {
public static void main(String[] args) throws Exception {
Server server = new Server();
final ContextHandlerCollection contexts = new ContextHandlerCollection();
final Context context = new Context(contexts, "/", Context.SESSIONS);
context.setResourceBase(System.getProperty("user.home"));
context.addServlet("org.mortbay.jetty.servlet.DefaultServlet", "/");
final SelectChannelConnector nioConnector = new SelectChannelConnector();
nioConnector.setPort(1978);
server.addConnector(nioConnector);
server.setHandler(contexts);
server.start();
}
} |
This will display your home directory on http://localhost:1978
Cheers
java
java, jetty