From Oracle's documentation
... Class paths to the .jar, .zip or .class files. Each classpath should end with a filename or directory depending on what you are setting the class path to:
For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file.
For .class files in an unnamed package, the class path ends with the directory that contains the .class files.
For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).
Source
This then means that -cp dynamiclib\*
won't work. If dynamic lib contains jars, you must specify each jar in the classpath, if it contains class files then defining the folder (without the *) should be enough, unless you have classes defined in the unnamed package AKA the default package.