$ cat Test.java
public class Test {
public static void main(String[] args) throws Throwable {
sun.tools.jcmd.JCmd.main(args);
}
}
$ javac --add-exports jdk.jcmd/sun.tools.jcmd=ALL-UNNAMED Test.java
jdk.jcmd is not in the default root set. --add-modules jdk.jcmd should be required. If missing, a warning is emitted at runtime. Error when it attempts to access the internal type at runtime.
$ java --add-exports jdk.jcmd/sun.tools.jcmd=ALL-UNNAMED Test
WARNING: Unknown module: jdk.jcmd
Exception in thread "main" java.lang.NoClassDefFoundError: sun/tools/jcmd/JCmd
at Test.main(Test.java:9)
Caused by: java.lang.ClassNotFoundException: sun.tools.jcmd.JCmd
at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@9-internal/BuiltinClassLoader.java:366)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@9-internal/ClassLoaders.java:185)
at java.lang.ClassLoader.loadClass(java.base@9-internal/ClassLoader.java:424)
... 1 more