Java 9 options - add-export vs. -XaddExports not recognized

I downloaded the latest jdk9 build:

java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+142) Java HotSpot(TM) Server VM (build 9-ea+142, mixed mode) 

When i do

 /path/jdk-9/bin/java -X 

I see an option:

 --add-exports <module>/<package>=<target-module>(,<target-module>)* updates <module> to export <package> to <target-module>, regardless of module declaration. <target-module> can be ALL-UNNAMED to export to all unnamed modules. 

But when I try to use this option:

 /path/jdk-9/bin/java --add-exports:java.base/jdk.internal.ref=ALL-UNNAMED -jar some.jar 

I get:

 Unrecognized option: --add-exports:java.base/jdk.internal.ref=ALL-UNNAMED 

The same for -XaddExports , which I saw in some posts.

What am I doing wrong here?

Do I need a special jdk9 jigsaw distribution? I'm a little confused about the different versions of jdk9, to be honest;)

+7
java java-9
source share
1 answer

Two flags have a slightly different syntax. At one point (I think it was build 9-ea + 113), where the JVM switched from -XaddExports to the -XaddExports --add-exports syntax, as part of the effort for JEP 293 , which aims to create a GNU style syntax for command arguments strings.

Current syntax:

 --add-exports <module>/<module>/<package>=<target-module>(,<target-module>)* --add-reads <module>=<target-module>(,<target-module>)* 

Note. Some utilities may have a problem accepting a new style of arguments --key value , because there is a space between them, in this case you can also put an equal sign in the middle (i.e. --key=value ) to satisfy these communal services.

Old syntax:

 -XaddExports:<module>/<module>/<package>=<target-module>(,<target-module>)* -XaddReads:<module>=<target-module>(,<target-module>)* 

Unfortunately, itโ€™s very easy to skip the colon change space. I spoiled it myself several times.

+10
source share

All Articles