2
头图

The latest version of RockerMQ is currently 4.9.2, which does not work under Java 11:

 [rocketmq@localhost 00-rocketmq-4.9.2]$ java -version
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

[rocketmq@localhost 00-rocketmq-4.9.2]$ bin/mqnamesrv 
-Djava.ext.dirs=/jre/lib/ext:/home/rocketmq/00-rocketmq-4.9.2/bin/../lib:/lib/ext is not supported.  Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit

The related issue is here , it has been fixed, and the fix will be released in version 4.9.3.

We can see that the main reason for the failure to run is because of the JVM parameters in the startup script.

Speaking of which, I would like to advise you not to include a lot of -XX: parameters in the script when you publish similar open source projects. These should be left to the user to adjust, because you do not know what the user uses. What kind of JVM, you don't force users to "optimize", just leave a gap.

Since it is a script problem, then modify the script:

Open runserver.sh and runbroker.sh (the corresponding .cmd suffix under Windows), and make the following modifications (remember to backup before modification):

  1. Find the line containing the -Djava.ext.dirs parameter, and delete or comment out the line;
  2. Find the line containing the -Xloggc parameter, delete or comment out the line;
  3. Find the line containing the -XX:+UseGCLogFileRotation parameter, delete or comment out the line;
  4. Find the line containing export CLASSPATH= (in the front part of the file) and change the content after the equal sign to .:${BASE_DIR}/conf:${BASE_DIR}/lib/*:${CLASSPATH}
  5. Find the line containing the -XX:-UseLargePages parameter and add a line below it JAVA_OPT="${JAVA_OPT} --add-exports java.base/jdk.internal.ref=ALL-UNNAMED"

With this modification, RocketMQ can be successfully started under Java 11.


捏造的信仰
2.8k 声望272 粉丝

Java 开发人员