Is there a way to tell jvm to look for a class with entry main method automatically rather than to specify it when invoking java ClassWithMainMethod?
In other words, I have directory with many compiled classes one of which has main method and I want to only specify that directory.
No, there is no way to do that. You can create an executable jar, and define what the main class is in the jar manifest, allowing you to use
though.
See http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html
You may also deliver your app with a script which executes the appropriate command for you: