0

I need to pass the command line option, --add-exports, to java. Example:

--add-exports java.management/sun.management=ALL-UNNAMED

If I try to use the --java-opt for Coursier, it does not work and I get an error. It appears Coursier is not parsing the two word argument needed for --add-exports.

cs launch --java-opt --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED com.google.googlejavaformat:google-java-format:1.13.0 -- src/main/java/com/example/demo/DemoApplication.java

The error for the above example is

Cannot find app jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED in channels io.get-coursier:apps

What is the correct command line syntax for Couriser to pass the Java '--add-exports' option?

Found solution by using the Coursier -J syntax as documented here.

-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED

Dustin Shimono
  • 1,031
  • 7
  • 10
  • Have you tried `cs launch --java-opt "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED com.google.googlejavaformat:google-java-format:1.13.0" ...`? – Progman Jan 01 '22 at 16:38
  • @Progman No luck with the quotes like that either. I get an error saying the option is unrecognized. I'm using openjdk 16.0.1 2021-04-20. ❯ cs launch --java-opt "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" com.google.googlejavaformat:google-java-format:1.13.0 -- src/main/java/com/example/demo/DemoApplication.java JVMJ9VM007E Command-line option unrecognised: --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. – Dustin Shimono Jan 02 '22 at 17:32

0 Answers0