[
Bloke.com
|| Linux
|| JavaScript
|| Java
|| Volleyball
|| Link Me
]
Free: [ Guestbook || MessageBot || Plugins || Counter || AusPrices || Advertise ] |
This is kinda wierd, but I use it occasionally, and it's really a big hack, but maybe you'll find it useful. This tip shows you how to create a makefile that will allow you to run cpp on your java code.
First the simple (but more hacky version, you need to do: mkdir cpp, before you start). Assume you want to compile the classes file1.java and file2.java.
JCC=/usr/local/java/bin/javac JFLAGS=-g CPP=gcc -E DEST=/tmp/ .SUFFIXES: .class .java TARGETS= file1.class file2.class .java.class: /bin/rm -f dummy.c ln -s $< dummy.c $(CPP) dummy.c | grep -v '^#' > cpp/$< $(JCC) $(JFLAGS) cpp/$< cp cpp/*.class /home/cameron/xg/x/classes/ cp cpp/*.class ./ all: $(TARGETS) clean: /bin/rm -f *.classThe other version allows you to just run cpp on selected files. The files have the entension .javacpp will have the C Pre-processor run on them.
JCC=/usr/local/java/bin/javac JFLAGS= CPP=gcc -E .SUFFIXES : .class .java .javacpp .javacpp.java: cp $< $*.c $(CPP) $*.c | grep -v '^#' > $*.java chmod -w $*.java .java.class : $(JCC) $(JAVAFLAGS) $< all: Counter.class Connect.class mv *class $(DEST) Counter.class: Counter.java Counter.java: Counter.javacppNote that you need to add the dependences, otherwise when you change .javacpp, the file is still just built from the .java file.
In the above example, there are two sources files Connect.java, and Counter.javacpp. It is not neccessary to specify the Connect dependencies since it is simple.
Got Java questions? Maybe my Java Board has the answers?