E
E
Eugene2019-12-24 12:56:24
Java
Eugene, 2019-12-24 12:56:24

How to pass Java 9 Options to Tomcat 9?

How to pass in Tomcat 9 Java Options for Java 9+ (such as --add-exports, -add-reads, etc.) if Tomcat is running as a Windows service?
According to the documentation , you can only pass -X and -D options, but how do you pass everything else? If you pass the parameters as is (for example --add-reads), then Tomcat will not start because it does not recognize the parameters.
Adding Java Options to catalina.bat and setenv.bat doesn't work, as those scripts don't seem to be called when Tomcat is started as a service.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-12-24
@Jek_Rock

I asked myself and
I will answer) Despite what is written in the documentation, you can pass options like "--add-reads" with the --JvmOptions9 parameter. But Tomcat does not fully support the Java 9 options format. For example, it understands "--add-opens=java.desktop/java.awt=ALL-UNNAMED" but does not start with "--add-opens java.desktop/java. awt=ALL-UNNAMED" (with a space instead of "=")
Well, in addition, I will write a few points due to which the Tomcat service in Java 9+ under Windows may also not start:

  • Java options for Java 9+ must be specified in a specific order.
    For example, first there should be module-path, then add-modules, then patch-module (if needed) and then everything else. At the same time, if you run without Tomcat or with it but not as a service, then the order is not important
  • Check for a space after each option.
    For example, if you write "--add-reads=java.desktop=ALL-UNNAMED" (with a space at the end), then the JVM will give you "Unknown module: ALL-UNNAMED specified to --add-reads" and you will search for a long time for what not so with "ALL-UNNAMED"
  • Don't forget that for Tomcat ";" is the parameter separator.
    When passing multiple parameters to the classpath via ";" this character must be escaped with single quotes "';'"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question