在Windows XP中编译servlet [英] Compiling a servlet in Windows XP

查看:126
本文介绍了在Windows XP中编译servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从命令提示符编译和运行servlet?

How do I compile and run a servlet from the Command Prompt?

当我尝试使用Apache Tomcat 6.0.16编译时出错。

I got an error when I tried to compile using Apache Tomcat 6.0.16.

我应该使用的确切命令是什么?

What is the exact command I should be using?

推荐答案


如何从命令提示符编译和运行servlet?

How do I compile and run a servlet from the Command Prompt?

对于问题的第一部分,你'我需要将servlet API放在你的类路径上:

For the first part of the question, you'll need to put the servlet API on you classpath:

javac -cp $TOMCAT_HOME/lib/servlet-api.jar *.java

对于第二部分,你想要实现的目标有点不清楚。 Servlet旨在打包在WAR中并部署在Servlet容器(如Tomcat)中。 Servlet没有main()方法,它不打算在命令行上运行。

For the second part, what you are trying to achieve is a bit unclear. A Servlet is intended to be packaged in a WAR and deployed in a Servlet container (like Tomcat). A Servlet doesn't have a main() method, it's not intended to be run on the command line.

实际上,你应该从像开发Web应用程序简介并获得一些IDE支持。 NetBeans不是我最喜欢的IDE,但他们有非常好的教育材料,在你的情况下,我认为这将是一个很好的起点。

Actually, you should start with a good tutorial like Introduction to Developing Web Applications and get some IDE support. NetBeans is not my favorite IDE but they have very good educational material and, in your case, I think it would be a good starting point.

这篇关于在Windows XP中编译servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆