{"id":2231,"date":"2020-03-19T16:14:45","date_gmt":"2020-03-19T16:14:45","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=2231"},"modified":"2020-04-07T18:27:29","modified_gmt":"2020-04-07T12:57:29","slug":"write-first-basic-java-program","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/write-first-basic-java-program\/","title":{"rendered":"Write your First Basic Java Program"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">So, have a Basic Example of JAVA Program :<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We need two software to generate a Java Program-&gt;<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\"> First one is the Java SE Development Kit<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The second one is a Text Editor<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">For this example, we\u2019ll use a notepad.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">A notepad is a simple editor involved with the Windows Operating System.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">We can use another text editor like NotePad++<\/span><\/li>\n<\/ul>\n<h2><b>Here are the few steps to the Compile and Run Java program:<\/b><\/h2>\n<p><b>Step 1)\u00a0<\/b><span style=\"font-weight: 400;\">Go to the Start menu and Open notepad by selecting Programs &gt; Accessories &gt; Notepad<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><b>Step 2)\u00a0<\/b><span style=\"font-weight: 400;\">Make a code for the first basic program.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Let\u2019s declare a class with the name Test.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Then declare the main method,\u00a0i.e., <\/span><i><span style=\"font-weight: 400;\">public<\/span><\/i> <i><span style=\"font-weight: 400;\">static void main(String args[]){<\/span><\/i><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Now write <\/span><i><span style=\"font-weight: 400;\">System.out.println (&#8220;First Program&#8221;);<\/span><\/i><span style=\"font-weight: 400;\">\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The above line displays the text First Program.<\/span><\/li>\n<\/ul>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-2232 aligncenter\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_50.png\" alt=\"\" width=\"636\" height=\"312\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_50.png 767w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_50-300x147.png 300w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/p>\n<p><b>Step 3)<\/b><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">Now, save the file as\u00a0<\/span><b>Basicprogram.java<\/b><span style=\"font-weight: 400;\">\u00a0and make sure to save the file in the working folder\u00a0<\/span><b>C:\\workspace<\/b><\/p>\n<p><b>Step 4)<\/b><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">Now, go and open the command prompt.\u00a0<\/span><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/b><span style=\"font-weight: 400;\">Go to Directory path <\/span><b>C:\\workspace<\/b><span style=\"font-weight: 400;\">.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0Then, compile the above code using the command,<\/span><\/p>\n<p><img decoding=\"async\" class=\"wp-image-2233 aligncenter\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_51.png\" alt=\"\" width=\"636\" height=\"58\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_51.png 824w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_51-300x27.png 300w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_51-768x70.png 768w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/p>\n<p><b>Step 5)<\/b><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">If you look in your working folder, you can see that a file named\u00a0<\/span><b>FirstProgram.class<\/b><span style=\"font-weight: 400;\">\u00a0has been created.<\/span><\/p>\n<p><b>Step 6)<\/b> <span style=\"font-weight: 400;\">Now, execute the code and enter the java command, followed by the class name.<br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0So, the expected output should be the \u2018First Program.\u2019<\/span><\/p>\n<p><b>Note: \u00a0 <\/b><span style=\"font-weight: 400;\">As we say,\u00a0Java is case sensitive Programming language.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, all the code, commands, and file names should are used in the consistent casing.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s have an example on case sensitive:<\/span><\/p>\n<p style=\"padding-left: 60px;\"><span style=\"color: #999999;\"><em><span style=\"font-weight: 400;\">int demo=1;<br \/>\n<\/span><span style=\"font-weight: 400;\">int DEMO=1;<\/span><\/em><\/span><\/p>\n<p><span style=\"font-weight: 400;\">*These are completely different variables.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><b>Step 7)<\/b><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">Now, copy the code and paste the same code in IDE like we say Eclipse the compiling and execution is done with the click of a button.<\/span><\/p>\n<p><img decoding=\"async\" class=\"wp-image-2234 aligncenter\" src=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_52.png\" alt=\"\" width=\"714\" height=\"405\" title=\"\" srcset=\"https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_52.png 877w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_52-300x170.png 300w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_52-768x435.png 768w, https:\/\/www.h2kinfosys.com\/blog\/wp-content\/uploads\/2020\/03\/Screenshot_52-390x220.png 390w\" sizes=\"(max-width: 714px) 100vw, 714px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, have a Basic Example of JAVA Program : We need two software to generate a Java Program-&gt; First one is the Java SE Development Kit The second one is a Text Editor For this example, we\u2019ll use a notepad. A notepad is a simple editor involved with the Windows Operating System.\u00a0 We can use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2410,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[443,442,58,437],"class_list":["post-2231","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorials","tag-basic","tag-first","tag-java","tag-program"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=2231"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/2231\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media\/2410"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=2231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=2231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=2231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}