{"id":360,"date":"2012-02-21T15:17:31","date_gmt":"2012-02-21T23:17:31","guid":{"rendered":"http:\/\/www.hongyu.org\/wordpress\/?p=360"},"modified":"2012-02-21T15:18:09","modified_gmt":"2012-02-21T23:18:09","slug":"using-maven-to-run-a-java-main-class","status":"publish","type":"post","link":"https:\/\/www.hongyu.org\/wordpress\/?p=360","title":{"rendered":"Maven command to run a Java main class"},"content":{"rendered":"<p>There might be more than one Java classes in a Maven project that contains the main() function. To pick up a specific one to run, you can try the following command:<\/p>\n<p>[sourcecode]<br \/>\nmvn exec:java -Dexec.mainClass=&quot;my_main_class_name&quot;<br \/>\n[\/sourcecode]<\/p>\n<p>In case the memory is not enough, try the following command:<\/p>\n<p>[sourcecode]<br \/>\nexport MAVEN_OPTS=-Xmx1024m<br \/>\n[\/sourcecode]<br \/>\nwhere 1024m is the max heap memory<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There might be more than one Java classes in a Maven project that contains the main() function. To pick up a specific one to run, you can try the following command: [sourcecode] mvn exec:java -Dexec.mainClass=&quot;my_main_class_name&quot; [\/sourcecode] In case the memory is not enough, try the following command: [sourcecode] export MAVEN_OPTS=-Xmx1024m [\/sourcecode] where 1024m is the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.hongyu.org\/wordpress\/?p=360\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Maven command to run a Java main class&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/360"}],"collection":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=360"}],"version-history":[{"count":2,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":362,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/360\/revisions\/362"}],"wp:attachment":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}