javacommand-linepackagejavac

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

  • 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.