问题
% java11 -Xlog:gc*:file=c:\max.txt -version
[0.002s][error][logging] Invalid decorator '\max.txt'.
Invalid -Xlog option '-Xlog:gc*:file=c:\max.txt', see error log for
details.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Apparently with Java 9 (and later) unified logging a colon is used as a separator between fields in the -Xlog
arguments. So, how do I specify a Windows pathname that has a colon in it? Is there an escape of some kind? If I specify the filename as is, I get the error I included above. Thank you.
回答1:
One of the ways suggested for solving that on the mailing list is using shell escapes like:
java -Xlog:gc*:file=\"C:\max.txt\" -version
Note that according to Dave Holmes' posting, only double quotes are supported. Depending on the shell, the escaping is necessary so that the Java command sees the quotes.
来源:https://stackoverflow.com/questions/52955773/how-to-use-a-windows-filename-with-a-colon-with-java-9-unified-logging