3

I have a jsp based web application.

The source is kept in C:/MyApp/src. Here it contains the controllers and other .java files.

After building the application via eclipse. I copied the .war file to Apache/WebApps folder. Apache Tomcat expanded it and the web-application is working perfectly.

From the last couple of days I edited a lot of pages directly in Apache/WebApps folder. Now I want to edit a .java file in C:/MyApp/src/..

Now I want to use that updated .java file in my Apache/WebApps but don't want to rebuild the whole code via eclipse. If I do so my changes that I made in Apache/WebApps folder will be lost.

What should I do?

Prakash K
  • 11,669
  • 6
  • 51
  • 109
coure2011
  • 40,286
  • 83
  • 216
  • 349
  • Apache is not an Program, Apache is an Foundation. Im pretty sure, the Foundation does not extract your WAR-Files. Please be more specific. ;) – Grim Jul 27 '12 at 11:12
  • @coure2011 I think you are using Apache Tomcat if I am not wrong and not apache? – Prakash K Jul 27 '12 at 15:21

3 Answers3

2

you should

  1. merge back all you modifications from the deployment folder (Apache/WebApps) to the source folder (C:/MyApp/src/). Make sure you can rebuild the current version from the sources.
  2. start using some sort a version control tool, even if you work only on your local machine (I recommend Git)
  3. start using build tool, instead of having Eclipse build your war from the sources. I recommend Maven or Ivy
Community
  • 1
  • 1
bpgergo
  • 15,669
  • 5
  • 44
  • 68
  • -1 You are right, but this does not solve his problem. He congrete dont like to have the WebApps-folder deleted. Neither maven nor ant would help here. – Grim Jul 27 '12 at 11:24
2

Follow the changes as suggested by @bpgergo or else ...

You can configure your tomcat server with Eclipse and are starting and stopping the server from eclipse then you can add your project to the configured Server in eclipse.

Eclipse can be configured to auto-deploy the changes to the server, so whenever you change anything like a JSP or a java file the server will automatically take the changes without you deploying your WAR file.

But since java changes are not hot-deployable eclipse would restart the server whenever you save changes to your java file.

If you want to deploy java changes without restarting the server you can also try using JRebel (it is free for 30 days :-)).

For now I would suggest (if you don't want to go the above mentioned way. The following is a very crude method and should be avoided in the future)

  1. compile the .java file into a .class in eclipse.
  2. shut-down the server
  3. copy the .class file to the exact location on the server in WEB-INF/classes/..
  4. restart the server
  5. This would keep your JSP changes intact and also will reflect the .java changes

Hope this helps.

Community
  • 1
  • 1
Prakash K
  • 11,669
  • 6
  • 51
  • 109
0

Install the Plugin

http://andrei.gmxhome.de/filesync/index.html

And work with extracted war-files.

Grim
  • 1,938
  • 10
  • 56
  • 123
  • I don't think this answers the question, since he is talking about a `.java` file, java files are unlike jsp and require a deployment to reflect the changes. This tool will just sync the files from file system with eclipse. – Prakash K Jul 27 '12 at 15:24
  • Eclipse compile .java to .class right? The plugin the .class-files to the Server too! Then the deployment-scanner of the server starts up. Thats all deployment! (http://www.youtube.com/watch?v=OMtcjgTyP-g @ 4min) – Grim Jul 28 '12 at 08:08