drip icon indicating copy to clipboard operation
drip copied to clipboard

Using drip for javac

Open sjl opened this issue 12 years ago • 5 comments

I'd like to use Drip to run javac commands (basically for checking the syntax of a file whenever I save it in Vim). I'm pretty sure javac ... is just a wrapper around a java command so it should be possible to use Drip instead. Any idea how I might do that?

sjl avatar Jul 11 '13 16:07 sjl

This should be possible. You'd need to figure out the equivalent command line for javac using java.

On Thu, Jul 11, 2013 at 9:37 AM, Steve Losh [email protected] wrote:

I'd like to use Drip to run javac commands (basically for checking the syntax of a file whenever I save it in Vim). I'm pretty sure javac ... is just a wrapper around a java command so it should be possible to use Drip instead. Any idea how I might do that?

Reply to this email directly or view it on GitHub: https://github.com/flatland/drip/issues/64

ninjudd avatar Jul 11 '13 21:07 ninjudd

Yep, that's what I'm looking for but can't seem to find. It would be nice to have it in Drip's docs since a lot of people would probably find it useful.

sjl avatar Jul 14 '13 21:07 sjl

The best I can find is that there's a programmatic interface for javac, so maybe write a small java program that takes the program to compile as an argument and uses the programmatic interface?

edit to add link to info on interface: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#proginterface

mattboehm avatar Nov 04 '13 15:11 mattboehm

Apologies in advance if this is a dumb/obvious observation, but my javac is a binary, and since the JRE includes the java command but doesn't ship a compiler, it seems like javac has to be much more than a wrapper around java (unless the JDK ships a different java command than the JRE?). What am I missing here?

http://openjdk.java.net/groups/compiler/ http://www.ahristov.com/tutorial/java-compiler/shell.html

trptcolin avatar Nov 04 '13 15:11 trptcolin

Although the modern way to do it is creating a java main class that use the javax.tools.JavaCompiler class it's still possible to use the deprecated sun.tools.javac.Main class:

java -classpath /usr/lib/jvm/default-java/lib/tools.jar sun.tools.javac.Main MyClass.java

@trptcolin I guess that the only reason why javac is not a script wrapper around java is that not all system offer decent builtin script capabilities.

jeromerobert avatar May 11 '14 09:05 jeromerobert