Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to set module-path with JNI_CreateJavaVM?

Stephan BircherApr 6 2018 — edited Apr 16 2018

I could not find a way how to set the module path using JNI_CreateJavaVM in Java 9 (9.0.4). I was expecting something like -Djava.class.path which is used to set the class path.

The jdk.internal.module,ModuleBootstrap class uses the system property "jdk.module.path".

        // --module-path option specified to the launcher

        ModuleFinder appModulePath = createModulePathFinder("jdk.module.path");

    private static ModuleFinder createModulePathFinder(String prop) {

        String s = System.getProperty(prop);

        if (s == null) {

            return null;

        } else {

            String[] dirs = s.split(File.pathSeparator);

            Path[] paths = new Path[dirs.length];

            int i = 0;

            for (String dir: dirs) {

                paths[i++] = Paths.get(dir);

            }

            return ModulePath.of(patcher, paths);

        }

    }

However using -Djdk.module.path as JNI_CreateJavaVM argument is ignored with the following warning:

Java HotSpot(TM) 64-Bit Server VM warning: Ignoring system property options whose names match the '-Djdk.module.*'. names that are reserved for internal use.

Does anybody has an idea how to pass the module-path using JNI_CreateJavaVM. Or is there an alternative to create a jvm in Java9 which I have missed?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2018
Added on Apr 6 2018
1 comment
1,187 views