简体   繁体   English

如何在Eclipse IDE的Apache Tomcat服务器中部署创建的.jar文件?

[英]How to deploy created .jar file in Apache Tomcat server in Eclipse IDE?

I'm stuck into the process of deploying created .jar files in Eclipse. 我陷入了在Eclipse中部署创建的.jar文件的过程。

Eclipse is at location: E:\\eclipse Eclipse在以下位置: E:\\eclipse

Web project is at: E:\\Runtime_Testing\\src\\study_to_night Web项目位于: E:\\Runtime_Testing\\src\\study_to_night

Tomcat is at location: C:\\apache-tomcat-7.0.54-windows-x64 Tomcat位于以下位置: C:\\apache-tomcat-7.0.54-windows-x64

Meanwhile, steps followed for creating jar files in Eclipse: 同时,遵循以下步骤在Eclipse中创建jar文件:

  1. Right click on your Java Project and select Export. 右键单击Java项目,然后选择“导出”。
  2. Expand the Java node and select JAR file. 展开Java节点,然后选择JAR文件。
  3. In the JAR File Specification page, checked the option which says "Export Java source files and resources" 在“ JAR文件规范”页面中,选中显示“导出Java源文件和资源”的选项。
  4. Selected the export destination as: E:OneForAll.jar ; 选择导出目的地为: E:OneForAll.jar ; OneForAll being the name of my .jar file OneForAll我的.jar文件名称
  5. Checked the option` "Compress the contents of the JAR Files" 选中选项“压缩JAR文件的内容”
  6. Next ---> Finish. 接下来--->完成。

On following the above steps, an executable JAR file is created at the specified location. 执行上述步骤后,将在指定位置创建一个可执行JAR文件。 Just to check if all the files have been extracted in the .jar component, when I chose "Extract files" option, all source files were traceable. 只是为了检查是否所有文件都已提取到.jar组件中,当我选择“提取文件”选项时,所有源文件都是可追溯的。 However, on double-click it throws Error: Invalid or corrupt jarfile 'E:OneForAll.jar' . 但是,双击它会引发Error: Invalid or corrupt jarfile 'E:OneForAll.jar'

I feel I'm lost. 我觉得我迷路了。 Is there something I missed out? 我错过了什么吗? What went wrong? 什么地方出了错?

Could someone walk me through the steps to do this manually ? 有人可以指导我逐步完成手动操作吗?

So you have it running successfully within eclipse? 因此,您可以在Eclipse中成功运行它吗? But now you want to deploy this tested web app? 但是现在您想部署这个经过测试的Web应用程序吗?

Then 然后

  1. Right click on your Java Project and select Export. 右键单击Java项目,然后选择“导出”。

  2. Expand the Web node and select WAR file. 展开Web节点,然后选择WAR文件。

This exports the WEB-INF and related files that tomcat needs. 这将导出tomcat需要的WEB-INF和相关文件。

This question answers what to do next How to deploy a war file in Tomcat 7 这个问题回答了下一步该如何在Tomcat 7中部署War文件

Apache tomcat is a web container you cannot deploy a jar in tomcat server. Apache tomcat是一个Web容器,您无法在tomcat服务器中部署jar。 If you created a web application then export your application as war file and put it in tomcat webapp directory, start the server and your war will be deployed. 如果创建了Web应用程序,然后将应用程序导出为war文件并将其放在tomcat webapp目录中,请启动服务器,然后将部署war。

if you have lots of jars then still you need to bundle them as war 如果您有很多罐子,那么您仍然需要将它们捆绑在一起作为战争

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

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