Error: Could not create the Java Virtual Machine. Spigot Minecraft - java

i'm trying to install spigot server on debian 10, when i run start.sh:
#!/bin/sh
while true
do
java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -
XX:+UnlockExperimentalVMOptions -$
echo "restarting in 10"
sleep 10
done
i've got this output:
i don't have any idea on how to fix it, any help?

The script seems to require an argument which should be the jar name.
Also, you put a wrong back to break line ("\n") which seems to break the bash.
For me, you should replace -$ by the jar file or spigot, like that:
#!/bin/sh
while true
do
java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions spigot-1.18.jar
echo "Restarting in 10 seconds"
sleep 10
done

The script is not correct.
#!/bin/sh
while true
do
java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 - XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar spigot.jar nogui
echo "restarting in 10"
sleep 10
done
Reference: https://www.vultr.com/docs/setup-spigot-on-debian-10/

Related

JVM Startup Flags Not Found

Run the start.sh on Alibaba Cloud Linux 3.2104 64bits
start.sh content:
#!/bin/sh
java -Xms3G -Xmx3G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200
-XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch
-XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M
-XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4
-XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90
-XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem
-XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs
-Daikars.new.flags=true -jar paper.jar nogui
then the console out put:
start.sh: line 4: -XX:+UnlockExperimentalVMOptions: command not found
start.sh: line 5: -XX:G1NewSizePercent=30: command not found
start.sh: line 6: -XX:G1ReservePercent=20: command not found
start.sh: line 7: -XX:InitiatingHeapOccupancyPercent=15: command not found
start.sh: line 8: -XX:G1RSetUpdatingPauseTimePercent=5: command not found
start.sh: line 9: -XX:MaxTenuringThreshold=1: command not found
start.sh: line 10: -Daikars.new.flags=true: command not found
java version:
OpenJDK Runtime Environment Corretto-17.0.2.8.1 (build 17.0.2+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.2.8.1 (build 17.0.2+8-LTS, mixed mode, sharing)```
I am not a native speaker, sorry for my poor explanation
Your command has multiple lines - in bash shell this must all be on one line or use the line continuation character. So you have two choices:
All on one line:
java -Xms3G -Xmx3G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paper.jar nogui
or use a line continuation
java -Xms3G -Xmx3G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 \
-XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch \
-XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M \
-XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 \
-XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 \
-XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem \
-XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs \
-Daikars.new.flags=true -jar paper.jar nogui

How to increase stack size eclipse.ini file

My rcp based launcher has launcher.exe which has some recursive call during class loading so getting a stack over flow error. To avoid it I have to increasing the stack size. but unable to launch the application through launcher.exe but works fine from a windows batch script
I found similar thread forum post about increasing stack size
but of not much help.
my eclipse.ini :
-startup
plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740
-vmargs
-Xms256m
-Xmx2048m
-Xss4m
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC
-XX:+ScavengeBeforeFullGC
-Declipse.buildId=44.1.2
But strangely though through a windows batch script this works perfectly fine:
#echo off
java -Dosgi.requiredJavaVersion=1.8 -Xms256m -Xmx256m -Xss2m -jar plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar -application xx.yy.zz.mm.application.application -showSplash splash.bmp
exit
Don't know why the -Xss agrument is not considered by eclipse.ini
environment : Windows7+eclipse Neon+ 64bit java1.8
xxx.product file has following entry for VM agruments:
<launcherArgs>
<vmArgs>-Xms256m -Xmx2048m -Xss4m
-XX:MaxGCPauseMillis=10 -XX:MaxHeapFreeRatio=70 -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:+ScavengeBeforeFullGC
</vmArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
</vmArgsMac>
<vmArgsWin>-Declipse.buildId=44.1.2
</vmArgsWin>
</launcherArgs>
I found oracle blog here so tried with -Xss4096k in ini file but of no luck yet! Don't know the difference between launching through ini and launching through the command line. looks as if both are same but surely they aren't.

weird tomcat7 on start

My Tomcat 7 Works fine, but when i retrieve the run command, return:
# ps -ef | grep java
tomcat7 18794 1 2 09:30 ? 00:01:09 /usr/lib/jvm/default-java/bin/java
-Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties
-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms2048m -Xmx2048m -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
-Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start root 20085 18341 0 10:13 pts/0 00:00:00 grep java
I can't remove the "-Xmx128m" parameter.
I change this files:
/usr/share/tomcat7/bin/setenv.sh
/usr/share/tomcat7/defaults.template
But the parameter persist.
The xmx & xms are assigned correctly to 2048m, but i want a correct start.
Did you search through this file ? :
/etc/default/tomcat7
Find the line with JAVA_OPTS="-Djava.awt.headless=true
and change the -Xmx128 parameter
Solved!.
Just edit /etc/default/tomca7 and change this line:
JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC"
to this:
JAVA_OPTS="-Djava.awt.headless=true -Xmx2048m -XX:+UseConcMarkSweepGC"

Play Framework Run Application Issue

I am getting the following error whenever i am trying to run a new Web Application created using Play.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
In Play framework 2.0.3, <play framework install dir>\framework\build.bat script you need to replace the command line argument for the command below
java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M %DEBUG_PARAM% -Dfile.encoding=UTF8 -Dplay.version="%PLAY_VERSION%" -Dsbt.ivy.home="%~dp0..\repository" -Dplay.home="%~dp0." -Dsbt.boot.properties="file:///%p%sbt/sbt.boot.properties" -jar "%~dp0sbt\sbt-launch.jar" %*
Into
java -XX:+CMSClassUnloadingEnabled %DEBUG_PARAM% -Dfile.encoding=UTF8 -Dplay.version="%PLAY_VERSION%" -Dsbt.ivy.home="%~dp0..\repository" -Dplay.home="%~dp0." -Dsbt.boot.properties="file:///%p%sbt/sbt.boot.properties" -jar "%~dp0sbt\sbt-launch.jar" %*
Just downloaded and unzipped 2.2.1 on my Windows 8 computer.
Followed the documentation at Play Framework website, and ended up having the same issue as you. Adjusting the various parameters in the build file didn't do anything, but the:
java -XX:+CMSClassUnloadingEnabled %DEBUG_PARAM% -Dfile.encoding=UTF8 -Dplay.version="%PLAY_VERSION%" -Dsbt.ivy.home="%~dp0..\repository" -Dplay.home="%~dp0." -Dsbt.boot.properties="file:///%p%sbt/sbt.boot.properties" -jar "%~dp0sbt\sbt-launch.jar" %*
... solved the problem.
I don't know where other people found this solution, but there's no mentioning of this solution on the Play Framework website. In fact, there's nothing to suggest that anything could go wrong. After all, it's just a file you need to unzip.
It's running now, however it's a little hard to trust a framework that screws up that early on. Seems the authors don't test on anything but Linux.
in 2.3 Play framework :
GO to :
C://Play2.3/framework/build.bat and open this file and make these changes.
Replace this line with below line.
java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M %DEBUG_PARAM% -Dfile.encoding=UTF8 -Dplay.version="%PLAY_VERSION%" -Dsbt.ivy.home="%~dp0..\repository" -Dplay.home="%~dp0." -Dsbt.boot.properties="file:///%p%sbt/sbt.boot.properties" -jar "%~dp0sbt\sbt-launch.jar" %*
java -XX:+CMSClassUnloadingEnabled %DEBUG_PARAM% -Dfile.encoding=UTF8 -Dplay.version="%PLAY_VERSION%" -Dsbt.ivy.home="%~dp0..\repository" -Dplay.home="%~dp0." -Dsbt.boot.properties="file:///%p%sbt/sbt.boot.properties" -jar "%~dp0sbt\sbt-launch.jar" %*
then type this command on command promt:
C:\Users\k.ashish\Downloads\play-2.2.3\play-2.2.3\yourapp>play
C:\Users\k.ashish\Downloads\play-2.2.3\play-2.2.3\yourapp>run
If you are not able to execute this command then set the play2.3 framework path in Environment variable in windows like java path .

Error Expanding Script Generated Classpath for Java in PowerShell Script

Synopsis:
I am trying to convert a shell script from UNIX to Powershell.
The script cannot "hardcode" the path, but must instead list a directory to dynamically build the path at runtime.
Also, the script must pass in 1 parameter to indicate the "type" of the run.
I am placing my "attempted" re-write of the script (after much googling/binging)
This script might be very close as the "echo" statements produced what seems to be correct.
$EXE_CLASS="com.sungard.sims.dacar.standalone.Dacar"
#$DACAR_TAG=%1
$JAVA_EXE="$ENV:JDK15\jre\bin\java"
#JAVA_EXE=\opt\java\bin\java
$JARS="dist\lib\Dacar-Engine.jar;dist\lib\Dacar-Common.jar;dist\lib\Dacar-Collector.jar;dist\lib\standalone-Dacar.jar;dist\lib\DACAR-CRG.jar;"
#dynamically append all .jar files from the jars directory.
ls jars\*.jar | % { $JARS +=";jars\"+ $_.name }
$JAVA_OPTS="-server -Xloggc:.\engine.gc.log -Xmx2048m -Xms2048m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:MaxTenuringThreshold=8 -XX:CMSInitiatingOccupancyFraction=60 -XX:+PrintGCTimeStamps -XX:MaxPermSize=128m -XX:PermSize=128m -DinstName=${DACAR_TAG} -DprocType=ENGINE"
echo "exe: -> $JAVA_EXE"
echo "opts: -> $JAVA_OPTS"
echo "jars: -> $JARS"
echo "class: -> $EXE_CLASS"
& $JAVA_EXE $JAVA_OPTS "-classpath .\configuration;$JARS $EXE_CLASS 1> dacar.out 2> dacar.err"
please note that I have commented out the use of the DACAR_TAG which would normally be passed in as %1 in batch script containing "TEST|DEV|PROD|QA|STRESS|[CLIENT SPECIFIC VALUE]"
Here is the output:
PS C:\dacar> .\startDacar.ps1
exe: -> c:\Program Files\Java\jdk1.5.0_22\jre\bin\java
opts: -> -server -Xloggc:.\engine.gc.log -Xmx2048m -Xms2048m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:MaxTe
nuringThreshold=8 -XX:CMSInitiatingOccupancyFraction=60 -XX:+PrintGCTimeStamps -XX:MaxPermSize=128m -XX:PermSize=128m -DinstName=TESTING -DprocType=ENGINE
jars: -> dist\lib\Dacar-Engine.jar;dist\lib\Dacar-Common.jar;dist\lib\Dacar-Collector.jar;dist\lib\standalone-Dacar.jar;dist\lib\DACAR-CRG.jar;;jars\activation.jar;jars
\commons-beanutils-1.6.jar;jars\commons-codec-1.3.jar;jars\commons-collections-3.2.jar;jars\commons-configuration-1.4.jar;jars\commons-dbcp-1.4.jar;jars\commons-digester
-1.6.jar;jars\commons-discovery-0.4.jar;jars\commons-id.jar;jars\commons-lang-2.2.jar;jars\commons-logging-1.0.3.jar;jars\commons-pool-1.5.4.jar;jars\concurrent.jar;jars
\graphics.jar;jars\ha-javamail-1.0-beta-1.jar;jars\hsqldb.jar;jars\ibatis-core-3.0.jar;jars\jcommon-1.0.6.jar;jars\jconn3.jar;jars\jdom.jar;jars\jetty-6.1.15.jar;jars\je
tty-util-6.1.15.jar;jars\jfreechart-1.0.3.jar;jars\jgroups-all.jar;jars\jmxri.jar;jars\jta.jar;jars\junit.jar;jars\log4j-1.2.9.jar;jars\mailapi.jar;jars\postgresql-8.0.3
09.jdbc2ee.jar;jars\postgresql-8.4-701.jdbc3.jar;jars\quartz-1.6.0.jar;jars\servlet-api-2.5-20081211.jar;jars\smtp.jar;jars\svnant.jar;jars\svnClientAdapter.jar;jars\svn
javahl.jar;jars\truezip-6.jar;jars\uic-optional.jar;jars\uic.jar
class: -> com.sungard.sims.dacar.standalone.Dacar
Unrecognized option: -server -Xloggc:.\engine.gc.log -Xmx2048m -Xms2048m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8 -XX:+UseParNewGC -XX:+UseConcMarkSweepG
-XX:MaxTenuringThreshold=8 -XX:CMSInitiatingOccupancyFraction=60 -XX:+PrintGCTimeStamps -XX:MaxPermSize=128m -XX:PermSize=128m -DinstName=TESTING -DprocType=ENGINE
Could not create the Java virtual machine.
Adding the tag will be my next question if I can't figure this out.
JUST AS AN FYI, from with in a ps1 script I can start it the program with the following command successfully:
& "c:\Program Files\Java\jdk1.6.0_20\jre\bin\java" -server -Xloggc:.\engine.gc.log -Xmx2048m -Xms2048m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:MaxTenuringThreshold=8 -XX:CMSInitiatingOccupancyFraction=60 -XX:+PrintGCTimeStamps -XX:MaxPermSize=128m -XX:PermSize=128m -DinstName=TESTING -DprocType=ENGINE -classpath ".\configuration;dist\lib\Dacar-Engine.jar;dist\lib\Dacar-Common.jar;dist\lib\Dacar-Collector.jar;dist\lib\standalone-Dacar.jar;dist\lib\DACAR-CRG.jar;;jars\activation.jar;jars\commons-beanutils-1.6.jar;jars\commons-codec-1.3.jar;jars\commons-collections-3.2.jar;jars\commons-configuration-1.4.jar;jars\commons-dbcp-1.4.jar;jars\commons-digester-1.6.jar;jars\commons-discovery-0.4.jar;jars\commons-id.jar;jars\commons-lang-2.2.jar;jars\commons-logging-1.0.3.jar;jars\commons-pool-1.5.4.jar;jars\concurrent.jar;jars\graphics.jar;jars\ha-javamail-1.0-beta-1.jar;jars\hsqldb.jar;jars\ibatis-core-3.0.jar;jars\jcommon-1.0.6.jar;jars\jconn3.jar;jars\jdom.jar;jars\jetty-6.1.15.jar;jars\jetty-util-6.1.15.jar;jars\jfreechart-1.0.3.jar;jars\jgroups-all.jar;jars\jmxri.jar;jars\jta.jar;jars\junit.jar;jars\log4j-1.2.9.jar;jars\mailapi.jar;jars\postgresql-8.0.309.jdbc2ee.jar;jars\postgresql-8.4-701.jdbc3.jar;jars\quartz-1.6.0.jar;jars\servlet-api-2.5-20081211.jar;jars\smtp.jar;jars\svnant.jar;jars\svnClientAdapter.jar;jars\svnjavahl.jar;jars\truezip-6.jar;jars\uic-optional.jar;jars\uic.jar" com.sungard.sims.dacar.standalone.Dacar
But that is not really an option, as That is just invoking the thing in a hard coded fashion.
One thing to note about PowerShell variable expansion is that if it's anything more than a simple $VARIABLE expression you typically need to escape it using curly braces or a sub-expression.
So this line:
$JAVA_EXE="$ENV:JDK15\jre\bin\java"
Could be represented as either:
$JAVA_EXE="${ENV:JDK15}\jre\bin\java"
or...
$JAVA_EXE="$($ENV:JDK15)\jre\bin\java"
EDIT: Apparently PowerShell does
correctly evaluate all 3 examples. I
seem to recall the first syntax not
working but perhaps that was in
PowerShell 1.0 or a CTP...
Another useful tip that I often suggest people do when working with external .exe commands is to map it to an alias using the Set-Alias command. This way it makes working with the command a lot more natural as you don't have to use the &"string" syntax.
Set-Alias java "$($ENV:JDK15)\jre\bin\java.exe"
java blah1 blah2 etc

Categories