13

I'm stuck into the process of deploying created .jar files in Eclipse.

Eclipse is at location: E:\eclipse

Web project is at: E:\Runtime_Testing\src\study_to_night

Tomcat is at location: C:\apache-tomcat-7.0.54-windows-x64

Meanwhile, steps followed for creating jar files in Eclipse:

  1. Right click on your Java Project and select Export.
  2. Expand the Java node and select JAR file.
  3. In the JAR File Specification page, checked the option which says "Export Java source files and resources"
  4. Selected the export destination as: E:OneForAll.jar; OneForAll being the name of my .jar file
  5. Checked the option` "Compress the contents of the JAR Files"
  6. Next ---> Finish.

On following the above steps, an executable JAR file is created at the specified location. 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. However, on double-click it throws 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 ?

Diti
  • 1,454
  • 3
  • 23
  • 38
mindfreak
  • 456
  • 3
  • 9
  • 29

2 Answers2

14

So you have it running successfully within eclipse? But now you want to deploy this tested web app?

Then

  1. Right click on your Java Project and select Export.

  2. Expand the Web node and select WAR file.

This exports the WEB-INF and related files that tomcat needs.

This question answers what to do next How to deploy a war file in Tomcat 7

Community
  • 1
  • 1
MichaelStoner
  • 889
  • 10
  • 26
  • I'm in a confused state of mind. Will copying the **WAR** file in the tomcat webapp directory and restarting the server do the magic ?? – mindfreak Apr 24 '15 at 10:04
  • It should detect it automatically and extract the folders too. You can also use the tomcat manager app if you have enabled it. When I'm back at my desk I'll update my answer with the next steps as well. You are almost there – MichaelStoner Apr 24 '15 at 10:14
  • **Perfect !!!**... Would wait for your updated answer. In the meantime, let me also try it out on my end to find it out myself. – mindfreak Apr 24 '15 at 10:27
  • I've linked to another SO question http://stackoverflow.com/questions/5109112/how-to-deploy-a-war-file-in-tomcat-7 rather than adding it here as there is some useful information in most of the answers on that page. – MichaelStoner Apr 24 '15 at 10:33
  • @Stoner - **`It worked like a charm !!`** Was able to deploy the `WAR` file through **manager-gui**. – mindfreak Apr 24 '15 at 11:43
10

Apache tomcat is a web container you cannot deploy a jar in tomcat server. 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.

if you have lots of jars then still you need to bundle them as war

sunny
  • 303
  • 2
  • 7
  • **Great...** -----> Should it go specifically into some folder on just putting it in tomcat webapp directory should serve the purpose ? – mindfreak Apr 24 '15 at 09:29
  • it should work in the webapp directory. Just make sure your jar is a part of war file. – sunny May 03 '15 at 12:42