Я пытаюсь скомпилировать класс Java на: http://wiki.eclipse.org/Jetty/Tutorial/Jetty_HelloWorld
с веб-сервисом Jetty.
По какой-то причине, когда я пытаюсь запустить:
javac -cp servlet-api-2.5.jar:jetty-all-$JETTY_VERSION.jar HelloWorld.java
Там написано 14, да 14 ошибок:
C:\Users\n...\DEMO>javac -cp servlet-api-2.5.jar:jetty-all-
7.3.0.v20110203.jar HelloWorld.java HelloWorld.java:1: package javax.servlet.http does not exist import javax.servlet.http.HttpServletRequest;
^ HelloWorld.java:2: package javax.servlet.http does not exist import javax.servlet.http.HttpServletResponse;
^ HelloWorld.java:3: package javax.servlet does not exist import javax.servlet.ServletException;
^ HelloWorld.java:7: package org.eclipse.jetty.server does not exist import org.eclipse.jetty.server.Server;
^ HelloWorld.java:8: package org.eclipse.jetty.server does not exist import org.eclipse.jetty.server.Request;
^ HelloWorld.java:9: package org.eclipse.jetty.server.handler does not exist import org.eclipse.jetty.server.handler.AbstractHandler;
^ HelloWorld.java:11: cannot find symbol symbol: class AbstractHandler public class HelloWorld extends AbstractHandler
^ HelloWorld.java:14: cannot find symbol symbol : class Request location: class HelloWorld
Request baseRequest,
^ HelloWorld.java:15: cannot find symbol symbol : class HttpServletRequest location: class HelloWorld
HttpServletRequest request,
^ HelloWorld.java:16: cannot find symbol symbol : class HttpServletResponse location: class HelloWorld
HttpServletResponse response)
^ HelloWorld.java:17: cannot find symbol symbol : class ServletException location: class HelloWorld
throws IOException, ServletException
^ HelloWorld.java:20: cannot find symbol symbol : variable HttpServletResponse location: class HelloWorld
response.setStatus(HttpServletResponse.SC_OK);
^ HelloWorld.java:27: cannot find symbol symbol : class Server location: class HelloWorld
Server server = new Server(8080);
^ HelloWorld.java:27: cannot find symbol symbol : class Server location: class HelloWorld
Server server = new Server(8080);
^ 14 errors
</p>
<p>How do i fix it so it works on my machine, and i can complie and run it?</p>
<p>Thanks.</p>
<p><strong>UPDATE:</strong>
HelloWorld.java (its on the site, but ill put it here):</p>
<code>import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
public class HelloWorld extends AbstractHandler
{
public void handle(String target,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.getWriter().println("<h1>Hello World</h1>");
}
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
server.setHandler(new HelloWorld());
server.start();
server.join();
}
}
</code>
ОБНОВЛЕНИЕ 2:
В процессе установки JAVA EE SDK.
Даст вам знать, если это работает