{"id":44549,"date":"2025-08-14T12:17:55","date_gmt":"2025-08-14T04:17:55","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=44549"},"modified":"2025-08-14T12:17:55","modified_gmt":"2025-08-14T04:17:55","slug":"java%e7%a8%8b%e5%ba%8f%e5%a6%82%e4%bd%95%e5%81%9a%e6%88%90exe%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2025\/ruanjiankf\/44549\/","title":{"rendered":"java\u7a0b\u5e8f\u5982\u4f55\u505a\u6210exe\uff1f"},"content":{"rendered":"<p>\u5728Java\u7a0b\u5e8f\u5f00\u53d1\u4e2d\uff0c\u7a0b\u5e8f\u6e90\u7801\u901a\u5e38\u4ee5.class\u6587\u4ef6\u4f5c\u4e3a\u8f93\u51fa\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\uff0c\u66f4\u76f4\u63a5\u548c\u53ef\u9760\u7684\u65b9\u5f0f\u662f\u5c06Java\u7a0b\u5e8f\u505a\u6210exe\u683c\u5f0f\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u672c\u6559\u7a0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06Java\u7a0b\u5e8f\u5236\u4f5c\u6210exe\u6587\u4ef6\u3002<\/p>\n<p>\u539f\u7406\u7b80\u4ecb\uff1a<\/p>\n<p>Java\u7a0b\u5e8f\u5728\u6267\u884c\u524d\u9700\u8981JVM\uff08Java\u865a\u62df\u673a\uff09\u8fdb\u884c\u89e3\u91ca\u8fd0\u884c\uff0c\u56e0\u6b64\u4e0d\u80fd\u50cfC\u3001C++\u7b49\u7f16\u8bd1\u578b\u8bed\u8a00\u4e00\u6837\u76f4\u63a5\u751f\u6210\u672c\u5730\u7684exe\u6587\u4ef6\u3002\u5c06Java\u7a0b\u5e8f\u505a\u6210exe\u6587\u4ef6\u5b9e\u9645\u4e0a\u662f\u5728Java\u7a0b\u5e8f\u4e0a\u9644\u52a0\u4e00\u4e2a\u542f\u52a8JRE\uff08Java Runtime Environment\uff09\u7684\u6865\u63a5\u5668\uff0c\u4f7f\u5f97\u7a0b\u5e8f\u80fd\u591f\u81ea\u52a8\u4f7f\u7528JRE\u8fd0\u884c\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u5236\u4f5cJava\u7a0b\u5e8fexe\u6587\u4ef6\u7684\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u7f16\u5199Java\u7a0b\u5e8f\u6e90\u7801<\/p>\n<p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b8c\u6210\u4e00\u4e2aJava\u7a0b\u5e8f\u7684\u5f00\u53d1\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684HelloWorld\u7a0b\u5e8f\u3002<\/p>\n<p>&#8220;`java<\/p>\n<p>public class HelloWorld {<\/p>\n<p>    public static void main(String[] args) {<\/p>\n<p>        System.out.println(&#8220;Hello, World!&#8221;);<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u7f16\u8bd1Java\u6e90\u7801\uff0c\u751f\u6210class\u6587\u4ef6<\/p>\n<p>\u4f7f\u7528JDK\uff08Java Development Kit\uff09\u4e2d\u7684`javac`\u547d\u4ee4\u7f16\u8bd1\u6e90\u4ee3\u7801<a href=\"https:\/\/www.yimenexe.com\/ruanjian-kaifa-2261.html\">python\u6253\u5305\u7684exe\u8fc7\u5927<\/a>\u3002<\/p>\n<p>&#8220;`bash<\/p>\n<p>javac HelloWorld.java<\/p>\n<p>&#8220;`<\/p>\n<p>\u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\u540e\uff0c\u4f60\u5c06\u5f97\u5230\u4e00\u4e2a\u540d\u4e3a`HelloWorld.class`\u7684\u7f16\u8bd1\u540e\u7684\u6587\u4ef6\u3002<\/p>\n<p>3. \u6253\u5305Java\u7a0b\u5e8f<\/p>\n<p>\u901a\u5e38\uff0cJava\u7a0b\u5e8f\u4f1a\u4f7f\u7528JAR\uff08Java Archive\uff09\u6587\u4ef6<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/28\/12\/35099795145.jpg\" \/><\/figure>\n<\/p>\n<p>\u8fdb\u884c\u6253\u5305\u3002\u521b\u5efaJAR\u6587\u4ef6\u7684\u8fc7\u7a0b\u53ef\u4ee5\u4f7f\u7528`jar`\u547d\u4ee4\u5b8c\u6210\u3002<\/p>\n<p>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a`manifest.txt`\u7684\u6e05\u5355\u6587\u4ef6\u3002\u5728\u6b64\u6587\u4ef6\u4e2d\uff0c\u6307\u5b9a\u4e3b\u7c7b\uff08\u5373main\u51fd\u6570\u6240\u5728\u7684\u7c7b\uff09\u3002<\/p>\n<p>&#8220;`<\/p>\n<p>Main-Class: HelloWorld<\/p>\n<p>&#8220;`<\/p>\n<p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06 HelloWorld.class \u6587\u4ef6\u548c manifest.txt \u6253\u5305\u6210\u4e00\u4e2a\u540d\u4e3a HelloWorld.jar \u7684JAR\u6587\u4ef6\u3002<\/p>\n<p>&#8220;`bash<\/p>\n<p>jar cvfm HelloWorld.jar manifest.txt HelloWorld.class<\/p>\n<p>&#8220;`<\/p>\n<p>4. \u5c06Java\u7a0b\u5e8f\u5236\u4f5c\u6210exe\u6587\u4ef6<\/p>\n<p>\u6709\u5f88\u591a\u5de5\u5177\u53ef\u4ee5\u5c06JAR\u6587\u4ef6\u8f6c\u6362\u6210exe\u6587\u4ef6\u3002\u672c\u6559\u7a0b\u5c06\u4ee5Launch4J\u5de5\u5177\u4e3a\u4f8b\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n<p>&#8211; \u4e0b\u8f7d\u5e76\u5b89\u88c5Launch4J\uff1a\u8bbf\u95ee [http:\/\/launch4j.sourceforge.net\/](http:\/\/launch4j.sourceforge.net\/) \uff0c\u4e0b\u8f7d\u5bf9\u5e94\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\uff0c\u5e76\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<p>&#8211; \u542f\u52a8Launch4J\uff0c\u5728\u201cBasic\u201d\u9009\u9879\u5361\u4e2d\u7684\u201cOutput file\u201d\u5b57\u6bb5\u4e2d\uff0c\u6307\u5b9a\u751f\u6210exe\u6587\u4ef6\u7684\u8def\u5f84\u548c\u540d\u79f0\uff0c\u4f8b\u5982\uff1a\u201cHelloWorld.exe\u201d\u3002<\/p>\n<p>&#8211; \u5728\u201cJAR\u201d\u7684\u5b57\u6bb5\u4e2d\uff0c\u6307\u5b9a\u4f60\u7684JAR\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u4f8b\u5982\uff1a\u201cHelloWorld.jar\u201d\u3002<\/p>\n<p>&#8211; \u82e5\u8981\u6307\u5b9a\u7279\u5b9a\u7684JRE\uff0c\u8f6c\u5230&#8221;JRE&#8221;\u9009\u9879\u5361\uff0c\u586b\u5199&#8221;Min JRE version&#8221;\u5b57\u6bb5\uff0c\u5982&#8221;1.8.0&#8243;\u7b49\u3002<\/p>\n<p>&#8211; \u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u201cBuild wrapper\u201d\u6309\u94ae\uff0c\u751f\u6210exe\u6587\u4ef6\u3002<\/p>\n<p><a href=\"https:\/\/www.yimenexe.com\/ruanjian-kaifa-6895.html\">\u600e\u4e48\u5f00\u53d1\u4e00\u4e2aexe<\/a><\/p>\n<p>5. \u8fd0\u884cexe\u6587\u4ef6<\/p>\n<p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u751f\u6210\u7684`HelloWorld.exe`\u6587\u4ef6\u3002\u65e0\u9700\u9884\u5148\u5b89\u88c5Java\u73af\u5883\uff0c\u7a0b\u5e8f\u5c06\u987a\u5229\u8fd0\u884c\u5e76\u8f93\u51fa\u201cHello, World!\u201d\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u5c06Java\u7a0b\u5e8f\u5236\u4f5c\u6210exe\u6587\u4ef6\u7684\u8be6\u7ec6\u8fc7\u7a0b\u3002\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u4e3a\u4efb\u4f55Java\u7a0b\u5e8f\u521b\u5efa\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Java\u7a0b\u5e8f\u5f00\u53d1\u4e2d\uff0c\u7a0b\u5e8f\u6e90\u7801\u901a\u5e38\u4ee5.class\u6587\u4ef6\u4f5c\u4e3a\u8f93\u51fa\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\uff0c\u66f4\u76f4\u63a5\u548c\u53ef\u9760\u7684\u65b9\u5f0f\u662f\u5c06Java\u7a0b\u5e8f\u505a\u6210exe\u683c\u5f0f\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u672c\u6559\u7a0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06Java\u7a0b\u5e8f\u5236\u4f5c\u6210exe\u6587\u4ef6\u3002\u539f<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[34547,34548,3076,81,179],"topic":[],"class_list":["post-44549","post","type-post","status-publish","format-standard","hentry","category-ruanjiankf","tag-pyexe","tag-exe","tag-3076","tag-81","tag-179"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/44549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=44549"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/44549\/revisions"}],"predecessor-version":[{"id":44559,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/44549\/revisions\/44559"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=44549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=44549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=44549"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=44549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}