Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy only java file without deploying the WAR

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?

like image 377
coure2011 Avatar asked Jul 24 '26 06:07

coure2011


2 Answers

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.

like image 137
Prakash K Avatar answered Jul 25 '26 19:07

Prakash K


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
like image 44
bpgergo Avatar answered Jul 25 '26 20:07

bpgergo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!