Difference between revisions of "Java"
|Line 1:||Line 1:|
Latest revision as of 19:10, 15 August 2022
The Oracle Java Development Kit (JDK) is a development environment for building applications, applets, and components using the Java programming language. The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the Java platform.
Memory Usage Note
Depending on the JDK version, java by default uses the lesser of 1/4 of the system memory or 1 (or 2) gigabyte(s) of RAM for its heap memory. So, when using java with programs that require more memory, you may want to specify the min and max heap sizes. You can do that by providing appropriate command line arguments to java/javac, for example
java -Xms128m -Xmx1024m -jar your_java_program.jar
or by setting the _JAVA_OPTIONS environment variable, like so:
export _JAVA_OPTIONS="-Xms128m -Xmx1024m"
The above options are set when you load the jdk module, so must be modified after loading the module.
Unfortunately, the _JAVA_OPTIONS environment variable overrides the command line "-Xms and -Xmx" switches instead of the other way around, so if you want to have direct control of the Java Heap Memory settings for every command you will need to make sure the _JAVA_OPTIONS variable is not set before you run the command that uses -Xms and -Xmx. To check the current value of the _JAVA_OPTIONS environment variable, run echo $_JAVA_OPTIONS. To unset the value of the _JAVA_OPTIONS environment variable, run unset _JAVA_OPTIONS.