O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compiling into a Directory Other Than Your Source Directory

It is common practice, and it's a good thing, to keep your source files in one directory and your class files in another. Typically, when you start a project you do something like this:

/application root dir
/application root dir/src
/application root dir/classes

You create two directories under the root of your application. Put all of your source files under the src directory and compile such that your classes go into the classes directory. Then you can use the JAR archiving tool to package just your classes and deploy those when your application is done.

By default, the javac tool compiles your classes into the same directory that the source file is in. So, you need to pass a command ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required