Just replace javac with javacx in your command to compile Java source files. It's that's simple.
Javacx comes with a C command that launches it, although it's actually a java application. The command "javacx" is equivalent to "java javacx ...." if javacx.jar is on your classpath.
By default JavaCX does nothing other than pass options on to the standard compiler. The current version does not support argument files. To preprocess files use any of the following options :
To chain commands just list them in the order you want them applied. For example the command javacx -javacx:cmd "doathing" -javacx:cpp wibble.java will compile wibble.java ( and any source fles javac would normally automatically compile with it ), preprocessing each file with first the "doathing" command and then the standrad C preprocessor. A developer might other tools, for example, a tool that generates java source from some other language. There's no limit here but what the developer ( and their system memory ) can do.
There are some other options which most people will not need :
You can also chain multiple commands together. This allows quite complex preprocessing to be achieved using pretty much any command line tool that can take input on standard-in and send output to standard-out.
A little more detail :
Each source file found by the compiler will be processed by the standard C preprocessor using the options "-C -P -nostdinc -" which tell the C preprocessor to leave comments in place ( useful as some Java tools use comments for other purposes ), not put line numbers and finally use standard in for input ( and the C preprocessor defaults to standard out for output ).
Uses the gcc command ( GNU C Compiler ) to invoke it's C Preprocessor. This may be useful if that compiler supports options that the default C proprocessor on yoru system does not.
Uses an arbitrary command for processing the sources. Remember : you may need to take care to preserve the command as one argument, most likely using quotes around the command. Note that javacx -javacx:cpp wibble.java and javacx -javacs:cmd "cpp -C -P -nostdinc -" wibble.java will do the same thing, but we have to wrap the Cpp command in quotes to keep it's options together.
Cap is a preprocessing utility I wrote to compliment the C preprocessor. It provides additional features I find useful. THere is a java version of cap ( originally a C application ) which handles multibyte characters properly ( which the C version does not ).
It's perhaps worth mentioning that the C code from the original cap tool was relatively easy to port to java precisely because I had javacx to handle the macros. As C programmers will understand, it's common to wrap common operations and types in macro definitions. This greatly simplifies porting the code from C to Java ( which is uses many C style language features. ).
Exactly what you'd expect : prints the javacx version to stdout. Note that you can still pass the -version option to javac, so javacx -version gets you version of the Java compiler, not the version of javacx. I felt this was more intuitive, although arguably less logical.
Maybe your classpath includes something that interferes with javacx or there's someother reason, but this option lets you pass a classpath to the javacx launcher to use a different class path just fdr javacx itself. The standard compiler will still use the normal classpath. The path argument should be in the format your platform's java and javac commands expect.
A debugging aid in case your preprocessed code is not compiling as you'd expect. Outputs the results of each proprocessing stage to standard out. This if off by default.
Should not be needed ( ever ), but for completeness this turns off the echoing of preprocessing output to standard-out.
Again a debugging aid. Lets you see the arguments as received by javacx ( and subseqeuently passed to javac ). Might be useful if you think your shell is doing something you did not expect to the arguments.