Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faster javac/ant?

I find java starts up and runs practically instantly for me - but javac takes a few seconds, and ant makes it slower again. It's only a few seconds, but my edit-compile-test loop would be smoother without it. :-)

BTW: I've already used vim's ":make" with ant.

Is there a way to speed up javac and/or ant? I'm thinking of special switches, or tricks? Or maybe an alternative java compiler (I'm using 1.6, in linux)

like image 496
13ren Avatar asked Apr 27 '09 14:04

13ren


1 Answers

Eclipse does that for you ... but it's probably a bit big as a "patch" for your problem.

That aside, you can roll your own compiler plugin. There are two approaches:

  1. Run the java compiler from within ant (instead of creating a new process). Not sure if ant already does that; if not, that will save you a bit of time. Look at the Java 6 compiler API for details.

  2. Run javac in a server process which listens for options on a socket. In ant, send the process the command line and wait for the output to be sent back. Saves you starting a new process all the time.

  3. Try to use the eclipse compiler. Unlike the original javac, the Eclipse compiler is pretty good at "ignoring" errors, so it can produce class files even when they contain errors. That doesn't seem to mean much but it allows you to compile all the time in the background. When you do your last save (wrapping everything up), the compiler will have been able to compile everything else and will just have to look at a single file.

like image 57
Aaron Digulla Avatar answered Sep 22 '22 13:09

Aaron Digulla