Use the -classpath (aka -cp) or -sourcepath arguments to set base source locations. Use the -classpath argument to specify binary dependencies (jar files or base .class file directories). Use the -d argument to specify the output directory.
One thing to watch out for is that namespaces (packages) must match directory structures.
C:\temp>dir /B /S
C:\temp\bin
C:\temp\foo
C:\temp\src
C:\temp\src\foo
C:\temp\src\foo\Bar.java
C:\temp\src\foo\Baz.java
C:\temp>type src\foo\Bar.java
package foo;
public class Bar extends Baz {}
C:\temp>javac -cp .\src -d .\bin src\foo\Bar.java
C:\temp>dir /B /S
C:\temp\bin
C:\temp\foo
C:\temp\src
C:\temp\bin\foo
C:\temp\bin\foo\Bar.class
C:\temp\bin\foo\Baz.class
C:\temp\src\foo
C:\temp\src\foo\Bar.java
C:\temp\src\foo\Baz.java
A class file declaring package foo;
must be in the directory foo
. A class file declaring package foo.foo;
must be in the directory foo\foo
and so on.
See the documentation for javac. See here for more extensive classpath
documentation.