JavaÀïÃæµÄ·¾¶ÎÊÌ⣬CLASSPATHºÍSOURCEPATH
javaµÄ·¾¶ÈÃÐí¶àÈË£¬ÌرðÊdzõѧÕ߸е½ÃÔ»ó£¬ÎÒÕâÀïÔÙ½âÊÍһϡ£ÎÒÃÇ·Ö2¸ö½×¶Î£¬1ÊDZàÒë½×¶Î£¬2ÊÇÔËÐн׶Ρ£
Ò»¡¢±àÒë½×¶Î
Õâ¸öʱºò£¬ÎÒÃÇÒªÌṩ¸ø±àÒëÆ÷µÄÓÐ2¸ö·¾¶²ÎÊý£¬µÚÒ»¸öÊÇÔ´´úÂëÔÚÄÄÀҲ¾ÍÊÇ sourcepath,µÚ¶þ¸ö¾ÍÊÇÒÀÀµµÄÀàÔÚÄÄÀҲ¾ÍÊÇ classpath
ÎÒÃÇ¿´Ò»¸öÀý×Ó
d:\temp\TestCP\d1\p1\Class1.java
view plaincopy to clipboardprint?
package p1;
public class Class1 {
public void show(){
System.out.println("Class1");
}
}
package p1;
public class Class1 {
public void show(){
System.out.println("Class1");
}
}
d:\temp\TestCP\d2\p2\Class2.java
view plaincopy to clipboardprint?
package p2;
import p1.Class1;
public class Class2 {
public static void main(String[] args){
Class1 c1 = new Class1();
c1.show();
}
}
package p2;
import p1.Class1;
public class Class2 {
public static void main(String[] args){
Class1 c1 = new Class1();
c1.show();
}
}
±àÒëµÄʱºò£¬ÎÒÃÇÏÈÔÚ d:\temp\testCP\d1 ±àÒëClass1
D:\temp\testCP\d1>javac p1\Class1.java
±àÒë³É¹¦
È»ºóÎÒÃÇÔÚ d:\temp\testCP\d2 ϱàÒë Class2¡£ÓÐ2¸ö·½·¨½øÐбàÒ룺
µÚÒ»£ºÖ¸¶¨Ô´Îļþ sourcepath
D:\temp\testCP\d2>javac -sourcepath .;../d1 p2\Class2.java
µÚ¶þ£ºÖ¸¶¨classpath
D:\temp\testCP\d2>javac -sourcepath . -cp ../d1 p2\Class2.java
Á½¸ö·½·¨¶¼ÄÜ´ïµ½ÎÒÃÇÐèÒªµÄЧ¹û¡£Ò²¾ÍÊÇ˵£¬ÔÚ·¾¶Àϵͳ»áÔÚÆäÏÂÃæ¸ù¾Ýpackage×Ô¶¯Ñ°ÕÒÔ´Îļþ»òÕßclassÎļþµÄ¡£
ÁíÒ»¸öÇé¿ö£¬Èç¹ûÎÒÃÇÐèҪij¸öÀà¿âµÄÖ§³Ö£¬±ÈÈçjarÎļþ£¬ÄÇôÎÒÃǾͲ»ÄÜÖ»°üº¬Â·¾¶¾ÍÐÐÁË£¬¶øÊÇÓ¦¸Ã°üº¬Õû¸ö·¾¶ºÍÎļþÃû£¬±ÈÈç
D:\temp\testCP\d2>javac -sourcepath . -cp ../d1;d:/lib/spring.jar p2\Class2.java
µÚ¶þ¡¢ÔÚÔËÐÐʱ
ÎÒÃÇÐèÒªÖ¸¶¨ÆäËûµÄclassÔÚÄÄÀÒÔ¼°ÎÒÃÇÐèÒªµÄÀà¿âÔÚÄÄÀËùÒÔÔËÐÐÃüÁîÓ¦¸ÃÊÇ
D:\te
Ïà¹ØÎĵµ£º
ÇмǣºÎÞÂÛhibernate»¹ÊÇjdbcµÄÊÂÎñ¿ØÖƶ¼Ó¦ÔÚservice²ã!
jdbcÊÂÎñ¹ÜÀíÒª±£Ö¤service ²ãÓëdao²ãÊÇ»ùÓÚͬһ¸öConnection;
Ò²¾ÍÊÇ˵ÔÚservice²ãÀïµÃµ½Connection £¬DAOÖз½·¨ÒÔ²ÎÊýµÄÐÎʽµÃµ½Õâ¸öʵÀý¡£¡£
δÍê´ýÐø¡£¡£¡£ ......
ÎÒÔÚ¼ÆËã»úÐÐÒµºÍÎÒµÄͼ±êÒ»Ñù»¹Ö»ÊÇÒ»¸öСº¢£¬µ±ÎÒÔÚÄÃϼÆËã»ú4¼¶£¨Èí¼þ²âÊÔ¹¤³Ìʦ£©ºÍ±àдÁ˲»ÉÙµÄͦcoolµÄ³ÌÐòÖ®ºó£¬¾õµÃ
×Ô¼ºË®Æ½²»Àµ¹þ¡£½á¹û¸Õ¿çÈëÒ»¸ö´ó¹«Ë¾ÊµÏ°µÄʱºò£¬ÎÒ¿´µ½ÎÒµÄÄǸöÏîÄ¿£¬ºÜ¿ìÎÒ±à³ÌµÄ˼άÓÖÔÚÌø¶¯£¬¿É“ÀÏ´ó”À´ÁËÒ»¾äc/c++ʵÏÖ
£¬ÎҾͷ·ðµ½ÁËÒ»¸ ......
Ì°³ÔÉßµÄËã·¨·ÖÎö(Java)
Ì°³ÔÉßÊÇÒ»¿î·Ç³£¾µäµÄÊÖ»úÓÎÏ·¡£ËüÓкܶàËã·¨£¬ÕâÀïÏêϸ·ÖÎöÒ»ÖֱȽÏÓÅÐãµÄËã·¨¡£
Ê×ÏȽéÉÜÏÂÖ÷ÒªÓõ½µÄÆ߸öÀࣺ
l WormMain£º×îÖ÷ÒªµÄÀ࣬¿ØÖÆËùÓÐÆäËüÀàµÄÔËÐкÍÏú»Ù¡£
l &nbs ......
Ò»¡¢ ¶¨Òå
·ÅÔÚÒ»¸öÀàµÄÄÚ²¿µÄÀàÎÒÃǾͽÐÄÚ²¿Àà¡£
¶þ¡¢ ×÷ÓÃ
1.ÄÚ²¿Àà¿ÉÒԺܺõÄʵÏÖÒþ²Ø,Ò²¾ÍÊÇ·â×°ÐÔ¡£Ò»°ãµÄ·ÇÄÚ²¿À࣬ÊDz»ÔÊÐíÓÐ private ÓëprotectedȨÏ޵ģ¬µ«ÄÚ²¿Àà¿ÉÒÔ
2.ÄÚ²¿ÀàÓµÓÐÍâΧÀàµÄËùÓÐÔªËصķÃÎÊȨÏÞ
3.¿ÉÊÇʵÏÖ¶àÖؼ̳Ð
4.¿ÉÒÔ±ÜÃâÐ޸ĽӿڶøʵÏÖͬһ¸öÀàÖÐÁ½ÖÖͬÃû·½·¨µÄµ÷ÓÃ
Èý¡¢ ......