How do I compile to a different location?
Author: Deron Eriksson
Description: This Java tutorial shows how to compile a Java class to a different location.
Tutorial created using: Windows XP || JDK 1.6.0_10

By default, execution of the "javac" compiler produces .class files in the same directory where the source code files are located. This location for the generated .class files can be changed using the "-d" switch.

I have a file in my C:\stuff directory. Within the C:\stuff directory is another directory, C:\stuff\bin. I'll compile the Howdy javaSW file to a class file which will be placed in the bin directory via:

javac -d bin

After compilation, we can see that the Howdy.class file has been created in the bin directory.

Compiling class files to a different location