How do i compile all java classes from multiple packages/directories with a single javac command?

Question: Often when we have java classes in a package/sub-package structure, we would like to compile all of them with a single javac command. We expect that because of dependencies between java classes across packages all code would get compile automatically, if we simply try to compile the main class or package. But this does not happen (from command-line javac).

Put all the path to all java code you want to compile one after another with a space between them.

For eg: to compile classes in package and, we do this:
javac com/abc/*.java com/abc/def/*.java -d output


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: