5

I want to know how I can make changes in my code and run it on server directly from my eclipse IDE in place of converting my project every time to war file and deploy it on server.

I don't want to see my changes reflecting only by converting it to war file and deploying it every time on server.. can i see them on the fly directly through my eclipse IDE as soon as make some changes..

Plz help me i don't know exactly what to search on google .So seeking "SO" help.

Thanks in advance.

PS: Sorry My bad!!! I should have given more information... I am working on Spring Hibernate based project ...which is having only java files

Anupam Gupta
  • 1,591
  • 8
  • 36
  • 60

5 Answers5

3

You can use the Eclipse-WTP Plugin to handle your Web-Projects (http://www.eclipse.org/webtools). With this plugin you can create "dynamic web projects" which can deployed on a specified (Tomcat) server.

If you use maven and your project is structured like a maven-webapp(webapp-archetype), you can also use the m2eclipse-plugin to import your maven-project and run it on an server.

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
RicoZ
  • 835
  • 5
  • 16
2

There are so many different ways to do this, but here's one approach that may work for you (it's hard to tell because you haven't been specific about your container environment):

In the main method of a new Java application:

  • create an instance of a servlet container (e.g. Jetty or Tomcat)
  • register your application's servlets using the servlet container's API calls
  • create the relevant URL mappings for your static resources
  • start the HTTP server

Then, run this application in debug mode. You now have a mini environment running inside Eclipse.

sjr
  • 9,769
  • 1
  • 25
  • 36
  • Thanks sjr... but I am a newbie and not able to understand the step mentioned by you ... can you please elaborate more on the points ..It will be helpful if you can tell me step by step on how to do what.. i also saw one more link which is http://stackoverflow.com/questions/3723743/best-way-to-debug-java-web-application-packaged-as-a-war-using-eclipse-and-maven can you tell me the best and easiest way – Anupam Gupta Apr 19 '11 at 10:43
2

Following up on sjr's answer, the wicket quickstart archetype contains such a main class. Here it is:

Start.java (HEAD)

There is nothing wicket-specific about it, it can be used to run any Java webapp project

Copy it to src/test/java and execute it as a main class

you will need the following dependencies in your pom:

<dependency>
    <groupId>org.eclipse.jetty.aggregate</groupId>
    <artifactId>jetty-all-server</artifactId>
    <version>7.3.0.v20110203</version>
    <scope>provided</scope>
</dependency>
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
0

Everything can't be reflected on the fly

  • You can change images,javascript files,css such files on the fly.
  • Some files are there which are manipulated on the context initialization time, like(web.xml, spring conf files, and some other conf file ) So , You can't change them on the fly but you can change these and restart the server to see the effect.

  • Some Servlet and Java code needs to compile and you can change them on the fly if they were not loaded by classloader (You can't be 100% sure here)

jmj
  • 237,923
  • 42
  • 401
  • 438
0

You can use the HotSwap technologies through the WTP eclipse plug-in to see the effect of the your changed code without the need to redeploy the whole application to the application server. This link has a tutorial for how to setup the tomcat hot deploy using WTP eclipse plug-in .

But this HotSwap technologies has many limitations , for example , it only allows to change the method bodies but doesn't allow adding/removing classes ,fields , constructors , methods , annotations etc.And modification of the XML files and property files (eg web.xml , faces-config.xml ) cannot be reflected instantly .

JRebel can overcome these limitations but it is not free .It discuss the limitation of other alternatives free/open source here

Ken Chan
  • 84,777
  • 26
  • 143
  • 172