tags:

views:

227

answers:

2

How to compile all files in directory to *.class files?

+3  A: 

Well, this seems pretty obvious, so I may be missing something

javac *.java

(With appropriate library references etc.)

Or perhaps:

javac -d bin *.java

to javac create the right directory structure for the output.

Were you looking for something more sophisticated? If so, could you give more details (and also which platform you're on)?

Jon Skeet
thank you, it works!
alex
+1  A: 

Here's a code fragment that I use to build an entire project where, as usual, source files are in a deeply nested hierarchy and there are many .jar files that must go into the classpath (requires UNIX utilities):

CLASSPATH=
for x in $(find | grep jar$); do CLASSPATH="$CLASSPATH:$x"; done
SRC=$(find | grep java$)
javac -cp "$CLASSPATH" $SRC
Kilian Foth