How to fix "Unrecognized VM option 'UseConcMarkSweepGC'" error? - java

I have followed the instructions for getting started with codenameone in IntelliJ, yet when I set up my first project, based on the sample app I get this error:
"C:\Program Files\Java\jdk-15.0.1\bin\java.exe" -Xms128m -Xmx1014m -XX:ReservedCodeCacheSize=512m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes=\"\" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\lib\idea_rt.jar=61544:C:\Program Files\JetBrains\IntelliJ IDEA 2020.3.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\out\production\justtrivia;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\src;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\lib\CodenameOne.jar;C:\Users\reinp\OneDrive - beuthhs\beuth\Patterns und Frameworks\justtrivia\JavaSE.jar;native\internal_tmp;lib\impl\cls" com.codename1.impl.javase.Simulator com.patrickreinbold.justtrivia.JustTrivia
Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Process finished with exit code 1
I saw that this has to do with Java 8 but in the IntelliJ instructions it says nothing about using Java 8. Is Java 8 always necessary or can codenameone run with Java 15, too?
EDIT:
I have now got it to open by simply copying the first line with the java command and removing the UseConcMarkSweepGC flag, then running it in terminal. But I am still not sure if that is "the correct way" to do it or if something could break along the way now.

Ignore unsupported VM options with another option:
-XX:+IgnoreUnrecognizedVMOptions

This is a problem with the netbeans build script but this isn't really relevant as Codename One only supports Java 8 and Java 11 (at this time) so you should use one of those versions at the moment.

run export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

Homebrew users:
Comment out these lines
# /usr/local/etc/elasticsearch/jvm.options
## GC configuration
#-XX:+UseConcMarkSweepGC
#-XX:CMSInitiatingOccupancyFraction=75
#-XX:+UseCMSInitiatingOccupancyOnly
Then if you get
Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m'
Update the logging file path
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
to
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/usr/local/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
Sources
Brew installed Elasticsearch 7.9.2 failing on macOS
https://stackoverflow.com/a/57993824/2237510

Related

How to build an ARM Gnueabi openjdk11 JRE with JMX support

I've successfully build an openjdk 11 JDK for my target board (based on Gnueabi ARM).
Then with JDK Jlink I successfully created a custom JRE which I was able to run on my target.
Now I'd like to remote debug with JStatd or JMX, but when I start java with
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8855
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
I got this error
-Dcom.sun.management is not supported in this VM.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I already created a custom JRE with all the possible Java 11 modules with the command
sudo qemu-arm -L /usr/arm-linux-gnueabi jdk/bin/jlink --no-header-files --no-man-pages --module-path jmods --compress=2 --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.instrument,java.logging,java.management,java.management.rmi,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.se,java.security.jgss,java.security.sasl,java.smartcardio,java.sql,java.sql.rowset,java.transaction.xa,java.xml,java.xml.crypto,jdk.accessibility,jdk.attach,jdk.charsets,jdk.compiler,jdk.crypto.cryptoki,jdk.crypto.ec,jdk.dynalink,jdk.editpad,jdk.hotspot.agent,jdk.httpserver,jdk.jartool,jdk.javadoc,jdk.jcmd,jdk.jconsole,jdk.jdeps,jdk.jdi,jdk.jdwp.agent,jdk.jfr,jdk.jlink,jdk.jshell,jdk.jsobject,jdk.jstatd,jdk.localedata,jdk.management,jdk.management.agent,jdk.management.jfr,jdk.naming.dns,jdk.naming.rmi,jdk.net,jdk.pack,jdk.rmic,jdk.scripting.nashorn,jdk.sctp,jdk.security.auth,jdk.security.jgss,jdk.xml.dom,jdk.zipfs --output jre_all_modules
but I got the same "-Dcom.sun.management is not supported in this VM." error.
Since the target is an embedded board, with restricted amount of RAM, the goal is to got the minimun set of modules needed to run openjdk 11 JMX or JStatd.
Thanks to all in advance

Java, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED

I have newly installed
IntelliJ IDEA 2021.2 (Ultimate Edition)
Build #IU-212.4746.92, built on July 27, 2021
Licensed to XXXXXX
Subscription is active until August 15, 2021.
Runtime version: 11.0.11+9-b1504.13 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-80-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 3
Kotlin: 212-1.5.10-release-IJ4746.92
Current Desktop: X-Cinnamon
I cloned project I work with on other workstation without issues, but cannot start any class with main method and IDEA says:
Abnormal build process termination:
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=-5972351880001011455 -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US -Didea.paths.selector=IntelliJIdea2021.2 -Didea.home.path=/home/pm/idea-IU-212.4746.92 -Didea.config.path=/home/pm/.config/JetBrains/IntelliJIdea2021.2 -Didea.plugins.path=/home/pm/.local/share/JetBrains/IntelliJIdea2021.2 -Djps.log.dir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/log/build-log -Djps.fallback.jdk.home=/home/pm/idea-IU-212.4746.92/jbr -Djps.fallback.jdk.version=11.0.11 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server/rfg-survey-api_cc70fc05/_temp_ -Djps.backward.ref.index.builder=true -Djps.track.ap.dependencies=false --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -Dtmh.instrument.annotations=true -Dtmh.generate.line.numbers=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"/tmp/kotlin-idea-12426594439704512301-is-running\" -classpath /home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-launcher.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/lib/tools.jar org.jetbrains.jps.cmdline.Launcher /home/pm/idea-IU-212.4746.92/lib/slf4j.jar:/home/pm/idea-IU-212.4746.92/lib/idea_rt.jar:/home/pm/idea-IU-212.4746.92/lib/platform-api.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/forms_rt.jar:/home/pm/idea-IU-212.4746.92/lib/util.jar:/home/pm/idea-IU-212.4746.92/lib/annotations.jar:/home/pm/idea-IU-212.4746.92/lib/3rd-party.jar:/home/pm/idea-IU-212.4746.92/lib/kotlin-stdlib-jdk8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/jna-platform.jar:/home/pm/idea-IU-212.4746.92/lib/protobuf-java-3.15.8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders-6.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/javac2.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/aether-dependency-resolver.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-javac-extension-1.jar:/home/pm/idea-IU-212.4746.92/lib/jna.jar:/home/pm/idea-IU-212.4746.92/lib/jps-model.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-http-1.3.3.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/jasper-v2-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-reflect.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/ant/lib/ant-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/uiDesigner/lib/jps/java-guiForms-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-common.jar:/home/pm/idea-IU-212.4746.92/plugins/IntelliLang/lib/java-langInjection-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-constants-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/maven/lib/maven-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/gradle-java/lib/gradle-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/devkit/lib/devkit-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-common.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/javaee-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/webSphereIntegration/lib/jps/javaee-appServers-websphere-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/weblogicIntegration/lib/jps/javaee-appServers-weblogic-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/JPA/lib/jps/javaee-jpa-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-compilerPatch.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-jps-common.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-common.jar org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 34781 9f0681bb-da2a-48db-8344-900ddeb29804 /home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server
Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I found other comment to check Lombok works and I see it is fine.
How to fix the problem?
Some configuration were rolled over by the update. How to get back to JDK8 :
Go to File > "Project Structure".
In the new window, in left tree, choose "Project Settings" > Project
Among params, look at "Project language level". For me the IJ update had changed it from "8" to "16". Hence the error. Just put it back to "8" and rollll!
You can delete the .idea folder and reimport your project again. I solved this issue in this way.
You are running the project via Java 1.8 and add the --add-opens option to the runner. However Java 1.8 does not support it.
So, the first option is to use Java 11 to run the project, as Java 11 can recognize this VM option.
Another solution is to find a place where --add-opens is added and remove it.
Check Run configuration in IntelliJ IDEA (VM options field) and Maven/Gradle configuration files for argLine (Maven) and jvmArgs (Gradle)
For Intellij using Maven, you can go to Preferences > Build, Execution, Deployment > Build Tools > Maven > Running Tests and uncheck argLine.
Disable argLine
My solution was to go into .idea -> workspace.xml and set ALTERNATIVE_JRE_ENABLED="false".
For Eclipse:
Also make sure that in your Run ->a Run Configurations (or Debug
Configurations) > Arguments tab for the launch configuration
you are using doesn't contain this option.
From Eclipse forum's Ed Merks' answer.

"Unrecognized option: --add-opens" Hyperledger Besu

I want to get started with Hyperledger Besu, after following the steps of the official documentation here and running the following command:
bin\besu --help
I get the following error:
C:\Users\user\Desktop\besu-1.3.9>bin\besu --help
Unrecognized option: --add-opens
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I get the same thing when running bin\besu or bin\besu -help.
I don't know if the problem is with java's installation or with hyperledger besu trying to run unvalid/unrecognised option bin\besu --add-opens. I tried uninstalling then reinstalling java but this did not solve the issue, here is java's version:
C:\Users\user>java -version
Picked up _JAVA_OPTIONS: -Xmx512m
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) Client VM (build 25.241-b07, mixed mode)
Any help would be appreciated!
I have no prior experience with the library which is in discussion, but I have just had a look at the official docs of the library which you are trying to use, and the installation instructions state that you require Java 11+ to complie
Hyperledger Besu requires:
MacOS High Sierra 10.13 or later versions
Java 11+ to compile; earlier versions are not supported.
From your question, it looks like your system is running Java8. Trying bumping it up to java 11 and try starting the binary again.
The script you're running adds --add-opens java.base/sun.security.provider=ALL-UNNAMED to the java command line that starts Besu. As others have noted, the --add-opens parameter was made available in Java 9; all it does is prevent a warning from being issued when any class uses reflection to access an internal JDK class (in this case, the Sun security package). I've been starting Besu without this parameter for weeks with no problems, so you could have simply removed the parameter from the Besu start script or -- better -- upgraded to at least the Java 11 or higher version that Besu expects. According to Oracle, this command line parameter will be removed eventually, but that's a problem for the Besu maintainers, not you.
change the java home version path from jdk8 path to jdk11 in environment variable
as
JAVA_HOME : {jdk11 directory path}

java returns VM error after upgrade in centos 6.5

I want to upgrade my jdk on a centos server, after some simple searches i found some solutions.
from this link you can see that the instructions are simple:
jdk 7 installation guide for centos
-install your jdk from rpm package or from source
-do some alternatives
-check the practical version (java -version)
and i go easy with the first two steps but in check version step i get this error:
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
i have also checked alternatives --config java and simbolic links.
i have also tried which command to find out what java is actually running and this was the link directoins.
/usr/bin/java -> /etc/alternatives/java -> /usr/java/jdk-1.8.0_40/bin/java
the weird point is when i run /usr/bin/java -version it is OK and it returns the version but when i run java without any prefix i got that error.
so what is the problem?
you may need to setup CLASSPATH variable so that jvm could load needed libraries.
see this post https://docs.oracle.com/javase/tutorial/essential/environment/paths.html

Can't debug intellij plugin - invalid initial heap size

I'm developing an intellij plugin and when i'm trying to run the plugin (or debug it) i keep getting the following error:
Could not create the Java virtual machine. Invalid initial heap size:
-Xms128m
The JVM parameters in the Run\Debug configurations are (by default):
-Xms128m
-Xmx512m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=64m
-XX:+UseCodeCacheFlushing
-ea
-Dsun.io.useCanonCaches=false
So eventually I can't debug or run my code.
JVM is unhappy because there are newline characters between options.
You can confirm this by copy-pasting VM Options into a text editor.
I met the same problem today. I solved this problem by making the checked and select the IDEA Plugin Sdk。My Idea version is 11.1.5. you can try it..

Categories

Resources