{"id":1134,"date":"2018-11-27T14:05:56","date_gmt":"2018-11-27T14:05:56","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=1134"},"modified":"2025-10-27T11:07:05","modified_gmt":"2025-10-27T11:07:05","slug":"javac","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/compilers\/javac\/","title":{"rendered":"Java Compilers"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>The Java compiler <code>javac<\/code> is available on the CSF but should <strong>not<\/strong> be used on the login node. You need to load one of the available openjdk modules.<\/p>\n<p>Version 1.8.0 of the OpenJDK is installed in the CSF. You do not need to load any module for using this. However, the <code>javac<\/code> compiler is not installed with it.<br \/>\nYou can use any of the the following openjdk modules if you need Java compiler:<\/p>\n<h2>Restrictions on use<\/h2>\n<p>None.<\/p>\n<h2>Set up procedure<\/h2>\n<p>Version 1.8.0 is the default JRE version available if no modulefile is loaded. The following modulefiles are also available if a specific version is required:<\/p>\n<pre>\r\nmodule load tools\/openjdk\/25.0.1               # JDK 25\r\nmodule load tools\/openjdk\/23.0.2               # JDK 23\r\nmodule load tools\/openjdk\/22.0.2               # JDK 22\r\nmodule load tools\/openjdk\/20.0.2               # JDK 20\r\nmodule load tools\/openjdk\/17.0.2               # JDK 17\r\nmodule load tools\/openjdk\/11.0.2               # JDK 11\r\n<\/pre>\n<h2>Running the application<\/h2>\n<p>As a quick test, create a file named <code>HelloWorld.java<\/code> using a text editor on the CSF (e.g. using <code>gedit<\/code>) which contains the following:<\/p>\n<pre>\r\npublic class HelloWorld {\r\n    public static void main(String[] args) {\r\n        System.out.println(\"Hello World\");\r\n    }\r\n}\r\n<\/pre>\n<p>Then compile the code using:<\/p>\n<pre>\r\njavac HelloWorld.java\r\n<\/pre>\n<p>Now run the code using:<\/p>\n<pre>\r\njava HelloWorld\r\n\r\n# It should print:\r\nHello World\r\n<\/pre>\n<p>Due to recent excessive memory usage on the login node, all processes running on that node are now restricted in their memory usage. The <code>javac<\/code> compiler will <strong>not<\/strong> execute on the login node, reporting a memory limit error:<\/p>\n<pre>\r\nError occurred during initialization of VM\r\nCould not reserve enough space for object heap\r\nCould not create the Java virtual machine.\r\n<\/pre>\n<p>You should start an interactive session using <a href=\"\/csf3\/batch-slurm\/srun\/\">srun<\/a> to launch a shell on a compute node that has more memory. You can then run <code>javac<\/code> as normal.<\/p>\n<h3>Interactive Usage<\/h3>\n<p>Request an interactive session using:<\/p>\n<pre>\r\nOn the login node:\r\nsrun -p interactive -n 1 -t 0-1 --pty bash\r\n  #\r\n  # Wait for a new prompt to appear (e.g., <code>[<em>username@node<em>770<\/em><\/em>]<\/code>)\r\n  #\r\njavac ...\r\n<\/pre>\n<h3>Running Compiled Java Code<\/h3>\n<p>Please read the <a href=\"\/csf3\/software\/tools\/java\">Java application launcher<\/a> notes for how to run java code in the batch system with the correct number of threads.<\/p>\n<h2>Further info<\/h2>\n<ul>\n<li><a href=\"\/csf3\/software\/tools\/java\/\" target=\"_blank\" rel=\"noopener\">OpenJDK and JAVA in CSF3<\/a><\/li>\n<li><a href=\"https:\/\/openjdk.org\/\" target=\"_blank\" rel=\"noopener\">OpenJDK Website<\/a><\/li>\n<\/ul>\n<h2>Updates<\/h2>\n<p>None.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview The Java compiler javac is available on the CSF but should not be used on the login node. You need to load one of the available openjdk modules. Version 1.8.0 of the OpenJDK is installed in the CSF. You do not need to load any module for using this. However, the javac compiler is not installed with it. You can use any of the the following openjdk modules if you need Java compiler: Restrictions.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/compilers\/javac\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":130,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1134","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/1134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=1134"}],"version-history":[{"count":15,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/1134\/revisions"}],"predecessor-version":[{"id":11266,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/1134\/revisions\/11266"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/130"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=1134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}