I want to set the default Java heap size to 1024m without needing to specify the -Xmx option every time I run a jar file.
export JAVA_OPTIONS=-Xmx1024m to .bashrc file but it didn't work.
The maximum heap size is not the maximum amount of memory the JVM will use, but the heap size is what Xmx actually sets.
Regarding settings, it seems there maybe issues with
JAVA_OPTIONS, a more bulletproof method would be to add this to
alias java='java -Xms1024m'
Or, since environment variables are interpolated in an alias:
alias java='java $MY_JAVA_OPTS'
This gives you some flexibility if you want to add or override $MY_JAVA_OPTS for some session:
MY_JAVA_OPTS="$MY_JAVA_OPTS -Xprof -Xdiag"