{"id":5197,"date":"2021-03-23T12:13:04","date_gmt":"2021-03-23T12:13:04","guid":{"rendered":"https:\/\/ded9.com\/?p=5197"},"modified":"2025-10-22T13:05:29","modified_gmt":"2025-10-22T13:05:29","slug":"learn-hello-world-in-java-in-very-simple-language","status":"publish","type":"post","link":"https:\/\/ded9.com\/de\/learn-hello-world-in-java-in-very-simple-language\/","title":{"rendered":"Learn \u201cHello World\u201d in Java: Easy Step-by-Step Guide"},"content":{"rendered":"<section class=\"l-section wpb_row us_custom_687840d3 height_auto width_full\">\n<div class=\"l-section-h i-cf\">\n<div class=\"g-cols vc_row type_default valign_top\">\n<div class=\"vc_col-sm-12 wpb_column vc_column_container\">\n<div class=\"vc_column-inner us_custom_e1309d51\">\n<div class=\"wpb_wrapper\">\n<div class=\"w-post-elm post_content us_custom_9c8713ca\">\n<p><span style=\"font-size: 12pt; font-family: georgia, palatino, serif;\">Hello World! It is a simple program that outputs Hello, World! Prints on the screen. Because the program is so simple, it is usually used to introduce a new programming language to a new user.<\/span><span id=\"more-50033\"><\/span><\/p>\n<p>Let&#8217;s check out how &#8220;Hello World!&#8221; works.<\/p>\n<p>To run this program on your System, ensure Java is installed correctly. You also need an IDE (or text editor) to write and edit <a href=\"https:\/\/en.wikipedia.org\/wiki\/Java_(programming_language)\" target=\"_blank\" rel=\"noopener\">Java<\/a> <a href=\"https:\/\/ded9.com\/top-15-websites-for-you-to-learn-to-code-for-free-in-2024\/\">code<\/a>.<\/p>\n<h2>Hello World application in Java<\/h2>\n<h2><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-258204 size-full\" src=\"https:\/\/ded9.com\/wp-content\/uploads\/2021\/03\/1671094828273-Hello-World-Program-in-Java.jpg\" alt=\"Hello World application in Java\" width=\"1200\" height=\"628\" srcset=\"https:\/\/ded9.com\/wp-content\/uploads\/2021\/03\/1671094828273-Hello-World-Program-in-Java.jpg 1200w, https:\/\/ded9.com\/wp-content\/uploads\/2021\/03\/1671094828273-Hello-World-Program-in-Java-300x157.jpg 300w, https:\/\/ded9.com\/wp-content\/uploads\/2021\/03\/1671094828273-Hello-World-Program-in-Java-1024x536.jpg 1024w, https:\/\/ded9.com\/wp-content\/uploads\/2021\/03\/1671094828273-Hello-World-Program-in-Java-768x402.jpg 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/h2>\n<blockquote>\n<ol>\n<li dir=\"ltr\">\/\/ Your First Program<\/li>\n<li dir=\"ltr\">class HelloWorld {<\/li>\n<li dir=\"ltr\">public static void main (String [] args) {<\/li>\n<li dir=\"ltr\">System.out.println (\u201cHello, World!\u201d);<\/li>\n<li dir=\"ltr\">}<\/li>\n<li dir=\"ltr\">}<\/li>\n<\/ol>\n<\/blockquote>\n<p>If you copied the code accurately, save the File name HelloWorld.java because the class name and filename in Java must match.<\/p>\n<p>When you run the program, the output is:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Hello, World!<\/pre>\n<\/div>\n<h2>&#8220;Hello World!&#8221;\u00a0How does it work in Java?<\/h2>\n<p dir=\"ltr\"><strong>\u00a0\/\/ Your First Program<\/strong><\/p>\n<p>In Java, any line starting with \/\/ is a comment.\u00a0Comments to read the description of the code and understand more about it.\u00a0The Java compiler completely ignores these lines (the application that executes Java code for the computer).<\/p>\n<p dir=\"ltr\"><strong>\u00a0class HelloWorld\u2026\u2026<\/strong><\/p>\n<p>In Java, every program starts with a class definition. In the above program, HelloWorld is the class name, and the class definition is:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">class HelloWorld {\r\n\r\n\u2026 ..\u2026\r\n\r\n}<\/pre>\n<\/div>\n<p>Remember that every Java program has a class definition, and the class name must match the File name in Java.<\/p>\n<p dir=\"ltr\"><strong>public static void main (String [] args) {\u2026\u2026<\/strong><\/p>\n<p>The top line is the primary method. Every Java program must have a main method. The Java compiler starts executing the code using the primary process.<\/p>\n<p>Remember that the primary function is the Java entry point of the mandatory program. The signature of the primary function in Java is equal to:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">public static void main (String [] args) {\r\n\r\n\u2026 ..\u2026\r\n\r\n}\r\n<span style=\"font-family: 'courier new', courier, monospace;\">System.out.println (\"Hello, World!\");<\/span><\/pre>\n<\/div>\n<p>The above code prints the String inside the quotation mark in the standard output (screen). Note, this is the line of code inside the primary function inside the class definition.<\/p>\n<h2>Important Points<\/h2>\n<ul>\n<li>Every valid Java program must have a class definition (which matches the File name).<\/li>\n<li>The primary function must be in the class definition.<\/li>\n<li>The compiler starts executing the code from the primary function.<\/li>\n<\/ul>\n<p>The following code is a valid Java program that does nothing.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-java&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">public class HelloWorld {\r\n\r\npublic static void main (String [] args) {\r\n\r\n\/\/ Write your code here\r\n\r\n}\r\n\r\n}<\/pre>\n<\/div>\n<p>If you do not understand the meaning of class, static, methods, and so on, do not worry. We will explain them in full in the following sections.<\/p>\n<h2>FAQ<\/h2>\n<div id=\"rank-math-rich-snippet-wrapper\"><div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-1\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What does the \u201cHello World\u201d program do in Java?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>It displays the text Hello World on the screen\u2014this simple program ensures your development setup is working correctly.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-2\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">Which tools do I need to write my first Java program?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>You\u2019ll need the Java Development Kit (JDK) installed and a basic text editor or an IDE like Eclipse or IntelliJ\u202fIDEA to write your code.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-3\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">How do I compile and run my Java program from the command line?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Save your code in a .java file, then run javac FileName.java to compile and java FileName to execute it, assuming your PATH is set correctly.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Hello World! It is a simple program that outputs Hello, World! Prints on the screen. Because the program is so simple, it is usually used to introduce a new programming language to a new user. Let&#8217;s check out how &#8220;Hello World!&#8221; works. To run this program on your System, ensure Java is installed correctly. You [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":5198,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11513],"tags":[3018,840],"class_list":["post-5197","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-2","tag-ide","tag-java"],"acf":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/posts\/5197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/comments?post=5197"}],"version-history":[{"count":4,"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/posts\/5197\/revisions"}],"predecessor-version":[{"id":263745,"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/posts\/5197\/revisions\/263745"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/media\/5198"}],"wp:attachment":[{"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/media?parent=5197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/categories?post=5197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ded9.com\/de\/wp-json\/wp\/v2\/tags?post=5197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}