Compiling multiple packages using the command line in Java

Hi i have been using an IDE but now I need to run and compile from the command line.

The problem is that I have multiple packages and I have tried to find the answer but nothing has worked.

So I have

src/
  Support/ (.java files)
  Me/ (.java files) 
  Wrapers/ (.java files)  

Do you know how to compile everything with javac?


Solution 1:

This should do it (may require additional classpath elements via the -cp command line switch):

javac Support/*.java Me/*.java Wrapers/*.java

But if your build process gets more complex (and it will!), you should look into using Apache Ant for build automation.

Solution 2:

You should use build tools like Maven or Ant for such tasks.

In the initial stages, when the project is not very complex you can use the following line to compile, with appropriate classpath in place(as suggested by @Michael):

javac Support/*.java Me/*.java Wrapers/*.java