<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">In this tutorial, we will discuss how to write the hello world java program. Creating hello world java example is too easy. Here, we have created a class named ;<b>MyFirstJavaProgram ;</b>that contains only main method and prints a message &#8220;<b>hello world</b>&#8220;. It is the simple program of java. </div>
<p>
<b>Requirement for Hello World Java Example:</b></p>
<p></p>
<ul style="text-align: left;">
<li>create the java program.</li>
<li>install the JDK if you don&#8217;t have installed it, <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" target="_blank"><b>download the JDK</b></a> and install it.</li>
<li>set path of the bin directory under jdk.</li>
<li>compile and execute the program.</li>
</ul>
</div>
<div align='center' id="ads-id"></div>
<p>
 <b>Creating hello java example:</b><br />
Let&#8217;s create the hello world java program:</p>
<pre class="highlight" name="code">public class MyFirstJavaProgram { 
 
 /* This is my first java program. 
 * This will print 'Hello World' as the output 
 */ 
 
 public static void main(String []args) { 
 System.out.println("Hello World"); // prints Hello World 
 } 
} 
</pre>
</div>
<p>
Lets look at how to save the file, compile and run the program. Please follow the steps given below:</p>
<p></p>
<ul style="text-align: left;">
<li>Open notepad and add the code as above.</li>
<li>Save the file as : <b><i>MyFirstJavaProgram.java.</i></b></li>
<li>Open a command prompt window and go o the directory where you saved the class. Assume its ;F:Javas.</li>
<li>Type &#8216; <b><i>javac MyFirstJavaProgram.java </i></b>&#8216; and press enter to compile your code. If there are no errors in your code the command</li>
<li>prompt will take you to the next line.( Assumption : The path variable is set).</li>
<li>Now type &#8216; <b><i>java MyFirstJavaProgram</i></b> &#8216; to run your program.</li>
<li>You will be able to see &#8216; <b>Hello World</b> &#8216; printed on the window.</li>
</ul>
<p></p>
<div style="background-color: #ff99cc;"><b>output:</b><br />
>;<br />
C : >; javac MyFirstJavaProgram.java<br />
C : >; java MyFirstJavaProgram <br />
<b>Hello World</b></div>
</div>
<p>
<b>Understanding first java program:</b><br />
Let&#8217;s see what is the meaning of <b>class, public, static, void, main, String[], System.out.println()</b>.</p>
<ul style="text-align: left;">
<li><b>class </b>is used to declare a class in java.</li>
<li><b>public </b>is an access modifier which represents visibility, it means it is visible to all.</li>
<li><b>static </b>is a keyword, if we declare any method as static, it is known as static method. The core advantage of static method is that there is no need to create object to invoke the static method. The main method is executed by the JVM, so it doesn&#8217;t require to create object to invoke the main method. So it saves memory.</li>
<li><b>void </b>is the return type of the method, it means it doesn&#8217;t return any value.</li>
<li><b>main </b>represents startup of the program.</li>
<li><b>String[] args</b> is used for command line argument. We will learn it later.</li>
<li><b>System.out.println()</b> is used print statement.</li>
</ul>
<div class="separator" style="clear: both; text-align: center;"><img border="0" height="289" src="https://dineshonjava.com/wp-content/uploads/2013/02/hellojava.png" width="600"/></div>
<p>
</div>
<p>
As displayed in the above diagram, write the <b>MyFirstJavaProgram</b> program of java in notepad and saved it as <b>MyFirstJavaProgram.java. </b>To compile and run this program, you need to open command prompt by <b>Start ->; All Programs ->; Accessories ->; command prompt</b>.</p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" height="292" src="https://dineshonjava.com/wp-content/uploads/2013/02/hellojava1.png" width="600"/></div>
</div>
<p></p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/java-basic-syntax/">Previous</a> <;<; ; ; || <a href="https://dineshonjava.com/core-java-baby-step-to-be-best-java-ian/">Index </a>||  ; >;>;<a href="https://dineshonjava.com/variable-and-datatype-in-java/">Next</a> >;>;</b></div>
<p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/java-basic-syntax/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/variable-and-datatype-in-java/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '564'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…