considering the following command
java -Xmx1024M -jar app.jar arg0 arg1
The question is, how could I get the java input arguments here? I mean how could I get the -Xmx1024M
?
Thanks in advance
considering the following command
java -Xmx1024M -jar app.jar arg0 arg1
The question is, how could I get the java input arguments here? I mean how could I get the -Xmx1024M
?
Thanks in advance
You can list arguments by using RuntimeMXBean:
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
Unfortunately it's not possible to change java heap size limits at runtime
If all you want to do is ensure that your application has sufficient memory, you can use the Runtime.getRuntime().maxMemory()
or Runtime.getRunetime.totalmemory()
methods, depending on your needs.