I have a jar file which is run only through script in Windows due to 4G RAM allocation,like this:
java -Xmx4g MyApp.jar
and it hangs when clicking on the jar file, the question is whether it is possible to put an error message in the java program that says if the user clicks the jar file It should run the script
A solution that allocates RAM programmatically, like this:
, is not very convenient
This did not help either
Edit: I came up with this idea:
long heapSize = Runtime.getRuntime().totalMemory();
Double heapSizeG= Double.valueOf(heapSize/1000000000);//This condition is inappropriate because the heapSize is not expected
if(heapSizeG >3 ) //it is false after java -Xmx4g MyApp.jar, why?
{
//Do Something(); //not working
}