简体   繁体   English

我需要JDK与Eclipse Helios和Tomcat 7.0.33一起使用吗?

[英]Do I need JDK to work with Eclipse Helios and Tomcat 7.0.33?

I want to develop dynamic web applications. 我想开发动态Web应用程序。

For this I am using Eclipse Helios and Tomcat 7.0.33. 为此,我正在使用Eclipse Helios和Tomcat 7.0.33。 I have the JRE installed on my machine and I have provided the location of the JRE in the JAVA_HOME path. 我在计算机上安装了JRE,并在JAVA_HOME路径中提供了JRE的位置。

But when I am running any servlet, I get the error: 但是,当我运行任何servlet时,都会收到错误消息:

" HTTP Status 404 " -- " The requested resource is not available " “ HTTP状态404”-“请求的资源不可用”

Do I need a JDK in place of the JRE (meaning I have to set the path of the JDK in place of the JRE)? 我是否需要JDK来代替JRE(这意味着我必须设置JDK的路径来代替JRE)? Or could there be another other reason why this error is happening? 还是可能有其他原因导致此错误发生?

Looking for Help! 寻找帮助!

If your servlets are already compiled then JRE will serve the purpose, 如果您的servlet已经被编译,那么JRE将达到目的,

But they are compiled then you will JDK and other libraries( like servlet-api.jar, etc.) to compile you servlets. 但是它们被编译后,您将使用JDK和其他库(例如servlet-api.jar等)来编译servlet。

In short JDK is for development where you want to develop something using Java. 简而言之,JDK用于开发,您想使用Java进行开发。

And JRE is used when you already have compiled classes and you just want to run it. 当您已经编译了类并且只想运行它时,就会使用JRE。

You might want to refer to this : 您可能要参考以下内容:

What is the difference between JDK and JRE? JDK和JRE有什么区别?

In theory, compiling with Eclipse's incremental compiler is sufficient. 从理论上讲,使用Eclipse的增量编译器进行编译就足够了。 Running the application server with a JRE should be fine as well. 使用JRE运行应用程序服务器也应该很好。 I suppose your error is somewhere else. 我想你的错误在别的地方。 Anyway, I'd strongly recommend installing a JDK for developing a Java application. 无论如何,我强烈建议您安装JDK来开发Java应用程序。 It comes with some handy tools and many 3rd party tools (Maven, eg) also require a real JDK compiler and can't work with Eclipse's built in compiler. 它带有一些方便的工具,许多第三方工具(例如Maven)也需要一个真正的JDK编译器,并且不能与Eclipse的内置编译器一起使用。

I had the same problem. 我有同样的问题。 The JDK was not the issue. JDK不是问题。 After you compile your servlet you have to restart your tomcat server so it can load your class files before you try to access it through the web browser. 编译servlet之后,必须重新启动tomcat服务器,以便它可以加载类文件,然后再尝试通过Web浏览器访问它。 No more 404 errors after that, servlets are running fine. 之后,不再有404错误,servlet运行正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM