本文介绍了错误:无法找到或加载主类-Xmx1G的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这太疯狂了;

  java -Xmx1G -Xms1G -XX:+ UseG1GC -XX:+ PerfDisableSharedMem -jar service- 1.0-SNAPSHOT.jar 
错误:无法找到或加载主类-Xmx1G

I可以这样做:

  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服务-1.0-SNAPSHOT.jar
java -xx:+ useg1gc -jar服务-1.0-SNAPSHOT.jar
java -server - XX :: + UseG1GC -jar service-1.0-SNAPSHOT.jar`

我得到这个错误:
错误:无法找到或加载主类{OPTION}



或者它运行但忽略选项。


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

  jmap -heap 5879 
附加到进程ID 5879,请等待...
调试器成功连接。
检测到服务器编译器。
使用线程局部对象分配的JVM版本是25.121-b13


8个线程的并行GC
堆配置:

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版本1.8.0_121
Java™SE运行时环境(build 1.8.0_121-b13)
Java HotSpot™64位服务器虚拟机(版本25.121-b13,混合模式)

这发生在我的Mac和Alpine Docker镜像中。任何想法?

解决方案

当你应该使用连字符减号(U + 002D)。

  -Xmx1G#不正确:破折号
-Xmx1g#正确:连字符减号







This is crazy; has anyone ever seen this before?

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

I can do this:

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

but jmap -heap {PID} shows that it's ignoring the options completely. I've tried different variations:

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`

I either get this error:Error: Could not find or load main class {OPTION}

Or it runs but ignores options.

Even java -XX:-UseConcMarkSweepGC -jar service-1.0-SNAPSHOT.jar is ignored:

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)

This is my 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)

This is happening on my Mac, and in Alpine Docker image. Any thoughts?

解决方案

You used an en-dash (U+2013) when you should have used a hyphen-minus (U+002D).

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

这篇关于错误:无法找到或加载主类-Xmx1G的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 11:24