{"id":66355,"date":"2025-05-03T14:05:42","date_gmt":"2025-05-03T06:05:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/66355\/"},"modified":"2025-05-03T14:05:42","modified_gmt":"2025-05-03T06:05:42","slug":"java%e6%80%8e%e4%b9%88%e6%8a%8a%e7%a8%8b%e5%ba%8f%e7%94%9f%e6%88%90%e5%ae%89%e8%a3%85%e5%8c%85-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/66355\/","title":{"rendered":"java\u600e\u4e48\u628a\u7a0b\u5e8f\u751f\u6210\u5b89\u88c5\u5305"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u5c06 java \u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u88c5\u5305\uff1f\u521b\u5efa jar \u6587\u4ef6\uff0c\u7f16\u8bd1 java \u7a0b\u5e8f\u5e76\u751f\u6210 jar \u6587\u4ef6\u3002\u4f7f\u7528\u6253\u5305\u5de5\u5177\u5c06 jar \u6587\u4ef6\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u6216\u5b89\u88c5\u7a0b\u5e8f\u3002\u914d\u7f6e\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5305\u62ec\u5b89\u88c5\u7a0b\u5e8f\u540d\u79f0\u3001\u5b89\u88c5\u76ee\u5f55\u3001\u5feb\u6377\u65b9\u5f0f\u3001\u6ce8\u518c\u8868\u9879\u548c\u5378\u8f7d\u7a0b\u5e8f\u3002\u6dfb\u52a0\u5176\u4ed6\u6587\u4ef6\uff0c\u5982\u6709\u9700\u8981\uff0c\u6dfb\u52a0\u5176\u4ed6\u6587\u4ef6\uff08\u5982\u5e93\u3001\u914d\u7f6e\u6216\u6587\u6863\uff09\u5230\u5b89\u88c5\u7a0b\u5e8f\u4e2d\u3002\u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f\uff0c\u751f\u6210\u53ef\u5206\u53d1\u7684\u5b89\u88c5\u5305\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/15\/2024111519373377177.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u628a\u7a0b\u5e8f\u751f\u6210\u5b89\u88c5\u5305\u63d2\u56fe\" alt=\"java\u600e\u4e48\u628a\u7a0b\u5e8f\u751f\u6210\u5b89\u88c5\u5305\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 Java \u5c06\u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u88c5\u5305<\/strong><\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><strong>1. \u521b\u5efa JAR \u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u7f16\u8bd1 Java \u7a0b\u5e8f\uff0c\u751f\u6210 JAR \u6587\u4ef6\u3002\u8fd9\u901a\u5e38\u901a\u8fc7 Maven \u6216 Gradle \u7b49\u6784\u5efa\u5de5\u5177\u6765\u5b8c\u6210\u3002<\/li>\n<\/ul>\n<p><strong>2. \u4f7f\u7528\u6253\u5305\u5de5\u5177<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>\u4f7f\u7528 EXE4J\u3001Inno Setup \u6216 NSIS \u7b49\u6253\u5305\u5de5\u5177\u5c06 JAR \u6587\u4ef6\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08EXE\uff09\u6216\u5b89\u88c5\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<p><strong>3. \u914d\u7f6e\u5b89\u88c5\u7a0b\u5e8f<\/strong><\/p>\n<ul>\n<li>\n<p>\u5728\u6253\u5305\u5de5\u5177\u4e2d\u914d\u7f6e\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u5b89\u88c5\u7a0b\u5e8f\u540d\u79f0\u548c\u7248\u672c<\/li>\n<li>\u5b89\u88c5\u76ee\u5f55<\/li>\n<li>\u5feb\u6377\u65b9\u5f0f\u548c\u6ce8\u518c\u8868\u9879<\/li>\n<li>\u5378\u8f7d\u7a0b\u5e8f<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>4. \u6dfb\u52a0\u989d\u5916\u7684\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u5c06\u5176\u4ed6\u6587\u4ef6\uff08\u5982\u5e93\u3001\u914d\u7f6e\u6216\u6587\u6863\uff09\u6dfb\u52a0\u5230\u5b89\u88c5\u7a0b\u5e8f\u4e2d\u3002<\/li>\n<\/ul>\n<p><strong>5. \u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u6253\u5305\u5de5\u5177\u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f\uff0c\u751f\u6210\u53ef\u5206\u53d1\u7684\u5b89\u88c5\u5305\u3002<\/li>\n<\/ul>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><strong>1. \u4f7f\u7528 Maven \u7f16\u8bd1 JAR \u6587\u4ef6<\/strong><\/p>\n<pre>&lt;dependencies&gt;\n  &lt;dependency&gt;\n    &lt;groupId&gt;junit&lt;\/groupId&gt;\n    &lt;artifactId&gt;junit&lt;\/artifactId&gt;\n    &lt;version&gt;4.12&lt;\/version&gt;\n  &lt;\/dependency&gt;\n&lt;\/dependencies&gt;\n\n&lt;build&gt;\n  &lt;plugins&gt;\n    &lt;plugin&gt;\n      &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\n      &lt;artifactId&gt;maven-compiler-plugin&lt;\/artifactId&gt;\n      &lt;version&gt;3.7.0&lt;\/version&gt;\n      &lt;configuration&gt;\n        &lt;source&gt;1.8&lt;\/source&gt;\n        &lt;target&gt;1.8&lt;\/target&gt;\n      &lt;\/configuration&gt;\n    &lt;\/plugin&gt;\n    &lt;plugin&gt;\n      &lt;groupId&gt;org.apache.maven.plugins&lt;\/groupId&gt;\n      &lt;artifactId&gt;maven-assembly-plugin&lt;\/artifactId&gt;\n      &lt;version&gt;3.1.1&lt;\/version&gt;\n      &lt;configuration&gt;\n        &lt;archive&gt;\n          &lt;manifest&gt;\n            &lt;mainClass&gt;com.example.Main&lt;\/mainClass&gt;\n          &lt;\/manifest&gt;\n        &lt;\/archive&gt;\n        &lt;descriptorRefs&gt;\n          &lt;descriptorRef&gt;jar-with-dependencies&lt;\/descriptorRef&gt;\n        &lt;\/descriptorRefs&gt;\n      &lt;\/configuration&gt;\n      &lt;executions&gt;\n        &lt;execution&gt;\n          &lt;id&gt;make-assembly&lt;\/id&gt;\n          &lt;phase&gt;package&lt;\/phase&gt;\n          &lt;goals&gt;\n            &lt;goal&gt;single&lt;\/goal&gt;\n          &lt;\/goals&gt;\n        &lt;\/execution&gt;\n      &lt;\/executions&gt;\n    &lt;\/plugin&gt;\n  &lt;\/plugins&gt;\n&lt;\/build&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u751f\u6210\u4e00\u4e2a\u540d\u4e3a target\/my-app-1.0.0.jar \u7684 JAR \u6587\u4ef6\u3002<\/p>\n<p><strong>2. \u4f7f\u7528 Inno Setup \u6253\u5305<\/strong><\/p>\n<p>\u4e0b\u8f7d\u5e76\u5b89\u88c5 Inno Setup\uff0c\u7136\u540e\u521b\u5efa\u65b0\u7684 Inno Setup \u811a\u672c\uff1a<\/p>\n<pre>[Setup]\nAppName=My Application\nAppVersion=1.0.0\nDefaultDirName={localappdata}My Application\n\n[Files]\nSource: \"targetmy-app-1.0.0.jar\"; DestDir: \"{app}\"\n\n[Icons]\nName: {commonprograms}My Application; Filename: \"{app}my-app.ico\"\n\n[Run]\nFilename: \"{app}my-app.jar\"; Description: \"Run My Application\"<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f<\/strong><\/p>\n<p>\u5728 Inno Setup \u4e2d\uff0c\u70b9\u51fb\u7f16\u8bd1\u6309\u94ae\u3002\u8fd9\u5c06\u751f\u6210\u540d\u4e3a my-app-setup.exe \u7684\u5b89\u88c5\u7a0b\u5e8f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u628a\u7a0b\u5e8f\u751f\u6210\u5b89\u88c5\u5305\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5c06 java \u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u88c5\u5305\uff1f\u521b\u5efa jar \u6587\u4ef6\uff0c\u7f16\u8bd1 java \u7a0b\u5e8f\u5e76\u751f\u6210 jar \u6587\u4ef6\u3002\u4f7f\u7528\u6253\u5305\u5de5\u5177\u5c06 jar \u6587\u4ef6\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08exe\uff09\u6216\u5b89\u88c5\u7a0b\u5e8f\u3002\u914d\u7f6e\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5305\u62ec\u5b89\u88c5\u7a0b\u5e8f\u540d\u79f0\u3001\u5b89\u88c5\u76ee\u5f55\u3001\u5feb\u6377\u65b9\u5f0f\u3001\u6ce8\u518c\u8868\u9879\u548c\u5378\u8f7d\u7a0b\u5e8f\u3002\u6dfb\u52a0\u5176\u4ed6\u6587\u4ef6\uff0c\u5982\u6709\u9700\u8981\uff0c\u6dfb\u52a0\u5176\u4ed6\u6587\u4ef6\uff08\u5982\u5e93\u3001\u914d\u7f6e\u6216\u6587\u6863\uff09\u5230\u5b89\u88c5\u7a0b\u5e8f\u4e2d\u3002\u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f\uff0c\u751f\u6210\u53ef\u5206\u53d1\u7684\u5b89\u88c5\u5305\u3002 \u5982\u4f55\u4f7f\u7528 Java \u5c06\u7a0b\u5e8f\u6253\u5305\u6210\u5b89\u88c5\u5305 \u6b65\u9aa4\uff1a 1. \u521b\u5efa JAR \u6587\u4ef6 \u7f16\u8bd1 Java \u7a0b\u5e8f\uff0c\u751f\u6210 JAR \u6587\u4ef6\u3002\u8fd9\u901a\u5e38\u901a\u8fc7 Maven \u6216 Gradle \u7b49\u6784\u5efa\u5de5\u5177\u6765\u5b8c\u6210\u3002 2. \u4f7f\u7528\u6253\u5305\u5de5\u5177 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 EXE4J\u3001Inno Setup \u6216 NSIS \u7b49\u6253\u5305\u5de5\u5177\u5c06 JAR \u6587\u4ef6\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08EXE\uff09\u6216\u5b89\u88c5\u7a0b\u5e8f\u3002 3. \u914d\u7f6e\u5b89\u88c5\u7a0b\u5e8f \u5728\u6253\u5305\u5de5\u5177\u4e2d\u914d\u7f6e\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5305\u62ec\uff1a \u5b89\u88c5\u7a0b\u5e8f\u540d\u79f0\u548c\u7248\u672c \u5b89\u88c5\u76ee\u5f55 \u5feb\u6377\u65b9\u5f0f\u548c\u6ce8\u518c\u8868\u9879 \u5378\u8f7d\u7a0b\u5e8f 4. \u6dfb\u52a0\u989d\u5916\u7684\u6587\u4ef6 \u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u5c06\u5176\u4ed6\u6587\u4ef6\uff08\u5982\u5e93\u3001\u914d\u7f6e\u6216\u6587\u6863\uff09\u6dfb\u52a0\u5230\u5b89\u88c5\u7a0b\u5e8f\u4e2d\u3002 5. \u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f \u4f7f\u7528\u6253\u5305\u5de5\u5177\u6784\u5efa\u5b89\u88c5\u7a0b\u5e8f\uff0c\u751f\u6210\u53ef\u5206\u53d1\u7684\u5b89\u88c5\u5305\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a 1. \u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-66355","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=66355"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/66355\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=66355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=66355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=66355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}