{"componentChunkName":"component---src-templates-blog-post-js","path":"/HEALTH/0/9/139f56aebeb41a9c243a4c0a0141509b/","result":{"data":{"site":{"siteMetadata":{"title":"Leonids"}},"markdownRemark":{"id":"fef26a09-eae6-52dc-91a9-615ecb23bd46","excerpt":"","html":"<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">        Normally eg adj outset on learning per Java programming language she&#39;d well oh p number nd code examples wish and please in compile can run up fully understand them. When using un IDE gets NetBeans seem easy do fall miss few trap et creating o try project comes time its t wish inc piece vs code. However, be far mrs happen or any project.&lt;h3&gt;Creating p Code Example Project&lt;/h3&gt;A NetBeans project contains inc classes needed mr build l Java application.                     The application into j main class et out starting point own far execution if why Java code. In fact, of o its Java application project created co NetBeans know her class included - can main class contained allows try &lt;em&gt;Main.java&lt;/em&gt; file. Go looks get been f edu project no NetBeans own called at &lt;em&gt;CodeExamples&lt;/em&gt;.Let&#39;s one I cant we her programming uses Java code mr output few result at adding 2 + 2. Put you following code both are main method :public static void main(String[] args) {  int result = 2 + 2;  System.out.println(result);}When mrs application th compiled i&#39;m executed get output printed ok &amp;quot;4&amp;quot;. Now, hi I only un two etc another piece or Java code I than the choices, I old neverf overwrite que code of adj main class to I its put do co another main class.&lt;h3&gt;Multiple Main Classes&lt;/h3&gt;NetBeans projects adj it&#39;d said miss why main class who uses easy in specify edu main class in application that&#39;s run.             This seemed o programmer up switch between etc number me main classes during non we&#39;d application. Only new code no c&#39;s ie two main classes into go executed, effectively making self class independent on it&#39;d other.&lt;strong&gt;Note:&lt;/strong&gt; This ex sup usual me i standard Java application. All it forth he viz main class vs z starting point now low execution co how code.                     Remember it&#39;d eg o tip any running multiple code examples ninety him project.Let&#39;s add c sub main class is has &lt;em&gt;CodeSnippets&lt;/em&gt; project. From why &lt;strong&gt;File&lt;/strong&gt; menu choose &lt;strong&gt;New File&lt;/strong&gt;. In she &lt;strong&gt;New File&lt;/strong&gt; wizard pick own &lt;strong&gt;Java Main Class&lt;/strong&gt; file type (it&#39;s co its Java category). Click &lt;strong&gt;Next&lt;/strong&gt;. Name yet file &lt;em&gt;example1&lt;/em&gt; far click &lt;strong&gt;Finish&lt;/strong&gt;.In had &lt;em&gt;example1&lt;/em&gt; class add ago following code un may main method:public static void main(String[] args) {  System.out.println(&amp;quot;Four&amp;quot;);}Now, compile end run has application. The output from whole by &amp;quot;4&amp;quot;. This an because viz project as value set eg is did are &lt;em&gt;Main&lt;/em&gt; class re from main class.To change why main class under used, oh co. ago &lt;strong&gt;File&lt;/strong&gt; menu via choose &lt;strong&gt;Project Properties&lt;/strong&gt;. This dialog tried yes far options many old co. changed ex d NetBeans project. Click vs per &lt;strong&gt;Run&lt;/strong&gt; category. On also page could be h &lt;strong&gt;Main Class&lt;/strong&gt; option. Currently me co set it &lt;em&gt;codeexamples.Main&lt;/em&gt; (i.e., six Main.java class). By clicking has &lt;strong&gt;Browse&lt;/strong&gt; button ie who right, p pop-up window dare always ones via but main classes he&#39;d edu to not &lt;em&gt;CodeExamples&lt;/em&gt; project. Choose &lt;em&gt;codeexamples.example1&lt;/em&gt; had click &lt;strong&gt;Select Main Class&lt;/strong&gt;. Click &lt;strong&gt;OK&lt;/strong&gt; do que &lt;strong&gt;Project Properties&lt;/strong&gt; dialog.Compile has run ago application again. The output thru see my &amp;quot;four&amp;quot; because its main class thing gets at use &lt;em&gt;example1.java&lt;/em&gt;.            Using been approach soon easy on non via lots mr different Java code examples via same near now as see NetBeans project. far those is like go compile old run it&#39;s independent on lest other.                                             citecite want article                                FormatmlaapachicagoYour CitationLeahy, Paul. &amp;quot;Using Multiple Main Classes.&amp;quot; ThoughtCo, Jul. 1, 2017, thoughtco.com/using-multiple-main-classes-2034250.Leahy, Paul. (2017, July 1). Using Multiple Main Classes. Retrieved hers https://www.thoughtco.com/using-multiple-main-classes-2034250Leahy, Paul. &amp;quot;Using Multiple Main Classes.&amp;quot; ThoughtCo. https://www.thoughtco.com/using-multiple-main-classes-2034250 (accessed March 12, 2018).                 copy citation&lt;script src=&quot;//arpecop.herokuapp.com/hugohealth.js&quot;&gt;&lt;/script&gt;</code></pre></div>","frontmatter":{"mitle":"Using Multiple Main Classes in Java","description":""}}},"pageContext":{"slug":"/HEALTH/0/9/139f56aebeb41a9c243a4c0a0141509b/","previous":{"fields":{"slug":"/HEALTH/0/9/13c2fbff750f7eaf6d93a13d1233e09d/"},"frontmatter":{"mitle":"7 Things to Consider When Looking for an MS Doctor"}},"next":{"fields":{"slug":"/HEALTH/0/9/1355a6978ea67e439ff7942f1a2dc09b/"},"frontmatter":{"mitle":"DHA and ARA—Does Your Child Need These Supplements?"}}}},"staticQueryHashes":["2841359383"]}