Sunday, February 04, 2007

Makefile to compile java programs

The following is the makefile to compile java programs:

all: | remove_classes ProxyServer.class

rm -f *.class

javac -nowarn

The order of execution of jobs within the makefile can be normal or we can specify the order. The jobs listed after the pipe (|) are all orderly, as mentioned above.

all: | first second third

Makefile can be executed as:
> make

If target-name is omitted, then the first job is run. So in the first job, we name it as "all" and then there we specified the jobs it should run, along with the order. It is simple to understand that the current make file removes all old class files and then compiles the java program to get the latest class files. Though this is not needed, as javac would update the class files, this simple example helps us to understand "make".

Have fun!

No comments: