{"id":38417,"date":"2024-11-26T17:58:18","date_gmt":"2024-11-26T09:58:18","guid":{"rendered":"https:\/\/fwq.ai\/blog\/38417\/"},"modified":"2024-11-26T17:58:18","modified_gmt":"2024-11-26T09:58:18","slug":"%e5%ae%89%e8%a3%85%e5%ae%8cjava%e6%80%8e%e4%b9%88%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/38417\/","title":{"rendered":"\u5b89\u88c5\u5b8cjava\u600e\u4e48\u4f7f\u7528"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u4f7f\u7528\u5df2\u5b89\u88c5\u7684 java\uff1f\u9a8c\u8bc1 java \u5df2\u5b89\u88c5\uff1a\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u6267\u884c java -version\u3002\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a\u5bf9\u4e8e\u975e windows\uff0c\u7f16\u8f91 .bash_profile \u6587\u4ef6\u5e76\u6dfb\u52a0 java_home \u548c path \u53d8\u91cf\uff1b\u5bf9\u4e8e windows\uff0c\u4f7f\u7528\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u8bbe\u7f6e path \u53d8\u91cf\u3002\u8fd0\u884c java \u7a0b\u5e8f\uff1a\u521b\u5efa .java \u6587\u4ef6\uff0c\u8f93\u5165\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1b\u4f7f\u7528 javac \u547d\u4ee4\u7f16\u8bd1\uff0c\u4f7f\u7528 java \u547d\u4ee4\u8fd0\u884c\u7a0b\u5e8f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/14\/2024111414545244270.jpg\" class=\"aligncenter\" title=\"\u5b89\u88c5\u5b8cjava\u600e\u4e48\u4f7f\u7528\u63d2\u56fe\" alt=\"\u5b89\u88c5\u5b8cjava\u600e\u4e48\u4f7f\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528\u5df2\u5b89\u88c5\u7684 Java<\/strong><\/p>\n<p><strong>\u7b2c\u4e00\u6b65\uff1a\u9a8c\u8bc1 Java \u5b89\u88c5<\/strong><\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u7a97\u53e3\u3002<\/li>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u6309 Enter\uff1a<\/li>\n<\/ol>\n<pre>java -version<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u5982\u679c Java \u5df2\u6210\u529f\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230 Java \u7248\u672c\u4ee5\u53ca\u5176\u4ed6\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><strong>\u7b2c\u4e8c\u6b65\uff1a\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff08\u975e Windows\uff09<\/strong><\/p>\n<p><strong>\u5bf9\u4e8e macOS \u6216 Linux\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\u3002<\/li>\n<li>\u7f16\u8f91 .bash_profile \u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<pre>vim ~\/.bash_profile<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u5728\u6587\u4ef6\u7684\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/li>\n<\/ol>\n<pre>export JAVA_HOME=\/Library\/Java\/JavaVirtualMachines\/&lt;java_version&gt;.jdk\/Contents\/Home\nexport PATH=$JAVA_HOME\/bin:$PATH<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8bf7\u5c06 \u66ff\u6362\u4e3a\u60a8\u5b89\u88c5\u7684 Java \u7248\u672c\uff08\u4f8b\u5982\uff0c8\u300111\u300117\uff09\u3002 <\/p>\n<p><strong>\u5bf9\u4e8e Windows\uff1a<\/strong><\/p>\n<ol>\n<li>\u6309 Windows \u952e + R \u952e\u3002<\/li>\n<li>\u5728\u201c\u8fd0\u884c\u201d\u5bf9\u8bdd\u6846\u4e2d\uff0c\u952e\u5165\u201csystempropertiesadvanced\u201d\u5e76\u6309 Enter\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u8f6c\u5230\u201c\u9ad8\u7ea7\u201d\u9009\u9879\u5361\u3002<\/li>\n<li>\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u90e8\u5206\u4e0b\uff0c\u67e5\u627e\u201cPath\u201d\u53d8\u91cf\u3002<\/li>\n<li>\u9009\u62e9\u201cPath\u201d\u53d8\u91cf\uff0c\u7136\u540e\u5355\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/li>\n<li>\u5728\u201c\u53d8\u91cf\u503c\u201d\u5b57\u6bb5\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u8def\u5f84\uff1a<\/li>\n<\/ol>\n<pre>;C:Program FilesJavajdk&lt;java_version&gt;in<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8bf7\u5c06 \u66ff\u6362\u4e3a\u60a8\u5b89\u88c5\u7684 Java \u7248\u672c\uff08\u4f8b\u5982\uff0c8\u300111\u300117\uff09\u3002 <\/p>\n<p><strong>\u7b2c\u4e09\u6b65\uff1a\u8fd0\u884c Java \u7a0b\u5e8f<\/strong><\/p>\n<ol>\n<li>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982\u8bb0\u4e8b\u672c\u6216 TextEdit\uff09\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a Example.java \u7684\u6587\u4ef6\u3002<\/li>\n<li>\u5728\u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/li>\n<\/ol>\n<pre>public class Example {\n    public static void main(String[] args) {\n        System.out.println(\"Hello, Java!\");\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u4fdd\u5b58\u6587\u4ef6\u3002<\/li>\n<li>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u7a97\u53e3\u3002<\/li>\n<li>\u5bfc\u822a\u5230\u5305\u542b Example.java \u6587\u4ef6\u7684\u76ee\u5f55\u3002<\/li>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u6309 Enter\uff1a<\/li>\n<\/ol>\n<pre>javac Example.java<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u6b64\u547d\u4ee4\u5c06\u7f16\u8bd1 Java \u7a0b\u5e8f\u3002<\/li>\n<li>\u8981\u8fd0\u884c\u7f16\u8bd1\u540e\u7684\u7a0b\u5e8f\uff0c\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u6309 Enter\uff1a<\/li>\n<\/ol>\n<pre>java Example<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u60a8\u5e94\u8be5\u770b\u5230\u8f93\u51fa\uff1a<\/p>\n<pre>Hello, Java!<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5b89\u88c5\u5b8cjava\u600e\u4e48\u4f7f\u7528\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528\u5df2\u5b89\u88c5\u7684 java\uff1f\u9a8c\u8bc1 java \u5df2\u5b89\u88c5\uff1a\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u6267\u884c java -version\u3002\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a\u5bf9\u4e8e\u975e windows\uff0c\u7f16\u8f91 .bash_profile \u6587\u4ef6\u5e76\u6dfb\u52a0 java_home \u548c path \u53d8\u91cf\uff1b\u5bf9\u4e8e windows\uff0c\u4f7f\u7528\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u8bbe\u7f6e path \u53d8\u91cf\u3002\u8fd0\u884c java \u7a0b\u5e8f\uff1a\u521b\u5efa .java \u6587\u4ef6\uff0c\u8f93\u5165\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1b\u4f7f\u7528 javac \u547d\u4ee4\u7f16\u8bd1\uff0c\u4f7f\u7528 java \u547d\u4ee4\u8fd0\u884c\u7a0b\u5e8f\u3002 \u5982\u4f55\u4f7f\u7528\u5df2\u5b89\u88c5\u7684 Java \u7b2c\u4e00\u6b65\uff1a\u9a8c\u8bc1 Java \u5b89\u88c5 \u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u7a97\u53e3\u3002 \u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u6309 Enter\uff1a java -version \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c Java \u5df2\u6210\u529f\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230 Java \u7248\u672c\u4ee5\u53ca\u5176\u4ed6\u4fe1\u606f\u3002 \u7b2c\u4e8c\u6b65\uff1a\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff08\u975e Windows\uff09 \u5bf9\u4e8e macOS \u6216 Linux\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\u3002 \u7f16\u8f91 .bash_profile \u6587\u4ef6\uff1a vim ~\/.bash_profile \u767b\u5f55\u540e\u590d\u5236 \u5728\u6587\u4ef6\u7684\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a [&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-38417","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38417","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=38417"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38417\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=38417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=38417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=38417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}