{"id":63101,"date":"2025-11-04T12:17:51","date_gmt":"2025-11-04T04:17:51","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=63101"},"modified":"2025-11-04T12:17:51","modified_gmt":"2025-11-04T04:17:51","slug":"java%e4%bb%a3%e7%a0%81%e6%80%8e%e4%b9%88%e7%94%9f%e6%88%90exe%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/exekaifa\/63101.html","title":{"rendered":"java\u4ee3\u7801\u600e\u4e48\u751f\u6210exe\uff1f"},"content":{"rendered":"<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/21\/09\/35311211224.jpg\" \/><\/figure>\n<\/p>\n<p>Java \u662f\u4e00\u79cd\u8de8\u5e73\u53f0\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u7684\u4ee3\u7801\u5728\u7f16\u8bd1\u540e\u751f\u6210 .class \u6587\u4ef6\uff0c\u7136\u540e\u5728 Java \u865a\u62df\u673a\uff08JVM\uff09\u4e0a\u8fd0\u884c\u3002\u8fd9\u610f\u5473\u7740 Java \u5e94\u7528\u7a0b\u5e8f\u4e0d\u76f4\u63a5\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08.exe \u6587\u4ef6\uff09\uff0c\u800c\u662f\u4f9d\u8d56\u4e8e\u5b89\u88c5\u5728\u8ba1\u7b97\u673a\u4e0a\u7684 JVM\u3002\u4e0d\u8fc7\uff0c\u6709\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u5c06 Java \u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6 (.exe)\uff0c\u8fd9\u6837\u7528\u6237\u65e0\u9700\u5b89\u88c5 Java \u73af\u5883\uff0c\u4e5f\u80fd\u8fd0\u884c\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u4e24\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\u5c06 Java \u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a .exe \u6587\u4ef6\u3002<\/p>\n<p>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528 Launch4j<\/p>\n<p>Launch4j \u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06 Java \u5e94\u7528\u7a0b\u5e8f\u5c01\u88c5\u6210 Windows \u53ef\u6267\u884c\u6587\u4ef6\uff08.exe\uff09\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 Launch4j \u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u4e0b\u8f7d\u5e76\u5b89\u88c5 Launch4j\u3002\u8bbf\u95ee\u5b98\u65b9\u7f51\u7ad9\uff08http:\/\/launch4j.sourceforge.net\/ \uff09\uff0c\u4e0b\u8f7d\u5bf9\u5e94\u7684\u7248\u672c\u5e76\u5b89\u88c5\u3002<\/p>\n<p>2. \u6253\u5f00 Launch4j\uff0c\u8bbe\u7f6e\u914d\u7f6e\u53c2\u6570\u3002<\/p>\n<p>   &#8211; Basic\uff1a\u5728\u201cOutput file\u201d\u8f93\u5165\u6846\u4e2d\u8f93\u5165\u4f60\u7684 .exe \u6587\u4ef6\u540d\u53ca\u751f\u6210\u8def\u5f84\uff0c\u5728 \u201cJar\u201d \u6587\u672c\u6846\u4e2d\u8f93\u5165\u4f60\u7684\u53ef\u8fd0\u884c\u7684 .jar \u6587\u4ef6\u8def\u5f84\u3002<\/p>\n<p>   &#8211; JRE\uff1a\u8bbe\u7f6e\u9002\u7528\u4e8e\u4f60\u7a0b\u5e8f\u7684 JRE \u7248\u672c\u548c\u8fd0\u884c\u65f6\u53c2\u6570\uff0c\u4f8b\u5982\uff0c\u6700\u5c0f\u548c\u6700\u5927 JRE \u7248\u672c\u3002<\/p>\n<p>3. \u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6\u3002\u70b9\u51fb\u201cSave configuration\u201d\u6309\u94ae\u4fdd\u5b58\u5f53\u524d\u914d\u7f6e\u3002\u4fdd\u5b58\u540e\uff0c\u5c06.xml\u6587\u4ef6\u7684\u8def\u5f84\u62d6\u52a8\u5230Launch4j\u4e2d\u3002<\/p>\n<p>4. \u70b9\u51fb\u201cBuil<a href=\"https:\/\/www.yimenexe.com\/exe-kaifa-2475.html\">ps1\u8f6cexe<\/a>d wrapper\u201d\u3002Launch4j \u4f1a\u751f\u6210\u4e00\u4e2a.exe \u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u5c06\u751f\u6210\u7684 .exe \u6587\u4ef6\u5206\u4eab\u7ed9\u5176\u4ed6\u7528\u6237\uff0c\u4ed6\u4eec\u65e0\u9700\u5b89\u88c5 Java \u73af\u5883\u5373\u53ef\u8fd0\u884c\u4f60\u7684 Java \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528 JDK \u5305\u542b\u7684 jlink \u548c jpackage \u5de5\u5177<\/p>\n<p>\u4ece Java 9 \u5f00\u59cb\uff0cJDK \u5305\u542b\u4e86\u4e00\u4e2a\u540d\u4e3a jlink \u7684\u5de5\u5177\uff0c\u7528\u4e8e\u521b\u5efa\u5177\u6709\u81ea\u5b9a\u4e49 JRE \u7684 Java \u8fd0\u884c\u65f6\u6620\u50cf\u3002\u4ece Java 14 \u5f00\u59cb\uff0cJDK \u4e5f\u5f15\u5165\u4e86\u4e00\u4e2a\u540d\u4e3a jpackage \u7684\u5de5\u5177\uff0c\u7528\u4e8e\u5c06 Java \u8fd0\u884c\u65f6\u6620\u50cf\u8f6c\u6362\u4e3a\u5e73\u53f0\u7279\u5b9a\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4e0b\u9762\u662f\u4f7f\u7528 jlink \u548c jpackage \u5de5\u5177\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u5148\u4f7f\u7528 jlink \u5de5\u5177\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u81ea\u5b9a\u4e49 JRE \u7684 Java \u8fd0\u884c\u65f6\u6620\u50cf\u3002\u4f60\u9700\u8981\u77e5\u9053\u4f60\u7684 Java<a href=\"https:\/\/exe.yimenapp.com\/tool-3156.html\">\u5730\u5740\u6253\u5305\u6210exe<\/a> \u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u6a21\u5757\uff1a<\/p>\n<p>   &#8220;`<\/p>\n<p>   jlink &#8211;no-header-files &#8211;no-man-pages &#8211;compress=2 &#8211;strip-debug &#8211;add-modules java.base,java.desktop,your.additional.modules &#8211;output runtime<\/p>\n<p>   &#8220;`<\/p>\n<p>2. \u4f7f\u7528 jpackage \u5de5\u5177\u5c06 Java \u8fd0\u884c\u65f6\u6620\u50cf\u548c .jar \u6587\u4ef6\u6253\u5305\u4e3a\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n<p>   &#8220;`<\/p>\n<p>   jpackage &#8211;name MyApplication &#8211;input input_folder_containing_jar_files &#8211;main-jar myapp.jar &#8211;main-class com.example.MyApp &#8211;runtime-image runtime &#8211;type app-image<\/p>\n<p>   &#8220;`<\/p>\n<p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u5728\u201coutput\u201d\u6587\u4ef6\u5939\u4e2d\u627e\u5230\u6839\u636e\u4f60\u7684\u8f93\u5165\u53c2\u6570\u751f\u6210\u7684 .exe \u6587\u4ef6\u3002\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u53cc\u51fb\u6b64 .exe \u6587\u4ef6\u8fd0\u884c\u4f60\u7684 Java \u5e94\u7528\u7a0b\u5e8f\uff0c\u65e0\u9700\u5b89\u88c5 Java \u73af\u5883\u3002<\/p>\n<p>\u603b\u4e4b\uff0c\u5c06 Java \u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a .exe \u6587\u4ef6\u4e3b\u8981\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 Launch4j \u6216\u4f7f\u7528 JDK \u81ea\u5e26\u7684 jlink \u548c jpackage \u5de5\u5177\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u4f60\u7f16\u5199\u7684 Java \u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u66f4\u52a0\u65b9\u4fbf\u5730\u5728\u7528\u6237\u7535\u8111\u4e0a\u8fd0\u884c\uff0c\u65e0\u9700\u5b89\u88c5Java\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java \u662f\u4e00\u79cd\u8de8\u5e73\u53f0\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u7684\u4ee3\u7801\u5728\u7f16\u8bd1\u540e\u751f\u6210 .class \u6587\u4ef6\uff0c\u7136\u540e\u5728 Java \u865a\u62df\u673a\uff08JVM\uff09\u4e0a\u8fd0\u884c\u3002\u8fd9\u610f\u5473\u7740 Java \u5e94\u7528\u7a0b\u5e8f\u4e0d\u76f4\u63a5\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08.exe \u6587\u4ef6\uff09\uff0c\u800c\u662f\u4f9d\u8d56\u4e8e<\/p>\n","protected":false},"author":23,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[3007,44397,960,1775,802],"class_list":["post-63101","post","type-post","status-publish","format-standard","hentry","category-exekaifa","tag-html","tag-javaexe","tag-960","tag-1775","tag-802"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/63101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=63101"}],"version-history":[{"count":1,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/63101\/revisions"}],"predecessor-version":[{"id":63137,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/63101\/revisions\/63137"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=63101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=63101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=63101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}