Compiling
D:> javac myprogram\com\example\Hello.javaand then the Hello.class file will be created in the same folder as Hello.java.
If your program is using third-party libraries and they are in D:\myprogram\libs, then:
D:> javac -cp "D:\myprogram\libs" myprogram\com\example\Hello.java
Running
D:> java -cp "D:\myprogram" com.example.Hello
If there are third-party libraries in D:\myprogram\libs folder, then:
D:> java -cp "D:\myprogram\libs\*;D:\myprogram" com.example.Hello