Search code examples
javaamazon-web-servicesjvmjvm-argumentsg1gc

Error when setting G1 GC on Elastic Bean Stalk


I'am trying to set G1 GC on elastic bean stalk using JVM options by UI using the following argument: –XX:+UseG1GC.

But when i try to restart the instance, the following error is thrown:

Error: Could not find or load main class ?XX:+UseG1GC

Why this is happening ?

Some informations:

java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

Environment:

Tomcat 8 with Java 8 running on 64bit Amazon Linux/2.6.2

Solution

  • You are using en dash character instead of hyphen - character. The JVM options are defined with a hyphen, it should be (notice the short -):

    -XX:+UseG1GC