How to compile single / multiple java files without restarting the server? Is there any Eclipse plugin for the same?

I want to compile several java files in my application without restarting Weblogic and Tomcat. Otherwise, it takes a lot of time. For this, I got one Hotswap plugin in Eclipse , but this does not work in all cases. He says that it works to compile a single file. Even if I use this, it does not work in all cases.

Is there any other way I can do this, or is there any other plugin / script / software that can help me with this?

If there are some open source versions, this will be very helpful.

Thanks at Advance.

+6
java compilation eclipse-plugin
source share
6 answers

One thing is compiling classes, but you also need a JAVA virtual machine to reload classes and use them, which is called hot swapping. For the best available hot swap of classes, you'll need something like javarebel . This allows you to reload much more types of code changes than regular JVM SUNs. If you run deployment in disassembled mode, you are free at home and can test any code change in a second or so. We are pretty testable, so I only use javarebel in that short phase when I build the whole application, but it works very well.

+7
source share

Java HotSpot VM does this automatically, but not in all cases ...

You must first start a debugging session, not a run session.

Then some changes will force to restart. The basic idea is that if the interface is to change the class (the sigs method, not the actual Java interface), the VM cannot replace the contents of the inline class.

For this you do not need a plug-in, but only a virtual machine of recent times.

This occurs under several circumstances, such as

  • add methods
  • removal methods
  • change method signatures
  • changing the class hierarchy (superclasses, implemented interfaces)

This can also happen if you introduce an error into the class. (For errors such as inconsistent braces)

When you save a Java file, eclipse compiles it. If there is an error, eclipse throws an exception to indicate that there is an unresolved compilation error. (This is done at startup, you do not just see the last successful compilation, making it obvious that you have a compiler error)

+2
source share

I do not know Eclipse, but I use Netbeans. Netbeans does this pretty well. The latest version even has the ability to automatically recompile when saving a java file.

I know that this does not exactly answer your question. You can probably use both Netbeans and Eclipse depending on which part of the project you are working on.

EDIT: With Tomcat, you can reload the web application. This is really only useful if Tomcat is looking at a new class. If your project is first compiled into the assembly directory and then a WAR is created, you can go into Tomcat and install the web application and instead of specifying the WAR point in the assembly directory.

In Tomcat, you may need to install a site configuration file under the name tomcat / conf / Catalina / localhost. The contents of this file are as follows:

<?xml version="1.0" encoding="UTF-8"?> <Context docBase="C:/Projects/MyWebApp/build/web" path="/MyWebApp"/> 

Overload instructions here: http://www.cs.ucl.ac.uk/teaching/java/tomcatfaq.html#changeservlet

If you do this several times, though Tomcat will run out of memory. This is due to what is called PermGenSpace. Read about it if you want to know more. The solution is to increase the JVM memory, PermGenSize (with -XX: MaxPermSize) and finally restart Tomcat.

EDIT2: If reloading the application results in a logout, you can easily get a container for serializing session data to disk by adding "implements Serializable" to some of your classes. Then you will not need to log in after restarting the application.

+1
source share

I agree that it is very difficult to relocate all the time of development.

I suggest you take a look at MyEclipse, which has a very good hotdeploy mechanism that works well with Tomcat, and which is fairly affordable and has a 30-day trial version.

Eclipse's patented Java EE engine for redistribution to the server is nowhere fast.

+1
source share

I think I don’t see where the problem is. This is what I do, and changes change almost instantly. I have an Ant script that compiles .java and .jsp files for me, puts them in the appropriate directories in webapps and modifies the web.xml file if necessary (or at least touches it to notify tomcat of the changes). If you need help executing any of these using Ant, I would be happy to help. Btw I do not use WAR files for deployment on my test machine. I think it would be much slower.

0
source share

very easy to do if you are reading this page: See http://blog.redfin.com/devblog/2009/09/how_to_set_up_hot_code_replacement_with_tomcat_and_eclipse.html Thanks, Dan Fabulich.

0
source share

All Articles