{"id":104717,"date":"2026-09-13T07:01:07","date_gmt":"2026-09-12T23:01:07","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/104717.html"},"modified":"2026-09-13T07:01:07","modified_gmt":"2026-09-12T23:01:07","slug":"%e3%80%90diy%e7%b3%bb%e5%88%97%ef%bc%9ajava%e8%99%9a%e6%8b%9f%e6%9c%ba%e3%80%91%e7%ac%ac06%e7%af%87%ef%bc%9a%e7%b1%bb%e8%b7%af%e5%be%84%ef%bc%88classpath%ef%bc%89%e6%98%af%e4%bb%80%e4%b9%88%e9%ac%bc","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/104717.html","title":{"rendered":"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6"},"content":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u3010\u7b2c05\u7bc7\u3011\u9879\u76ee\u7ed3\u6784\u4e0e\u7b2c\u4e00\u884c\u4ee3\u7801\u2014\u2014jvmgo \u9879\u76ee\u9aa8\u67b6\u642d\u5efa \u4e0b\u4e00\u7bc7\u3010\u7b2c07\u7bc7\u3011Entry \u63a5\u53e3\u8bbe\u8ba1\u2014\u2014\u7c7b\u8def\u5f84\u7684&#034;\u79ef\u6728\u5757&#034;<\/p>\n<hr \/>\n<h3>\u6458\u8981<\/h3>\n<p>\u5199\u4e00\u4e2a JVM&#xff0c;\u7b2c\u4e00\u4ef6\u8981\u89e3\u51b3\u7684\u4e8b\u5c31\u662f&#xff1a;\u53bb\u54ea\u513f\u627e class \u6587\u4ef6&#xff1f;<\/p>\n<p>\u6709\u610f\u601d\u7684\u662f&#xff0c;Java \u865a\u62df\u673a\u89c4\u8303\u5e76\u6ca1\u6709\u89c4\u5b9a\u865a\u62df\u673a\u8be5\u4ece\u54ea\u91cc\u5bfb\u627e\u7c7b\u2014\u2014\u8fd9\u662f\u7559\u7ed9\u5b9e\u73b0\u8005\u7684\u81ea\u7531\u3002Oracle \u7684 JVM \u7528\u7684\u662f&#034;\u7c7b\u8def\u5f84&#xff08;classpath&#xff09;&#034;\u65b9\u6848&#xff0c;\u6211\u4eec\u7684 jvmgo \u4e5f\u7167\u6284\u8fd9\u5957\u3002<\/p>\n<p>\u672c\u6587\u8bb2\u900f\u7c7b\u8def\u5f84\u7684\u4e09\u5927\u7ec4\u6210\u90e8\u5206&#xff08;\u542f\u52a8\u7c7b\u8def\u5f84 \/ \u6269\u5c55\u7c7b\u8def\u5f84 \/ \u7528\u6237\u7c7b\u8def\u5f84&#xff09;\u3001-classpath \u9009\u9879\u7684\u5404\u79cd\u7528\u6cd5\u3001Windows \u5206\u53f7\u4e0e Linux \u5192\u53f7\u7684\u5206\u9694\u7b26\u5dee\u5f02\u3001Java 6 \u5f15\u5165\u7684\u901a\u914d\u7b26 lib\/*&#xff0c;\u4ee5\u53ca\u4e00\u4e2a\u53cd\u76f4\u89c9\u7684\u7ed3\u8bba&#xff1a;\u4e3a\u4ec0\u4e48\u4f60\u53ef\u80fd\u542c\u8bf4\u8fc7 CLASSPATH \u73af\u5883\u53d8\u91cf&#xff0c;\u4f46\u7edd\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u4e0d\u8be5\u7528\u5b83\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9700\u8981\u7c7b\u8def\u5f84&#xff1a;HelloWorld \u80cc\u540e\u7684&#034;\u9690\u5f62\u4f9d\u8d56&#034;<\/h3>\n<p>\u5148\u770b\u4e00\u4e2a\u4f60\u53ef\u80fd\u6ca1\u6ce8\u610f\u8fc7\u7684\u4e8b\u5b9e\u3002<\/p>\n<p>\u6211\u4eec\u7684 HelloWorld \u53ea\u6709 5 \u884c\u4ee3\u7801&#xff1a;<\/p>\n<p><span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">HelloWorld<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">static<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> args<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token class-name\">System<\/span><span class=\"token punctuation\">.<\/span>out<span class=\"token punctuation\">.<\/span><span class=\"token function\">println<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Hello, world!&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u7f16\u8bd1\u540e\u53ea\u6709\u4e00\u4e2a HelloWorld.class\u3002\u770b\u8d77\u6765\u5e72\u5e72\u51c0\u51c0&#xff0c;\u5bf9\u5427&#xff1f;<\/p>\n<p>\u4f46 JVM \u8981\u8fd0\u884c\u5b83&#xff0c;\u5b9e\u9645\u4e0a\u5f97\u52a0\u8f7d\u51e0\u5341\u4e0a\u767e\u4e2a\u7c7b&#xff1a;<\/p>\n<p>\u3010\u8fd0\u884c HelloWorld \u5b9e\u9645\u9700\u8981\u52a0\u8f7d\u7684\u7c7b&#xff08;\u90e8\u5206&#xff09;\u3011<\/p>\n<p>  HelloWorld                    \u2190 \u6211\u4eec\u81ea\u5df1\u5199\u7684&#xff0c;1 \u4e2a<br \/>\n    \u2502<br \/>\n    \u251c\u2500 java.lang.Object         \u2190 \u6240\u6709\u7c7b\u7684\u7236\u7c7b&#xff0c;\u5fc5\u987b\u6709<br \/>\n    \u251c\u2500 java.lang.String         \u2190 main \u7684\u53c2\u6570 String[] args<br \/>\n    \u251c\u2500 java.lang.String[]       \u2190 \u6570\u7ec4\u7c7b\u578b\u672c\u8eab\u4e5f\u662f\u7c7b&#xff01;<br \/>\n    \u251c\u2500 java.lang.System         \u2190 System.out \u7528\u5230<br \/>\n    \u2502   \u2514\u2500 java.io.PrintStream  \u2190 System.out \u7684\u7c7b\u578b<br \/>\n    \u2502       \u2514\u2500 java.io.FilterOutputStream<br \/>\n    \u2502           \u2514\u2500 java.io.OutputStream<br \/>\n    \u2502               \u2514\u2500 java.lang.Object<br \/>\n    \u251c\u2500 java.lang.StringBuilder  \u2190 \u5b57\u7b26\u4e32\u62fc\u63a5\u4f1a\u88ab\u7f16\u8bd1\u6210 StringBuilder<br \/>\n    \u251c\u2500 java.lang.AbstractStringBuilder<br \/>\n    \u251c\u2500 java.lang.CharSequence   \u2190 \u63a5\u53e3<br \/>\n    \u2514\u2500 &#8230; \u8fd8\u6709 JDK \u5185\u90e8\u7684\u542f\u52a8\u7c7b\u3001\u5f02\u5e38\u5904\u7406\u7c7b\u7b49<\/p>\n<p>\u60f3\u60f3\u770b&#xff1a;\u52a0\u8f7d HelloWorld \u4e4b\u524d\u8981\u5148\u52a0\u8f7d\u5b83\u7684\u7236\u7c7b java.lang.Object&#xff1b;\u8c03\u7528 main() \u4e4b\u524d\u8981\u51c6\u5907\u53c2\u6570\u6570\u7ec4&#xff0c;\u5f97\u52a0\u8f7d java.lang.String \u548c String[]&#xff1b;\u628a\u5b57\u7b26\u4e32\u6253\u5370\u5230\u63a7\u5236\u53f0&#xff0c;\u5f97\u52a0\u8f7d java.lang.System\u3001java.io.PrintStream\u2026\u2026\u5c42\u5c42\u4f9d\u8d56&#xff0c;\u4e00\u73af\u6263\u4e00\u73af\u3002<\/p>\n<p>\u90a3\u4e48\u95ee\u9898\u6765\u4e86&#xff1a;\u8fd9\u4e9b\u7c7b\u5728\u78c1\u76d8\u7684\u54ea\u4e2a\u89d2\u843d&#xff1f;<\/p>\n<ul>\n<li>HelloWorld.class \u5728\u4f60\u5f53\u524d\u76ee\u5f55&#xff0c;\u8fd9\u4e2a\u597d\u627e<\/li>\n<li>\u4f46 java.lang.Object \u5728\u54ea&#xff1f;\u5728 JDK \u7684 jre\/lib\/rt.jar \u8fd9\u4e2a\u538b\u7f29\u5305\u91cc&#xff01;<\/li>\n<li>\u5982\u679c\u4f60\u7528\u4e86\u7b2c\u4e09\u65b9\u5e93&#xff08;\u6bd4\u5982 commons-lang3&#xff09;&#xff0c;\u5b83\u4eec\u7684 jar \u5305\u53c8\u5728 lib\/ \u76ee\u5f55\u4e0b<\/li>\n<\/ul>\n<p>JVM \u9700\u8981\u4e00\u4e2a\u7edf\u4e00\u7684\u673a\u5236\u6765\u5b9a\u4f4d\u8fd9\u4e9b\u6563\u843d\u5404\u5904\u7684 class \u6587\u4ef6\u2014\u2014\u8fd9\u5c31\u662f\u7c7b\u8def\u5f84\u3002<\/p>\n<p>\u91cd\u70b9&#xff1a;\u7c7b\u8def\u5f84\u672c\u8d28\u4e0a\u662f\u4e00\u4efd&#034;\u641c\u7d22\u6e05\u5355&#034;\u3002JVM \u8981\u52a0\u8f7d\u4e00\u4e2a\u7c7b\u65f6&#xff0c;\u5c31\u6309\u8fd9\u4efd\u6e05\u5355\u6328\u4e2a\u5730\u65b9\u53bb\u627e&#xff0c;\u627e\u5230\u7b2c\u4e00\u4e2a\u5339\u914d\u7684\u5c31\u7528\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u7c7b\u8def\u5f84\u7684\u4e09\u5927\u6765\u6e90<\/h3>\n<p>Oracle \u7684 JVM \u628a\u7c7b\u8def\u5f84\u5206\u6210\u4e09\u90e8\u5206&#xff0c;\u6309\u641c\u7d22\u7684\u5148\u540e\u987a\u5e8f\u6392\u5217&#xff1a;<\/p>\n<p>\u3010\u7c7b\u8def\u5f84\u7684\u4e09\u5927\u7ec4\u6210\u90e8\u5206\u3011<\/p>\n<p>  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n  \u2502                       \u7c7b\u8def\u5f84                              \u2502<br \/>\n  \u2502                    (Classpath)                           \u2502<br \/>\n  \u2502                                                          \u2502<br \/>\n  \u2502   \u2460 \u542f\u52a8\u7c7b\u8def\u5f84            \u2461 \u6269\u5c55\u7c7b\u8def\u5f84        \u2462 \u7528\u6237\u7c7b\u8def\u5f84  \u2502<br \/>\n  \u2502   Bootstrap Classpath   Extension Classpath  User Classpath\u2502<br \/>\n  \u2502   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502<br \/>\n  \u2502   \u2502  jre\/lib\/*     \u2502   \u2502 jre\/lib\/ext\/*  \u2502  \u2502  \u9ed8\u8ba4 &#034;.&#034;  \u2502 \u2502<br \/>\n  \u2502   \u2502                \u2502   \u2502                \u2502  \u2502           \u2502 \u2502<br \/>\n  \u2502   \u2502  \u00b7 rt.jar      \u2502   \u2502  \u00b7 \u6269\u5c55\u5305      \u2502  \u2502 \u00b7 \u4f60\u7684\u7c7b   \u2502 \u2502<br \/>\n  \u2502   \u2502  \u00b7 resources   \u2502   \u2502  \u00b7 \u672c\u5730\u5316jar   \u2502  \u2502 \u00b7 \u7b2c\u4e09\u65b9\u5e93 \u2502 \u2502<br \/>\n  \u2502   \u2502  \u00b7 charsets    \u2502   \u2502                \u2502  \u2502           \u2502 \u2502<br \/>\n  \u2502   \u2502  \u00b7 &#8230;         \u2502   \u2502                \u2502  \u2502           \u2502 \u2502<br \/>\n  \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2502<br \/>\n  \u2502       \u4f18\u5148\u7ea7\u6700\u9ad8              \u4f18\u5148\u7ea7\u4e2d           \u4f18\u5148\u7ea7\u6700\u4f4e  \u2502<br \/>\n  \u2502                                                          \u2502<br \/>\n  \u2502   \u641c\u7d22\u987a\u5e8f&#xff1a;\u2460 \u2192 \u2461 \u2192 \u2462 &#xff08;\u627e\u5230\u4e86\u5c31\u505c\u6b62&#xff09;                     \u2502<br \/>\n  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<table>\n<tr>\u7c7b\u8def\u5f84\u9ed8\u8ba4\u4f4d\u7f6e\u88c5\u7684\u662f\u4ec0\u4e48\u80fd\u6539\u5417<\/tr>\n<tbody>\n<tr>\n<td>\u542f\u52a8\u7c7b\u8def\u5f84<\/td>\n<td>jre\/lib\/<\/td>\n<td>Java \u6807\u51c6\u5e93&#xff08;\u4e3b\u8981\u90fd\u5728 rt.jar \u91cc&#xff09;<\/td>\n<td>\u53ef\u4ee5&#xff0c;\u7528 -Xbootclasspath&#xff08;\u5f88\u5c11\u7528&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6269\u5c55\u7c7b\u8def\u5f84<\/td>\n<td>jre\/lib\/ext\/<\/td>\n<td>Java \u6269\u5c55\u673a\u5236\u7684\u7c7b<\/td>\n<td>\u4e00\u822c\u4e0d\u6539<\/td>\n<\/tr>\n<tr>\n<td>\u7528\u6237\u7c7b\u8def\u5f84<\/td>\n<td>\u5f53\u524d\u76ee\u5f55 .<\/td>\n<td>\u6211\u4eec\u81ea\u5df1\u5199\u7684\u7c7b &#043; \u7b2c\u4e09\u65b9\u5e93<\/td>\n<td>\u7528 -classpath \/ -cp \u6307\u5b9a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>rt.jar \u662f\u4e2a\u4ec0\u4e48\u6765\u5934&#xff1f;<\/h4>\n<p>rt.jar \u662f Runtime \u7684\u7f29\u5199&#xff0c;\u4f4d\u4e8e $JAVA_HOME\/jre\/lib\/rt.jar\u3002\u5b83\u662f Java \u6838\u5fc3\u7c7b\u5e93\u7684\u6253\u5305\u6587\u4ef6&#xff0c;\u5927\u5c0f\u7ea6 60MB&#xff08;JDK 8&#xff09;&#xff0c;\u91cc\u9762\u585e\u4e86\u5927\u7ea6 2 \u4e07\u4e2a\u7c7b&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u770b\u770b rt.jar \u91cc\u6709\u4ec0\u4e48<\/span><br \/>\n<span class=\"token builtin class-name\">cd<\/span> <span class=\"token variable\">$JAVA_HOME<\/span>\/jre\/lib<br \/>\njar tf rt.jar <span class=\"token operator\">|<\/span> <span class=\"token function\">head<\/span> <span class=\"token parameter variable\">-20<\/span><\/p>\n<p><span class=\"token comment\"># \u8f93\u51fa&#xff08;\u8282\u9009&#xff09;<\/span><br \/>\njava\/lang\/Object.class<br \/>\njava\/lang\/String.class<br \/>\njava\/lang\/System.class<br \/>\njava\/lang\/Integer.class<br \/>\njava\/lang\/Thread.class<br \/>\njava\/util\/ArrayList.class<br \/>\njava\/util\/HashMap.class<br \/>\njava\/io\/PrintStream.class<br \/>\n<span class=\"token punctuation\">..<\/span>.<\/p>\n<p><span class=\"token comment\"># \u7edf\u8ba1\u6709\u591a\u5c11\u4e2a\u7c7b<\/span><br \/>\njar tf rt.jar <span class=\"token operator\">|<\/span> <span class=\"token function\">wc<\/span> <span class=\"token parameter variable\">-l<\/span><br \/>\n<span class=\"token comment\"># \u7ea6 20000&#043;<\/span><\/p>\n<p>\u91cd\u70b9&#xff1a;\u6211\u4eec\u7684 jvmgo \u8fd0\u884c\u65f6&#xff0c;\u5fc5\u987b\u80fd\u52a0\u8f7d rt.jar \u91cc\u7684\u7c7b\u3002\u6240\u4ee5\u542f\u52a8\u7c7b\u8def\u5f84\u662f\u4e09\u5757\u91cc\u6700\u5173\u952e\u7684\u2014\u2014\u6ca1\u6709\u5b83&#xff0c;\u8fde java.lang.Object \u90fd\u627e\u4e0d\u5230&#xff0c;\u7a0b\u5e8f\u6839\u672c\u8dd1\u4e0d\u8d77\u6765\u3002<\/p>\n<h4>\u641c\u7d22\u987a\u5e8f\u5f88\u91cd\u8981<\/h4>\n<p>\u4e3a\u4ec0\u4e48\u987a\u5e8f\u91cd\u8981&#xff1f;\u4e3e\u4e2a\u7ecf\u5178\u7684\u5751&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u4f60\u81ea\u5df1\u5199\u4e86\u4e00\u4e2a java.lang.String&#xff08;\u4f5c\u6b7b\u884c\u4e3a&#xff09;<\/span><br \/>\n<span class=\"token keyword\">package<\/span> <span class=\"token namespace\">java<span class=\"token punctuation\">.<\/span>lang<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">String<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ &#8230;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4f60\u7f16\u8bd1\u597d\u653e\u8fdb classpath&#xff0c;\u7136\u540e\u8fd0\u884c\u7a0b\u5e8f\u3002\u4f60\u89c9\u5f97 JVM \u4f1a\u7528\u4f60\u5199\u7684 String \u5417&#xff1f;<\/p>\n<p>\u4e0d\u4f1a\u3002 \u56e0\u4e3a\u542f\u52a8\u7c7b\u8def\u5f84&#xff08;rt.jar&#xff09;\u4f18\u5148\u7ea7\u6700\u9ad8&#xff0c;JVM \u5148\u5728\u90a3\u91cc\u627e\u5230\u4e86\u6b63\u724c\u7684 java.lang.String&#xff0c;\u5c31\u76f4\u63a5\u8fd4\u56de\u4e86&#xff0c;\u6839\u672c\u4e0d\u4f1a\u53bb\u4f60\u7684\u7528\u6237\u7c7b\u8def\u5f84\u91cc\u627e\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u53cc\u4eb2\u59d4\u6d3e\u6a21\u578b\u5728\u7c7b\u8def\u5f84\u5c42\u9762\u7684\u4f53\u73b0\u2014\u2014\u6838\u5fc3\u7c7b\u5e93\u6c38\u8fdc\u4f18\u5148&#xff0c;\u9632\u6b62\u88ab\u6076\u610f\/\u8bef\u64cd\u4f5c\u66ff\u6362\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001-classpath \/ -cp \u9009\u9879\u8be6\u89e3<\/h3>\n<p>\u7528\u6237\u7c7b\u8def\u5f84\u7684\u9ed8\u8ba4\u503c\u662f\u5f53\u524d\u76ee\u5f55 .\u3002\u4f46\u901a\u5e38\u6211\u4eec\u9700\u8981\u6307\u5b9a\u66f4\u590d\u6742\u7684\u4f4d\u7f6e&#xff0c;\u8fd9\u65f6\u5c31\u7528 -classpath&#xff08;\u7b80\u5199 -cp&#xff09;\u3002<\/p>\n<h4>\u57fa\u672c\u7528\u6cd5<\/h4>\n<p><span class=\"token comment\"># \u6307\u5b9a\u76ee\u5f55<\/span><br \/>\n<span class=\"token function\">java<\/span> <span class=\"token parameter variable\">-cp<\/span> path<span class=\"token punctuation\">\\\\<\/span>to<span class=\"token punctuation\">\\\\<\/span>classes HelloWorld<\/p>\n<p><span class=\"token comment\"># \u6307\u5b9a JAR \u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">java<\/span> <span class=\"token parameter variable\">-cp<\/span> path<span class=\"token punctuation\">\\\\<\/span>to<span class=\"token punctuation\">\\\\<\/span>lib1.jar HelloWorld<\/p>\n<p><span class=\"token comment\"># \u6307\u5b9a ZIP \u6587\u4ef6&#xff08;\u662f\u7684&#xff0c;zip \u4e5f\u884c&#xff09;<\/span><br \/>\n<span class=\"token function\">java<\/span> <span class=\"token parameter variable\">-cp<\/span> path<span class=\"token punctuation\">\\\\<\/span>to<span class=\"token punctuation\">\\\\<\/span>lib2.zip HelloWorld<\/p>\n<h4>\u6307\u5b9a\u591a\u4e2a\u4f4d\u7f6e<\/h4>\n<p>\u7528\u5206\u9694\u7b26\u628a\u591a\u4e2a\u8def\u5f84\u4e32\u8d77\u6765&#xff1a;<\/p>\n<p><span class=\"token comment\"># Windows&#xff1a;\u7528\u5206\u53f7 ;<\/span><br \/>\n<span class=\"token function\">java<\/span> <span class=\"token parameter variable\">-cp<\/span> path<span class=\"token punctuation\">\\\\<\/span>to<span class=\"token punctuation\">\\\\<\/span>classes<span class=\"token punctuation\">;<\/span>lib<span class=\"token punctuation\">\\\\<\/span>a.jar<span class=\"token punctuation\">;<\/span>lib<span class=\"token punctuation\">\\\\<\/span>b.jar<span class=\"token punctuation\">;<\/span>lib<span class=\"token punctuation\">\\\\<\/span>c.zip HelloWorld<\/p>\n<p><span class=\"token comment\"># Linux \/ Mac&#xff1a;\u7528\u5192\u53f7 :<\/span><br \/>\n<span class=\"token function\">java<\/span> <span class=\"token parameter variable\">-cp<\/span> path\/to\/classes:lib\/a.jar:lib\/b.jar:lib\/c.zip HelloWorld<\/p>\n<p>\u91cd\u70b9&#xff1a;\u8fd9\u662f\u65b0\u624b\u6700\u5bb9\u6613\u8e29\u7684\u5751\u4e4b\u4e00\u3002Windows \u7528\u5206\u53f7 ;&#xff0c;\u7c7b UNIX&#xff08;Linux\/Mac&#xff09;\u7528\u5192\u53f7 :\u3002\u5199\u9519\u4e86 JVM \u4f1a\u628a\u6574\u4e32\u5f53\u6210\u4e00\u4e2a\u8def\u5f84&#xff0c;\u7136\u540e\u62a5 ClassNotFoundException\u3002<\/p>\n<p>\u6211\u4eec\u7684 jvmgo \u4f1a\u7528 os.PathListSeparator \u6765\u81ea\u52a8\u9002\u914d&#xff0c;\u4e0d\u7528\u786c\u7f16\u7801&#xff1a;<\/p>\n<p><span class=\"token keyword\">const<\/span> pathListSeparator <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">string<\/span><span class=\"token punctuation\">(<\/span>os<span class=\"token punctuation\">.<\/span>PathListSeparator<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\">\/\/ Windows \u4e0b\u662f &#034;;&#034;&#xff0c;Linux\/Mac \u4e0b\u662f &#034;:&#034;<\/span><\/p>\n<h4>\u901a\u914d\u7b26&#xff1a;Java 6 \u7684\u9ed1\u79d1\u6280<\/h4>\n<p>\u4ece Java 6 \u5f00\u59cb&#xff0c;\u53ef\u4ee5\u7528\u901a\u914d\u7b26 * \u4e00\u6b21\u6307\u5b9a\u67d0\u4e2a\u76ee\u5f55\u4e0b\u7684\u6240\u6709 JAR \u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token comment\"># lib \u76ee\u5f55\u4e0b\u7684\u6240\u6709 jar \u90fd\u4f1a\u88ab\u52a0\u5165\u7c7b\u8def\u5f84<\/span><br \/>\n<span class=\"token function\">java<\/span> <span class=\"token parameter variable\">-cp<\/span> classes<span class=\"token punctuation\">;<\/span>lib<span class=\"token punctuation\">\\\\<\/span>* HelloWorld<\/p>\n<p>\u6ce8\u610f\u51e0\u4e2a\u7ec6\u8282&#xff1a;<\/p>\n<table>\n<tr>\u7ec6\u8282\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u5199\u6cd5<\/td>\n<td>\u5fc5\u987b\u662f lib\\\\*&#xff0c;\u4e0d\u80fd\u5199\u6210 lib\\\\*.jar<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u9012\u5f52<\/td>\n<td>\u4e0d\u9012\u5f52&#xff01;\u53ea\u5339\u914d lib\/ \u4e0b\u7684 jar&#xff0c;\u4e0d\u542b\u5b50\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>\u5339\u914d\u4ec0\u4e48<\/td>\n<td>\u53ea\u5339\u914d .jar \u548c .JAR&#xff0c;\u4e0d\u5339\u914d .zip<\/td>\n<\/tr>\n<tr>\n<td>\u987a\u5e8f<\/td>\n<td>\u5339\u914d\u5230\u7684 jar \u987a\u5e8f\u4e0d\u786e\u5b9a&#xff08;\u4f9d\u8d56\u6587\u4ef6\u7cfb\u7edf&#xff09;&#xff0c;\u522b\u4f9d\u8d56\u987a\u5e8f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u3010\u901a\u914d\u7b26\u5339\u914d\u793a\u610f\u56fe\u3011<\/p>\n<p>  lib\/<br \/>\n  \u251c\u2500\u2500 a.jar          \u2705 \u5339\u914d&#xff08;lib\/* \u4f1a\u52a0\u8f7d&#xff09;<br \/>\n  \u251c\u2500\u2500 b.jar          \u2705 \u5339\u914d<br \/>\n  \u251c\u2500\u2500 c.JAR          \u2705 \u5339\u914d&#xff08;\u5927\u5c0f\u5199\u4e0d\u654f\u611f&#xff09;<br \/>\n  \u251c\u2500\u2500 d.zip          \u274c \u4e0d\u5339\u914d&#xff08;\u901a\u914d\u7b26\u53ea\u8ba4 jar&#xff09;<br \/>\n  \u251c\u2500\u2500 e.class        \u274c \u4e0d\u5339\u914d<br \/>\n  \u2514\u2500\u2500 sub\/<br \/>\n      \u2514\u2500\u2500 f.jar      \u274c \u4e0d\u5339\u914d&#xff08;\u4e0d\u9012\u5f52\u5b50\u76ee\u5f55&#xff09;<\/p>\n<hr \/>\n<h3>\u56db\u3001CLASSPATH \u73af\u5883\u53d8\u91cf&#xff1a;\u4e3a\u4ec0\u4e48&#034;\u4e0d\u63a8\u8350&#034;<\/h3>\n<p>\u9664\u4e86 -cp \u9009\u9879&#xff0c;\u8fd8\u53ef\u4ee5\u8bbe\u7f6e CLASSPATH \u73af\u5883\u53d8\u91cf\u6765\u6307\u5b9a\u7528\u6237\u7c7b\u8def\u5f84&#xff1a;<\/p>\n<p><span class=\"token comment\"># Windows<\/span><br \/>\n<span class=\"token builtin class-name\">set<\/span> <span class=\"token assign-left variable\">CLASSPATH<\/span><span class=\"token operator\">&#061;<\/span>D:<span class=\"token punctuation\">\\\\<\/span>classes<span class=\"token punctuation\">;<\/span>D:<span class=\"token punctuation\">\\\\<\/span>lib<span class=\"token punctuation\">\\\\<\/span>a.jar<\/p>\n<p><span class=\"token comment\"># Linux \/ Mac<\/span><br \/>\n<span class=\"token builtin class-name\">export<\/span> <span class=\"token assign-left variable\">CLASSPATH<\/span><span class=\"token operator\">&#061;<\/span>\/home\/user\/classes:\/home\/user\/lib\/a.jar<\/p>\n<p>\u4f46\u5f3a\u70c8\u4e0d\u63a8\u8350\u8fd9\u4e48\u505a\u3002 \u539f\u56e0\u6709\u4e09&#xff1a;<\/p>\n<h4>\u7406\u7531 1&#xff1a;\u4f18\u5148\u7ea7\u95ee\u9898<\/h4>\n<p>-classpath \/ -cp \u9009\u9879\u7684\u4f18\u5148\u7ea7\u66f4\u9ad8&#xff0c;\u4f1a\u8986\u76d6 CLASSPATH \u73af\u5883\u53d8\u91cf&#xff1a;<\/p>\n<p>\u3010\u4f18\u5148\u7ea7\u3011<\/p>\n<p>  -cp \u9009\u9879    &gt;    CLASSPATH \u73af\u5883\u53d8\u91cf    &gt;    \u9ed8\u8ba4\u5f53\u524d\u76ee\u5f55 &#034;.&#034;<br \/>\n   (\u6700\u9ad8)                                      (\u6700\u4f4e)<\/p>\n<p>\u8fd9\u4f1a\u9020\u6210\u56f0\u60d1&#xff1a;\u4f60\u660e\u660e\u8bbe\u4e86\u73af\u5883\u53d8\u91cf&#xff0c;\u4f46\u522b\u4eba\u7528 -cp \u8dd1\u7a0b\u5e8f\u65f6\u5b83\u5b8c\u5168\u4e0d\u8d77\u4f5c\u7528&#xff0c;\u6392\u67e5\u8d77\u6765\u5f88\u61f5\u3002<\/p>\n<h4>\u7406\u7531 2&#xff1a;\u5168\u5c40\u6c61\u67d3<\/h4>\n<p>\u73af\u5883\u53d8\u91cf\u662f\u5168\u5c40\u7684\u3002\u4f60\u5728\u673a\u5668\u4e0a\u8bbe\u4e86 CLASSPATH&#xff0c;\u4f1a\u5f71\u54cd\u6240\u6709 Java \u7a0b\u5e8f\u2014\u2014\u5305\u62ec\u90a3\u4e9b\u4f60\u4e0d\u8be5\u5f71\u54cd\u7684\u7a0b\u5e8f&#xff08;\u6bd4\u5982 IDE\u3001\u6784\u5efa\u5de5\u5177\u3001\u5176\u4ed6\u9879\u76ee&#xff09;\u3002<\/p>\n<h4>\u7406\u7531 3&#xff1a;\u4e0d\u53ef\u79fb\u690d<\/h4>\n<p>\u4f60\u7684\u7a0b\u5e8f\u6362\u53f0\u673a\u5668\u8dd1&#xff0c;CLASSPATH \u5c31\u5f97\u91cd\u65b0\u914d\u4e00\u904d\u3002\u800c -cp \u9009\u9879\u901a\u5e38\u5199\u5728\u542f\u52a8\u811a\u672c\u91cc&#xff0c;\u8ddf\u7740\u9879\u76ee\u8d70&#xff0c;\u53ef\u79fb\u690d\u6027\u597d\u5f97\u591a\u3002<\/p>\n<p>\u6700\u4f73\u5b9e\u8df5&#xff1a;\u6c38\u8fdc\u7528 -cp \u9009\u9879&#xff0c;\u522b\u7528 CLASSPATH \u73af\u5883\u53d8\u91cf\u3002\u5982\u679c\u975e\u8981\u7528\u73af\u5883\u53d8\u91cf&#xff0c;\u4e5f\u53ea\u5728\u4e34\u65f6\u6d4b\u8bd5\u65f6\u7528&#xff0c;\u522b\u5199\u8fdb\u7cfb\u7edf\u914d\u7f6e\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u6211\u4eec\u7684 jvmgo \u8981\u600e\u4e48\u5b9e\u73b0&#xff1f;<\/h3>\n<p>\u7406\u89e3\u4e86\u6982\u5ff5&#xff0c;\u6765\u770b\u5b9e\u73b0\u601d\u8def\u3002<\/p>\n<p>jvmgo \u7684 ch02 \u4f1a\u505a\u8fd9\u4e9b\u4e8b&#xff1a;<\/p>\n<p>\u3010ch02 \u7c7b\u8def\u5f84\u5b9e\u73b0\u89c4\u5212\u3011<\/p>\n<p>  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n  \u2502                    Classpath                         \u2502<br \/>\n  \u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502<br \/>\n  \u2502  \u2502 bootClasspath \u2502 extClasspath  \u2502 userClasspath  \u2502 \u2502<br \/>\n  \u2502  \u2502 (jre\/lib\/*)   \u2502(jre\/lib\/ext\/*)\u2502 (-cp \u6216 &#034;.&#034;)   \u2502 \u2502<br \/>\n  \u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2502<br \/>\n  \u2502          \u2502               \u2502                \u2502         \u2502<br \/>\n  \u2502          \u2502  \u6bcf\u79cd\u90fd\u662f Entry \u63a5\u53e3\u7684\u67d0\u4e2a\u5b9e\u73b0              \u2502<br \/>\n  \u2502          \u25bc               \u25bc                \u25bc         \u2502<br \/>\n  \u2502   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510    \u2502<br \/>\n  \u2502   \u2502              Entry \u63a5\u53e3                      \u2502    \u2502<br \/>\n  \u2502   \u2502   readClass(className) ([]byte, Entry, error)\u2502    \u2502<br \/>\n  \u2502   \u2502   String() string                           \u2502    \u2502<br \/>\n  \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518    \u2502<br \/>\n  \u2502                                                      \u2502<br \/>\n  \u2502   4 \u79cd\u5b9e\u73b0&#xff1a;                                          \u2502<br \/>\n  \u2502   \u00b7 DirEntry        \u2014\u2014 \u76ee\u5f55\u5f62\u5f0f                      \u2502<br \/>\n  \u2502   \u00b7 ZipEntry        \u2014\u2014 JAR\/ZIP \u6587\u4ef6\u5f62\u5f0f              \u2502<br \/>\n  \u2502   \u00b7 CompositeEntry  \u2014\u2014 \u591a\u8def\u5f84\u7ec4\u5408&#xff08;\u5206\u53f7\/\u5192\u53f7\u5206\u9694&#xff09;      \u2502<br \/>\n  \u2502   \u00b7 WildcardEntry   \u2014\u2014 \u901a\u914d\u7b26\u5f62\u5f0f&#xff08;lib\/*&#xff09;            \u2502<br \/>\n  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u6838\u5fc3 API \u8bbe\u8ba1&#xff08;\u8fd9\u662f JVM \u89c4\u8303\u4e4b\u5916\u7684\u5b9e\u73b0\u7ec6\u8282&#xff0c;\u6211\u4eec\u53c2\u8003 Oracle \u7684\u505a\u6cd5&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u89e3\u6790\u7c7b\u8def\u5f84<\/span><br \/>\n<span class=\"token keyword\">func<\/span> <span class=\"token function\">Parse<\/span><span class=\"token punctuation\">(<\/span>jreOption<span class=\"token punctuation\">,<\/span> cpOption <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">*<\/span>Classpath<\/p>\n<p><span class=\"token comment\">\/\/ \u8bfb\u53d6 class \u6587\u4ef6&#xff08;\u6309 \u542f\u52a8 \u2192 \u6269\u5c55 \u2192 \u7528\u6237 \u7684\u987a\u5e8f\u641c\u7d22&#xff09;<\/span><br \/>\n<span class=\"token keyword\">func<\/span> <span class=\"token punctuation\">(<\/span>self <span class=\"token operator\">*<\/span>Classpath<span class=\"token punctuation\">)<\/span> <span class=\"token function\">ReadClass<\/span><span class=\"token punctuation\">(<\/span>className <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token builtin\">byte<\/span><span class=\"token punctuation\">,<\/span> Entry<span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">error<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8c03\u7528\u793a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u5728 startJVM \u4e2d\u4f7f\u7528<\/span><br \/>\ncp <span class=\"token operator\">:&#061;<\/span> classpath<span class=\"token punctuation\">.<\/span><span class=\"token function\">Parse<\/span><span class=\"token punctuation\">(<\/span>cmd<span class=\"token punctuation\">.<\/span>XjreOption<span class=\"token punctuation\">,<\/span> cmd<span class=\"token punctuation\">.<\/span>cpOption<span class=\"token punctuation\">)<\/span><br \/>\ndata<span class=\"token punctuation\">,<\/span> entry<span class=\"token punctuation\">,<\/span> err <span class=\"token operator\">:&#061;<\/span> cp<span class=\"token punctuation\">.<\/span><span class=\"token function\">ReadClass<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;java\/lang\/Object&#034;<\/span><span class=\"token punctuation\">)<\/span>   <span class=\"token comment\">\/\/ \u53c2\u6570\u7528\u659c\u7ebf\u5206\u9694<\/span><br \/>\n<span class=\"token keyword\">if<\/span> err <span class=\"token operator\">!&#061;<\/span> <span class=\"token boolean\">nil<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    fmt<span class=\"token punctuation\">.<\/span><span class=\"token function\">Printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u627e\u4e0d\u5230 java.lang.Object: %v\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> err<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\nfmt<span class=\"token punctuation\">.<\/span><span class=\"token function\">Printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u627e\u5230 java\/lang\/Object.class&#xff0c;\u6765\u81ea&#xff1a;%v&#xff0c;\u5171 %d \u5b57\u8282\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> entry<span class=\"token punctuation\">,<\/span> <span class=\"token function\">len<\/span><span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u91cd\u70b9&#xff1a;\u6ce8\u610f ReadClass \u7684\u53c2\u6570\u683c\u5f0f\u2014\u2014\u7528\u659c\u7ebf \/ \u5206\u9694&#xff0c;\u5e26 .class \u540e\u7f00\u3002\u6bd4\u5982 java.lang.Object \u8981\u5199\u6210 java\/lang\/Object.class\u3002\u8fd9\u8ddf\u78c1\u76d8\u8def\u5f84\u7684\u5199\u6cd5&#xff08;Windows \u7528\u53cd\u659c\u6760&#xff09;\u4e0d\u4e00\u6837&#xff0c;\u662f JVM \u5185\u90e8\u7684\u7edf\u4e00\u8868\u793a\u6cd5\u3002<\/p>\n<hr \/>\n<h3>\u672c\u7bc7\u5c0f\u7ed3<\/h3>\n<p>\u7c7b\u8def\u5f84\u662f JVM \u5b9a\u4f4d class \u6587\u4ef6\u7684\u673a\u5236&#xff0c;\u6838\u5fc3\u8981\u70b9&#xff1a;<\/p>\n<li>\u4e09\u5927\u6765\u6e90&#xff1a;\u542f\u52a8\u7c7b\u8def\u5f84&#xff08;jre\/lib&#xff0c;\u6838\u5fc3\u7c7b\u5e93 rt.jar&#xff09;\u2192 \u6269\u5c55\u7c7b\u8def\u5f84&#xff08;jre\/lib\/ext&#xff09;\u2192 \u7528\u6237\u7c7b\u8def\u5f84&#xff08;\u9ed8\u8ba4 .&#xff09;&#xff0c;\u6309\u6b64\u987a\u5e8f\u641c\u7d22&#xff0c;\u627e\u5230\u5373\u505c<\/li>\n<li>-cp \u9009\u9879&#xff1a;\u53ef\u6307\u5b9a\u76ee\u5f55\u3001jar\u3001zip&#xff0c;\u591a\u4e2a\u7528\u5206\u9694\u7b26\u9694\u5f00&#xff08;Windows \u5206\u53f7 \/ Linux \u5192\u53f7&#xff09;<\/li>\n<li>\u901a\u914d\u7b26&#xff1a;Java 6&#043; \u652f\u6301 lib\/* \u5339\u914d\u76ee\u5f55\u4e0b\u6240\u6709 jar&#xff08;\u4e0d\u9012\u5f52\u3001\u53ea\u8ba4 jar\u3001\u987a\u5e8f\u4e0d\u5b9a&#xff09;<\/li>\n<li>\u522b\u7528 CLASSPATH \u73af\u5883\u53d8\u91cf&#xff1a;\u4f18\u5148\u7ea7\u4f4e\u4e8e -cp\u3001\u5168\u5c40\u6c61\u67d3\u3001\u4e0d\u53ef\u79fb\u690d<\/li>\n<li>\u6211\u4eec\u7684\u5b9e\u73b0&#xff1a;\u7528 Entry \u63a5\u53e3 &#043; 4 \u79cd\u5b9e\u73b0&#xff08;Dir\/Zip\/Composite\/Wildcard&#xff09;\u6765\u7edf\u4e00\u62bd\u8c61<\/li>\n<p>\u4e0b\u4e00\u7bc7&#xff0c;\u6211\u4eec\u6b63\u5f0f\u5f00\u59cb\u5199\u4ee3\u7801\u2014\u2014\u8bbe\u8ba1 Entry \u63a5\u53e3&#xff0c;\u628a\u7c7b\u8def\u5f84\u62bd\u8c61\u6210\u53ef\u7ec4\u5408\u7684&#034;\u79ef\u6728\u5757&#034;\u3002\u8fd9\u91cc\u4f1a\u7528\u5230\u4e00\u4e2a\u7ecf\u5178\u8bbe\u8ba1\u6a21\u5f0f&#xff1a;\u7ec4\u5408\u6a21\u5f0f&#xff08;Composite Pattern&#xff09;\u3002<\/p>\n<hr \/>\n<p>\u4e0a\u4e00\u7bc7\u3010\u7b2c05\u7bc7\u3011\u9879\u76ee\u7ed3\u6784\u4e0e\u7b2c\u4e00\u884c\u4ee3\u7801\u2014\u2014jvmgo \u9879\u76ee\u9aa8\u67b6\u642d\u5efa \u4e0b\u4e00\u7bc7\u3010\u7b2c07\u7bc7\u3011Entry \u63a5\u53e3\u8bbe\u8ba1\u2014\u2014\u7c7b\u8def\u5f84\u7684&#034;\u79ef\u6728\u5757&#034;<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u3010\u7b2c05\u7bc7\u3011\u9879\u76ee\u7ed3\u6784\u4e0e\u7b2c\u4e00\u884c\u4ee3\u7801\u2014\u2014jvmgo \u9879\u76ee\u9aa8\u67b6\u642d\u5efa \u4e0b\u4e00\u7bc7\u3010\u7b2c07\u7bc7\u3011Entry \u63a5\u53e3\u8bbe\u8ba1\u2014\u2014\u7c7b\u8def\u5f84\u7684\\&#8221;\u79ef\u6728\u5757\\&#8221; \u6458\u8981<br \/>\n\u5199\u4e00\u4e2a JVM&#xff0c;\u7b2c\u4e00\u4ef6\u8981\u89e3\u51b3\u7684\u4e8b\u5c31\u662f&#xff1a;\u53bb\u54ea\u513f\u627e class \u6587\u4ef6&#xff1f;<br \/>\n\u6709\u610f\u601d\u7684\u662f&#xff0c;Java \u865a\u62df\u673a\u89c4\u8303\u5e76\u6ca1\u6709\u89c4\u5b9a\u865a\u62df\u673a\u8be5\u4ece\u54ea\u91cc\u5bfb\u627e\u7c7b\u2014\u2014\u8fd9\u662f\u7559\u7ed9\u5b9e\u73b0\u8005\u7684\u81ea\u7531\u3002Oracle \u7684 JVM \u7528\u7684\u662f\\&#8221;\u7c7b\u8def\u5f84&#xff08;classpath&#xff09;\\&#8221;\u65b9\u6848&#xff0c;\u6211\u4eec\u7684 jvmg<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11911,99,426,190,1412],"topic":[],"class_list":["post-104717","post","type-post","status-publish","format-standard","hentry","category-server","tag-classpath","tag-java","tag-jvm","tag-190","tag-1412"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/104717.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e0a\u4e00\u7bc7\u3010\u7b2c05\u7bc7\u3011\u9879\u76ee\u7ed3\u6784\u4e0e\u7b2c\u4e00\u884c\u4ee3\u7801\u2014\u2014jvmgo \u9879\u76ee\u9aa8\u67b6\u642d\u5efa \u4e0b\u4e00\u7bc7\u3010\u7b2c07\u7bc7\u3011Entry \u63a5\u53e3\u8bbe\u8ba1\u2014\u2014\u7c7b\u8def\u5f84\u7684&quot;\u79ef\u6728\u5757&quot; \u6458\u8981 \u5199\u4e00\u4e2a JVM&#xff0c;\u7b2c\u4e00\u4ef6\u8981\u89e3\u51b3\u7684\u4e8b\u5c31\u662f&#xff1a;\u53bb\u54ea\u513f\u627e class \u6587\u4ef6&#xff1f; \u6709\u610f\u601d\u7684\u662f&#xff0c;Java \u865a\u62df\u673a\u89c4\u8303\u5e76\u6ca1\u6709\u89c4\u5b9a\u865a\u62df\u673a\u8be5\u4ece\u54ea\u91cc\u5bfb\u627e\u7c7b\u2014\u2014\u8fd9\u662f\u7559\u7ed9\u5b9e\u73b0\u8005\u7684\u81ea\u7531\u3002Oracle \u7684 JVM \u7528\u7684\u662f&quot;\u7c7b\u8def\u5f84&#xff08;classpath&#xff09;&quot;\u65b9\u6848&#xff0c;\u6211\u4eec\u7684 jvmg\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/104717.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-12T23:01:07+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/104717.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/104717.html\",\"name\":\"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-12T23:01:07+00:00\",\"dateModified\":\"2026-09-12T23:01:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/104717.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/104717.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/104717.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/104717.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e0a\u4e00\u7bc7\u3010\u7b2c05\u7bc7\u3011\u9879\u76ee\u7ed3\u6784\u4e0e\u7b2c\u4e00\u884c\u4ee3\u7801\u2014\u2014jvmgo \u9879\u76ee\u9aa8\u67b6\u642d\u5efa \u4e0b\u4e00\u7bc7\u3010\u7b2c07\u7bc7\u3011Entry \u63a5\u53e3\u8bbe\u8ba1\u2014\u2014\u7c7b\u8def\u5f84\u7684\"\u79ef\u6728\u5757\" \u6458\u8981 \u5199\u4e00\u4e2a JVM&#xff0c;\u7b2c\u4e00\u4ef6\u8981\u89e3\u51b3\u7684\u4e8b\u5c31\u662f&#xff1a;\u53bb\u54ea\u513f\u627e class \u6587\u4ef6&#xff1f; \u6709\u610f\u601d\u7684\u662f&#xff0c;Java \u865a\u62df\u673a\u89c4\u8303\u5e76\u6ca1\u6709\u89c4\u5b9a\u865a\u62df\u673a\u8be5\u4ece\u54ea\u91cc\u5bfb\u627e\u7c7b\u2014\u2014\u8fd9\u662f\u7559\u7ed9\u5b9e\u73b0\u8005\u7684\u81ea\u7531\u3002Oracle \u7684 JVM \u7528\u7684\u662f\"\u7c7b\u8def\u5f84&#xff08;classpath&#xff09;\"\u65b9\u6848&#xff0c;\u6211\u4eec\u7684 jvmg","og_url":"https:\/\/www.wsisp.com\/helps\/104717.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-12T23:01:07+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/104717.html","url":"https:\/\/www.wsisp.com\/helps\/104717.html","name":"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-12T23:01:07+00:00","dateModified":"2026-09-12T23:01:07+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/104717.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/104717.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/104717.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010DIY\u7cfb\u5217\uff1aJava\u865a\u62df\u673a\u3011\u7b2c06\u7bc7\uff1a\u7c7b\u8def\u5f84\uff08classpath\uff09\u662f\u4ec0\u4e48\u9b3c\u2014\u2014JVM \u600e\u4e48\u627e\u5230\u4f60\u7684 class \u6587\u4ef6"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/104717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=104717"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/104717\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=104717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=104717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=104717"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=104717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}