Java ?? Class Path ?? Package
???????????? ???????[ 2013/7/29 10:29:57 ] ????????
????????
????????????????????????y?? ??????????? ??????????? ???????д?????? ?????????.
?????????
??????? ??·?? (class path)
???????????????????????? java?? ????????д??? hello world???????????У? ???????????????????????????? ??????????? ??????? Can't find class HelloWorld ???? Exception in thread "main" java.lang.NoSuchMethodError ?? maain.?????? ?????? class ???????.
?????????????????? java ????????й???. ?????????? java ????? java??????????????е?? ?????? java ???? javac ????????? .class?????????????е???? ?????????(bytecode)?? ???????? classloader???????Щ????? ???????????????. ????????????? classloader ????????? java ???????????????????????????? ???????????(???·??).????????????????????????????? ???????????·??(classpath)?? ?????????е???????????????. ???????? classpath ??????????. ????????????е??????С?? ????????????????? ???????????????. ????? java ????????? java luncher ???????? ??? java (?? java.exe)?????????????. ??????????????????????????????????
????1?? ?????? ??? java ?????? ???? rt.jar ?? i18n.jar ?е???.
????2?? ????? ??? java ?????????? ????λ???????($JAVA_HOME/jre/lib/ext)?е? .jar ??????.
????3?? ????? ????????????????????? java ????????????????. ?????????????????? -classpath ????????? CLASSPATH ???????????????Щ???λ??. ????????????????????????????????Щ??.?????? ???????? ???????????????λ??? ??????????????"???"????.
???????????????????? ?????·?????Щ??????????????? .jar?? .zip ??????б?? ??????????????? ???????? package ?????? ???潫??????? ?????????????????????????????????. ?????????????????в???? ?? unix ????????????? "??"?? windows ???? "??". ????????????
????* "."?? ????????? ????????.
????* CLASSPATH ?????????? ???????? ?????????.
????* ?????в??? -cp ???? -classpath?? ???????? ???????????.
????* ?? -jar ????????? .jar ???????? ?????????????????? ???е??????????????????????. ???????????е? .jar ????? ??????????Щ???? ???? package?? ?????????????????? ?????????. ??????? jdk ??????Щ????.
?????????? HelloWorld ???????????. ??????????裺
????* ??????? /HelloWorld (?? c??HelloWorld?? ??????????)
????* jdk ?汾? 1.2.2 (linux ?μ?)
????* PATH ???????????????. (???????????κ????????????ù???)
????* ????? HelloWorld.java?? ???????
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!
");
System.exit(0);
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11