{"id":38410,"date":"2025-08-14T12:17:57","date_gmt":"2025-08-14T04:17:57","guid":{"rendered":"https:\/\/app.60day.cn\/appday\/?p=38410"},"modified":"2025-08-14T12:17:57","modified_gmt":"2025-08-14T04:17:57","slug":"java%e7%94%9f%e6%88%90%e7%9a%84exe%e6%93%8d%e4%bd%9c%e5%8a%9e%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/app.60day.cn\/appday\/kaifaexe\/38410\/","title":{"rendered":"java\u751f\u6210\u7684exe\u64cd\u4f5c\u529e\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4e86\u89e3\u5982\u4f55\u5c06Java\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aexe\u6587\u4ef6\uff08\u53ef\u6267\u884c\u6587\u4ef6\uff09\uff0c\u4ee5\u53ca\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u3002Java\u751f\u6210\u7684exe\u6587\u4ef6\u53ef\u4ee5\u4f7f\u7528\u6237\u5728\u4e0d\u9700\u8981\u5b89\u88c5Java\u8fd0\u884c\u65f6\u73af\u5883\uff08JRE\uff09\u7684\u60c5\u51b5\u4e0b\u8fd0\u884cJava\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u6837\u7684exe\u6587\u4ef6\u901a\u5e38\u4f1a\u6253\u5305\u4e00\u4e2aJava\u8fd0\u884c\u65f6\u73af\u5883\uff0c\u4ece\u800c\u4f7f\u5e94\u7528\u7a0b\u5e8f\u5177\u6709\u76f4\u63a5\u8fd0\u884c\u7684\u80fd\u529b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5c06Java\u7a0b\u5e8f\u8f6c\u6362\u4e3aexe\u6587\u4ef6\u7684\u65b9\u6cd5\uff1a<\/p>\n<p>1. \u4f7f\u7528\u53ef\u6267\u884cJAR\u6587\u4ef6<\/p>\n<p>\u867d\u7136\u8fd9\u4e0d\u662f\u4e00\u4e2a\u771f\u6b63\u7684exe\u6587\u4ef6\uff0c\u4f46\u5b83\u5141\u8bb8\u7528\u6237\u5728\u5b89\u88c5\u4e86JRE\u7684\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884cJava\u5e94\u7528\u7a0b\u5e8f\u3002\u5c06Java\u7a0b\u5e8f\u6253\u5305\u6210\u53ef\u6267\u884cJAR\u6587\u4ef6\u7684\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<p>&#8211; \u7f16\u5199\u4e00\u4e2aJava\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u786e\u4fdd\u6709\u4e00\u4e2a\u5305\u542bma<a href=\"https:\/\/www.yimenexe.com\/ruanjian-kaifa-4374.html\">vsc\u6253\u5305exe<\/a>in()\u65b9\u6cd5\u7684\u4e3b\u7c7b\u3002<\/p>\n<p>&#8211; \u5728\u4e3b\u7c7b\u6240\u5728\u7684\u76ee\u5f55\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aMANIFEST.MF\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>Manifest-Version: 1.0<\/p>\n<p>Main-Class: your.package.MainClass<\/p>\n<p>Class-Path: .\/your\/package\/dependencies.jar<\/p>\n<p>&#8220;`<\/p>\n<p>\u6ce8\u610f\uff1a\u8bf7\u66ff\u6362`your.package.MainClass`\u548c\u4f9d\u8d56\u5305\u7684\u8def\u5f84<\/p>\n<p>&#8211; \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5c06\u7a0b\u5e8f\u548c\u6240\u6709\u4f9d\u8d56\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884cJAR\u6587\u4ef6\uff1a<\/p>\n<p>&#8220;`bash<\/p>\n<p>jar cvfm myApp.jar MANIFEST.MF -C src\/ .<\/p>\n<p>&#8220;`<\/p>\n<p>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u53cc\u51fbJAR\u6587\u4ef6\u6216\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`bash<\/p>\n<p>java -jar myApp.jar<\/p>\n<p>&#8220;`<\/p>\n<p>2. \u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177<\/p>\n<p>\u6709\u8bb8\u591a\u4f7f\u7528Java\u7f16\u5199\u7684exe\u6587<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/17\/18\/02108938753.jpg\" \/><\/figure>\n<\/p>\n<p>\u4ef6\u7684\u7b2c\u4e09\u65b9\u5de5\u5177\uff0c\u4f8b\u5982\uff1aLaunch4j, JWrapper, or Excelsior JET\u3002\u8fd9\u4e9b\u7a0b\u5e8f\u5141\u8bb8\u5c06Java\u7a0b\u5e8f\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u5e76\u5904\u7406\u6240\u6709\u5fc5\u8981\u7684\u8fd0\u884c\u65f6\u73af\u5883\u548c\u4f9d\u8d56\u7ba1\u7406\u3002\u4f7f\u7528\u8fd9\u4e9b\u7a0b\u5e8f\u7684\u5177\u4f53\u6b65\u9aa4\u53ef\u80fd\u56e0\u4ea7\u54c1\u800c\u5f02\uff0c\u4f46\u901a\u5e38\u4f1a\u5305\u62ec\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p>&#8211; \u7f16\u8bd1Java\u7a0b\u5e8f\u5e76\u521b\u5efa\u53ef\u6267\u884cJAR\u6587\u4ef6\uff08\u5982\u4e0a\u6240\u8ff0\uff09<\/p>\n<p>&#8211; \u4f7f\u7528\u6240\u9009\u5de5\u5177\u521b\u5efa\u4e00\u4e2aexe\u6587\u4ef6\uff0c\u5e76\u5728\u914d\u7f6e\u9009\u9879\u4e2d\u6307\u5b9aJAR\u6587\u4ef6\u548c\u8fd0\u884c\u65f6\u73af\u5883<\/p>\n<p>&#8211; \u6839\u636e\u9700\u8981\u8bbe\u7f6e\u5e94\u7528\u7a0b\u5e8f\u56fe\u6807\u3001\u7248\u672c\u4fe1\u606f\u548c\u5176\u4ed6\u539f\u751fexe\u6587\u4ef6\u5c5e\u6027<\/p>\n<p>&#8211; \u5bfc\u51faexe\u6587\u4ef6\uff0c\u6b64\u65f6\u5b83\u5e94\u8be5\u80fd\u5728\u76ee\u6807\u5e73\u53f0\u4e0a\u72ec\u7acb\u8fd0\u884c<\/p>\n<p>3. \u4f7f\u7528JLink (JDK 11+)<\/p>\n<p>\u81ea\u4eceJava 11\u5f00\u59cb\uff0cJDK\u5185\u7f6e\u4e86\u4e00\u4e2a\u540d\u4e3a`j<a href=\"https:\/\/www.yimenexe.com\/ruanjian-kaifa-2343.html\">python\u5c01\u88c5exe\u73af\u5883\u53d8\u91cf<\/a>link`\u7684\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u521b\u5efa\u4e00\u4e2a\u8fd0\u884cJava\u5e94\u7528\u7a0b\u5e8f\u7684\u81ea\u5b9a\u4e49\u8fd0\u884c\u65f6\u6620\u50cf\u3002\u867d\u7136\u5b83\u4e0d\u4f1a\u751f\u6210\u4e00\u4e2aexe\u6587\u4ef6\uff0c\u4f46\u5b83\u53ef\u4ee5\u8ba9\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u72ec\u7acb\u8fd0\u884c\u3002<\/p>\n<p>\u8981\u4f7f\u7528`jlink`\uff0c\u4f60\u9700\u8981\u627e\u5230\u5e94\u7528\u7a0b\u5e8f\u4f9d\u8d56\u7684\u6240\u6709\u6a21\u5757\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u884c\u64cd\u4f5c\uff1a<\/p>\n<p>&#8211; \u7f16\u5199\u5e76\u7f16\u8bd1\u4e00\u4e2a\u6a21\u5757\u5316\u7684Java\u5e94\u7528\u7a0b\u5e8f\u3002\u786e\u4fdd\u6bcf\u4e2a\u6a21\u5757\u90fd\u6709\u4e00\u4e2a`module-info.java`\u6587\u4ef6\u3002<\/p>\n<p>&#8211; \u4f7f\u7528`jlink`\u5de5\u5177\u521b\u5efa\u81ea\u5b9a\u4e49\u8fd0\u884c\u65f6\u6620\u50cf\uff1a<\/p>\n<p>&#8220;`bash<\/p>\n<p>jlink &#8211;add-modules my.module,required.modules &#8211;output myApp<\/p>\n<p>&#8220;`<\/p>\n<p>\u6ce8\u610f\uff1a\u8bf7\u66ff\u6362`my.module,required.modules`\u548c\u8f93\u51fa\u8f93\u51fa\u76ee\u5f55\u4e3a\u4f60\u7684\u6a21\u5757\u540d\u548c\u8f93\u51fa\u8def\u5f84<\/p>\n<p>&#8211; \u5bfc\u822a\u5230\u751f\u6210\u7684\u6620\u50cf\u76ee\u5f55\uff0c\u627e\u5230\u540d\u4e3a&#8221;bin&#8221;\u7684\u5b50\u76ee\u5f55\u3002\u5728\u5176\u4e2d\uff0c\u4f60\u5c06\u770b\u5230\u4e00\u4e2a\u540d\u4e3a`java`\u6216`java.exe`\u7684\u6587\u4ef6\uff0c\u5b83\u662f\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u8981\u5165\u53e3\u70b9\u3002\u5c06\u6b64\u6587\u4ef6\u548c\u5176\u4ed6\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e00\u8d77\u5206\u53d1\u7ed9\u7528\u6237\uff0c\u5b83\u4eec\u53ef\u4ee5\u5728\u4e0d\u5b89\u88c5JRE\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u603b\u7ed3\uff1a<\/p>\n<p>\u751f\u6210Java\u7684exe\u6587\u4ef6\u6709\u591a\u79cd\u65b9\u6cd5\u3002Java\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u6253\u5305\u6210\u53ef\u6267\u884cJAR\u6587\u4ef6\u8fd0\u884c\uff0c\u6216\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\uff0c\u5982Launch4j\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u4e3a\u539f\u751fexe\u6587\u4ef6\u3002\u6b64\u5916\uff0c\u65b0\u7684Java\u5f00\u53d1\u5de5\u5177`jlink`\u53ef\u4ee5\u7528\u6765\u6253\u5305\u72ec\u7acb\u7684Java\u8fd0\u884c\u73af\u5883\u3002\u8fd9\u4e9b\u65b9\u6cd5\u4f7fJava\u5e94\u7528\u66f4\u5bb9\u6613\u90e8\u7f72\u548c\u4f7f\u7528\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e\u90a3\u4e9b\u6ca1\u6709\u5b89\u88c5Java\u8fd0\u884c\u65f6\u73af\u5883\u7684\u7528\u6237\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4e86\u89e3\u5982\u4f55\u5c06Java\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aexe\u6587\u4ef6\uff08\u53ef\u6267\u884c\u6587\u4ef6\uff09\uff0c\u4ee5\u53ca\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u3002Java\u751f\u6210\u7684exe\u6587\u4ef6\u53ef\u4ee5\u4f7f\u7528\u6237\u5728\u4e0d\u9700\u8981\u5b89\u88c5Java\u8fd0\u884c\u65f6\u73af\u5883\uff08JRE\uff09\u7684\u60c5\u51b5\u4e0b\u8fd0\u884cJava\u5e94\u7528\u7a0b\u5e8f<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[34613,34614,84,132,797],"topic":[],"class_list":["post-38410","post","type-post","status-publish","format-standard","hentry","category-kaifaexe","tag-ideaexe","tag-shahidexe","tag-84","tag-132","tag-797"],"_links":{"self":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/38410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/comments?post=38410"}],"version-history":[{"count":1,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/38410\/revisions"}],"predecessor-version":[{"id":38445,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/posts\/38410\/revisions\/38445"}],"wp:attachment":[{"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/media?parent=38410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/categories?post=38410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/tags?post=38410"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/app.60day.cn\/appday\/wp-json\/wp\/v2\/topic?post=38410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}