˵һÏÂ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:\
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖÆµÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
1.ÉèÖÃCookie
Cookie cookie = new Cookie("key", "value");
cookie.setMaxAge(60);
ÉèÖÃ60ÃëÉú´æÆÚ£¬Èç¹ûÉèÖÃΪ¸ºÖµµÄ»°£¬ÔòΪä¯ÀÀÆ÷½ø³ÌCookie(ÄÚ´æÖб£´æ)£¬¹Ø±Õä¯ÀÀÆ÷¾ÍʧЧ¡£
cookie.setPath("/test/test2");
ÉèÖÃCookie·¾¶£¬²»ÉèÖõĻ°Îªµ±Ç°Â·¾¶(¶ÔÓÚServletÀ´ËµÎªrequest. ......
Java
ƽ̨ÒÑÎÞ´¦²»ÔÚ£¬Java EE¡¢Java SE¡¢Java ME ºÍ Java Card£¬Java
µÄ·¢Õ¹ÎªÎÞÊý³ÌÐòÔ±ÌṩÁ˹¤×÷»ú»á£¬¶¼ÊÇ“Java”£¬È»¶ø³ýÁË»ù±¾µÄ Java
Óï·¨´ó¶¼Ò»ÖÂÍ⣬³ÌÐòÔ±±ØÐë»ùÓÚ²»Í¬µÄƽ̨Óв»Í¬µÄ¿¼ÂÇ£¬Ñ§Ï°²»Í¬Æ½Ì¨µÄÌØµã£º
²»Í¬Æ½Ì¨µÄ»·¾³
Java EE ËùÔËÐеÄÓ²¼þ·þÎñÆ÷¡¢²Ù×÷ϵͳ£¬Java SE ËùÔÚ PC »ú ......
´ó¼ÒÔÚÈ¥²Î¼ÓÃæÊÔµÄʱºò£¬¾³£»áÓöµ½ÕâÑùµÄ¿¼Ì⣺¸øÄãÁ½¸öÀàµÄ´úÂ룬ËüÃÇÖ®¼äÊǼ̳еĹØÏµ£¬Ã¿¸öÀàÀïÖ»Óй¹ÔìÆ÷·½·¨ºÍһЩ±äÁ¿£¬¹¹ÔìÆ÷Àï¿ÉÄÜ»¹ÓÐÒ»¶Î´úÂë¶Ô±äÁ¿Öµ½øÐÐÁËijÖÖÔËË㣬ÁíÍ⻹ÓÐһЩ½«±äÁ¿ÖµÊä³öµ½¿ØÖÆÌ¨µÄ´úÂ룬ȻºóÈÃÎÒÃÇÅжÏÊä³öµÄ½á¹û¡£Õâʵ¼ÊÉÏÊÇÔÚ¿¼²éÎÒÃǶÔÓڼ̳ÐÇé¿öÏÂÀàµÄ³õʼ»¯Ë³ÐòµÄÁ˽⡣
ÎÒÃÇ´ó¼ ......
¶¨Òå:
SingletonģʽÖ÷Òª×÷ÓÃÊDZ£Ö¤ÔÚJavaÓ¦ÓóÌÐòÖУ¬Ò»¸öÀàClassÖ»ÓÐÒ»¸öʵÀý´æÔÚ¡£
Ôںܶà²Ù×÷ÖУ¬±ÈÈ罨Á¢Ä¿Â¼ Êý¾Ý¿âÁ¬½Ó¶¼ÐèÒªÕâÑùµÄµ¥Ï̲߳Ù×÷¡£
»¹ÓÐ, singletonÄܹ»±»×´Ì¬»¯;
ÕâÑù£¬¶à¸öµ¥Ì¬ÀàÔÚÒ»Æð¾Í¿ÉÒÔ×÷Ϊһ¸ö״̬²Ö¿âÒ»ÑùÏòÍâÌṩ·þÎñ£¬±ÈÈ磬ÄãÒªÂÛ̳ÖеÄÌû×Ó¼ÆÊýÆ÷£¬Ã¿´Îä¯ÀÀÒ»´ÎÐèÒª¼ÆÊý£¬µ¥Ì¬ÀàÄÜ·ñ ......