错误:找不到或加载主类–Xmx1G

问题描述

应使用连字符减号(U + 002D)时使用破折号(U + 2013)。

 –Xmx1G # incorrect: en dash
 -Xmx1g # correct: hyphen-minus

解决方法

这太疯狂了; 有人看过吗?

java –Xmx1G –Xms1G –XX:+UseG1GC -XX:+PerfDisableSharedMem -jar service-1.0-SNAPSHOT.jar
Error: Could not find or load main class –Xmx1G

我可以做这个:

java -jar service-1.0-SNAPSHOT.jar –Xmx1G –Xms1G –XX:+UseG1GC -XX:+PerfDisableSharedMem

jmap -heap {PID}表明它完全忽略了这些选项。我尝试了不同的变化:

java –XX:+UseG1GC -jar service-1.0-SNAPSHOT.jar –Xmx1G –Xms1G  -XX:+PerfDisableSharedMem
java -Xms1G -Xmx1G -jar service-1.0-SNAPSHOT.jar
java –xx:+useg1gc -jar service-1.0-SNAPSHOT.jar
java -server –XX::+UseG1GC -jar service-1.0-SNAPSHOT.jar`

我要么得到此错误: Error: Could not find or load main class {OPTION}

或它运行但忽略选项。

甚至java -XX:-UseConcMarkSweepGC -jar service-1.0-SNAPSHOT.jar被忽略:

jmap -heap 5879 
Attaching to process ID 5879,please wait... 
Debugger attached successfully. 
Server compiler detected. 
JVM version is 25.121-b13

using thread-local object allocation.  
Parallel GC with 8 thread(s)  
Heap Configuration:

MinHeapFreeRatio         = 0
MaxHeapFreeRatio         = 100
MaxHeapSize              = 4294967296 (4096.0MB)
NewSize                  = 89128960 (85.0MB)
MaxNewSize               = 1431306240 (1365.0MB)
OldSize                  = 179306496 (171.0MB)
NewRatio                 = 2
SurvivorRatio            = 8
MetaspaceSize            = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize         = 17592186044415 MB
G1HeapRegionSize         = 0 (0.0MB)

这是我的JVM:

java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13,mixed mode)

这发生在我的Mac和Alpine Docker映像中。有什么想法吗?

猜你在找的技术问答相关文章

如何检查配对的蓝牙设备是打印机还是扫描仪(Android)
是否允许实体正文进行HTTP DELETE请求?
如何将ZipInputStream转换为InputStream?
java.util.logging Java 8中的变量
PowerMockito.doReturn返回null
Java中的RESTful调用
Swing / Java:如何正确使用getText和setText字符串
特殊字符和重音字符
Android Studio中的ndk.dir错误
错误“找不到主类”