If your application is in (say) "myprogram.jar" and it depends on "javax.mail.jar", then you would run it like this:
$ java -cp myprogram.jar:javax.mail.jar com.test.myprogram.Main
(On Windows, you need to use ; instead of : as the classpath separator.)
However, it doesn't make a lot of sense to have "myProgram.java" and "anotherProgram.java" BOTH declare a Main class ... by which I assume you mean a class called Main. The problem is that since both versions of the Main class are in the same package, compiling one source file will overwrite the Main class produced when you compile the other source file.