{"id":293,"date":"2021-01-03T21:06:25","date_gmt":"2021-01-03T21:06:25","guid":{"rendered":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/?page_id=293"},"modified":"2021-01-03T21:07:06","modified_gmt":"2021-01-03T21:07:06","slug":"the-helloworld-example","status":"publish","type":"page","link":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/course-topics\/the-java-environment-2\/the-helloworld-example\/","title":{"rendered":"The HelloWorld Example"},"content":{"rendered":"\n<p>Here&#8217;s the prototypical first Java application &#8212;\u00a0<strong><code>HelloWorld.java<\/code><\/strong>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\npublic class HelloWorld \n{\n    public static void main(String&#x5B;] args)\n    {\n        System.out.println(&quot;Hello World!&quot;);\n    }\n}\n<\/pre><\/div>\n\n\n<p>That&#8217;s about as small as a Java application gets!<\/p>\n\n\n\n<p>Compile it:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>javac HelloWorld.java<\/strong><\/pre>\n\n\n\n<p>which produces a&nbsp;<code><strong>HelloWorld.class<\/strong><\/code>&nbsp;file.<\/p>\n\n\n\n<p>Then execute it:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>java HelloWorld<\/strong><\/pre>\n\n\n\n<p><strong><em><u>Note:<\/u><\/em>&nbsp;<\/strong>We&#8217;re executing the&nbsp;<em><strong>class<\/strong><\/em>, not the file!<\/p>\n\n\n\n<p>It should output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Hello World!!<\/strong><\/pre>\n\n\n\n<p>followed by a newline.<\/p>\n\n\n\n<p><strong><em><u>Note:<\/u><\/em><\/strong>\u00a0In the real world, the actual command line contents are more complex than this.\u00a0IDEs simplify things by doing all the nitty-gritty nasty stuff under the covers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s the prototypical first Java application &#8212;\u00a0HelloWorld.java: That&#8217;s about as small as a Java application gets! Compile it: javac HelloWorld.java which produces a&nbsp;HelloWorld.class&nbsp;file. Then execute it: java HelloWorld Note:&nbsp;We&#8217;re executing the&nbsp;class, not the file! It should output: Hello World!! followed by a newline. Note:\u00a0In the real world, the actual command line contents are more complex [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":263,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_eb_attr":"","_uag_custom_page_level_css":"","ocean_post_layout":"left-sidebar","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"ocs-course-topics-sidebar","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","footnotes":""},"class_list":["post-293","page","type-page","status-publish","hentry","entry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"ocean-thumb-m":false,"ocean-thumb-ml":false,"ocean-thumb-l":false},"uagb_author_info":{"display_name":"Bryan Higgs","author_link":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/author\/bryan\/"},"uagb_comment_info":0,"uagb_excerpt":"Here&#8217;s the prototypical first Java application &#8212;\u00a0HelloWorld.java: That&#8217;s about as small as a Java application gets! Compile it: javac HelloWorld.java which produces a&nbsp;HelloWorld.class&nbsp;file. Then execute it: java HelloWorld Note:&nbsp;We&#8217;re executing the&nbsp;class, not the file! It should output: Hello World!! followed by a newline. Note:\u00a0In the real world, the actual command line contents are more complex&hellip;","_links":{"self":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":1,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/293\/revisions"}],"predecessor-version":[{"id":294,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/293\/revisions\/294"}],"up":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/pages\/263"}],"wp:attachment":[{"href":"https:\/\/bhiggs.x10hosting.com\/PracticalJavaProgramming\/wp-json\/wp\/v2\/media?parent=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}