´ÓC++µ½JavaµÄ×¢Òâµã£¨ÉÏ£©
1.JavaµÄ±àÒëÔËÐÐ
JavaÖеÄpackage¸ÅÄîÏ൱ÓÚC++ÖеÄnamespaceµÄ¸ÅÄî¡£µ«ÊÇjava»á°ÑpackageµÄÃû×ÖºÍÎļþϵͳÖÐĿ¼½á¹¹¶ÔÓ¦ÆðÀ´£¬Ò²¼´Èç¹ûÄãÉêÃ÷ÁËij¸öpackageµÄÃû×ÖΪcom.tij.everythingisobj£¬ÄÇôÄãµÄÎļþϵͳÖбØÐë´´½¨com\tij\everythingisobjÕâÑùÒ»¸öĿ¼½á¹¹£¬ËùÓÐÊôÓÚÕâ¸öpackageµÄjavaÔ´´úÂ붼»á·ÅÔÚÕâ¸öĿ¼Ï£¡Ö®ËùÒÔÒªÕâô×ö£¬ÊÇΪÁËjvm¼ÓÔØÔËÐÐjava´úÂë·½±ã£¬¿ÉÒÔ¸ù¾Ýpackage²¢½áºÏCLASSPATHÀ´×°ÔØ*.java±àÒëºóµÄ*.classÔÚʲôλÖá£
ÀýÈçEveryObject .java£º
package com.tij.everythingisobj;
public class EveryObject {
public static void main(String[] args) {
}
}
javac com\tij\everythingisobj\EveryObject.java
Ê×ÏÈÓÃjavacÀ´±àÒë*.javaÎļþ£¬Éú³É*.class¡£¿ÉÒÔ°ÑÕâЩ*.class´ò°ü³ÉÒ»¸öjar°ü£¬µ«±ØÐë±£ÁôÍê³ÉµÄ·¾¶Ãû³Æ¡£
java com.tij.everythingisobj.EveryObject
Éú³É*.classºó£¬¿ÉÒÔÓÃÔÚÃüÁîÐÐÖÐÓÃjavaÃüÁî¸æËßjvmҪװÔØÄĸöÀಢÔËÐУ¬´Ëʱjvm»á¸ù¾ÝCLASSPATHÖÐÉèÖõÄ·¾¶È¥ËÑË÷ÄãÒªÔËÐеÄÀà¡£Èç¹ûÄãµÄCLASSPATHΪ c:\; ./£¬ÄÇôjvm»áÔÚ c:\com/tij/everythingisobjºÍ./com/tij/everythingisobjĿ¼ÏÂËÑË÷EveryObjectÀ࣬²¢×°ÔØËüµÄ¾²Ì¬mainº¯ÊýÔËÐС£ÄãÒ²¿ÉÒÔÔÚjavaÃüÁîÖмÓÈë -cpÀ´Ö¸¶¨CLASSPATH.
java -cp ./everyobj.jar com.tij.everythingisobj.EveryObject
Èç¹ûÄãÒªÔËÐÐ*.jarÎļþ£¬ÄÇô±ØÐë°ÑÄãµÄ*.jarÎļþ°üÀ¨ÔÚ -cpÑ¡ÏîÖС£´ò¿ª*.jarÄã¿ÉÒÔ¿´µ½ÀïÃæÒ²ÊÇÍêÕûµÄ·¾¶Ãû£¬Ä¿Â¼Î÷Ã涼ÊÇ*.class¡£¸úÖ±½Ó·ÅÔÚÎļþϵͳÉÏÖ´ÐÐÊÇÀàËƵġ£
2.JavaµÄpackage
ËùÓÐ*.java¶¼ÒªÊôÓÚijһ¸öpackage£¬Ò»¸öpackage¿ÉÒÔÓµÓÐn¸ö .javaÎļþ£¬Ã¿¸ö.javaÎļþÖÐÖ»ÄÜÓÐÒ»¸öpublicµÄÀà¡£¶øÇÒÕâ¸öÀàÃû±ØÐëÓë.javaµÄÃû×ÖÒ»Ñù¡£Í¬Ò»¸öpackageµÄ *.javaÎļþ¶¼»á·ÅÔÚÎļþϵͳµÄͬһ¸öĿ¼ÏÂÃæ¡£Èç¹ûÔÚ*.javaÖÐûÓÐÖ¸¶¨package name£¬ÄÇô*.javaÊôÓÚËüËùÔÚĿ¼µÄĬÈϵÄpackage£¬Ò»°ã²»ÓÃĬÈÏpackage¡£
2.JavaµÄȨÏÞ
package accessȨÏÞ
JavaµÄȨÏÞÓÐ public, protected, package access, private¡£±È½ÏÄ°ÉúµÄÊÇpackage access£¬µ±Àà»òÕßÀà³ÉԱûÓмÓÈκÎȨÏÞÏÞ¶¨·ûʱ£¬Õâ¸öÀà»òÕßÀà³ÉÔ±µÄȨÏÞ¾ÍÊÇpackage access¡£Ò²¾ÍÊÇ˵ֻÓÐÔÚͬһ¸öpackageÖпÉÒÔ·ÃÎÊ£¬ÔÚ²»Í¬packageÖÐÊÇÎÞ·¨·ÃÎʵġ£
ÀýÈçÔ
Ïà¹ØÎĵµ£º
StringºÍStringBufferµÄÇø±ð£¬ÍøÉÏ×ÊÁÏ¿ÉÒÔ˵ÊÇÊý²»Ê¤Êý£¬µ«ÊÇ¿´µ½ÕâƪÎÄÕ£¬¸Ð¾õÀïÃæ×öµÄСÀý×ÓºÜÓдú±íÐÔ£¬ËùÒÔתһÏ£¬²¢×Ô¼º×öÁËÒ»µã×ܽᡣ
ÔÚjavaÖÐÓÐ3¸öÀàÀ´¸ºÔð×Ö·ûµÄ²Ù×÷¡£
1.Character ÊǽøÐе¥¸ö×Ö·û²Ù×÷µÄ£¬
2.String ¶ÔÒ»´®×Ö·û½øÐвÙ×÷¡£²»¿É±äÀà¡£
3.StringBuffer Ò²ÊǶÔÒ»´®×Ö·û½øÐвÙ×÷£¬µ«ÊÇ¿É ......
ö¾ÙÀàÐÍÊÇJDK5.0µÄÐÂÌØÕ÷¡£SunÒý½øÁËÒ»¸öȫеĹؼü×ÖenumÀ´¶¨ÒåÒ»¸öö¾ÙÀà¡£ÏÂÃæ¾ÍÊÇÒ»¸öµäÐÍö¾ÙÀàÐ͵Ķ¨Ò壺
Java´úÂë
public enum Color{
RED,BLUE,BLACK,YELLOW,GREEN
}
public enum Color{
RED,BLUE,BLACK,YELLOW,GREEN
}
ÏÔ ......
±ÈÈçappletÎļþÊÇAppletTest.class
1£©
ÔÚAppletTest.javaµÄ´úÂëÖÐ
ʹÓÃĬÈÏ°ü£¬¼´²»ÓÃpackageÓï¾ä
ÔÚhtmlÒ³ÖеĴúÂëÊÇ
<applet code="AppletTest.class" width="400" height="300">
</applet>
AppletTest.classÎļþºÍhtmlÒ³·ÅÔÚÒ»¸öÎļþ¼ÐÖÐ
2)
ÔÚAppletTest.javaµÄ´úÂëÖÐ
package xx.yy;
ÔÚhtmlÒ³ ......
JavaÖеÄÊÂÎñ´¦Àí
¡¡¡¡Ò»°ãÇé¿öÏ£¬J2EEÓ¦Ó÷þÎñÆ÷Ö§³ÖJDBCÊÂÎñ¡¢JTA£¨Java Transaction API£©ÊÂÎñ¡¢ÈÝÆ÷¹ÜÀíÊÂÎñ¡£Ò»°ãÇé¿öÏ£¬×îºÃ²»ÒªÔÚ³ÌÐòÖÐͬʱʹÓÃÉÏÊöÈýÖÖÊÂÎñÀàÐÍ£¬±ÈÈçÔÚJTAÊÂÎñÖÐǶÌ×JDBCÊÂÎñ¡£µÚ¶þ·½Ã棬ÊÂÎñÒªÔÚ¾¡¿ÉÄ̵ܶÄʱ¼äÄÚÍê³É£¬²»ÒªÔÚ²»Í¬·½·¨ÖÐʵÏÖÊÂÎñµÄʹÓá£ÏÂÃæÎÒÃÇÁоÙÁ½ÖÖÊÂÎñ´¦Àí·½Ê½¡£
¡¡¡¡ ......
WindowsÏÂJAVAÓõ½µÄ»·¾³±äÁ¿Ö÷ÒªÓÐ3¸ö£¬JAVA_HOME¡¢CLASSPATH¡¢PATH¡£ÏÂÃæÖð¸ö·ÖÎö¡£ JAVA_HOMEÖ¸ÏòµÄÊÇJDKµÄ°²×°Â·¾¶£¬Èçx:\JDK_1.4.2£¬ÔÚÕâ·¾¶ÏÂÄãÓ¦¸ÃÄܹ»ÕÒµ½bin¡¢libµÈĿ¼¡£ÖµµÃÒ»ÌáµÄÊÇ£¬JDKµÄ°²×°Â·¾¶¿ÉÒÔÑ¡ÔñÈÎÒâ´ÅÅÌĿ¼£¬²»¹ý½¨ÒéÄã·ÅµÄĿ¼²ã´Îdzһµã£¬Èç¹ûÄã·ÅµÄĿ¼ºÜÉ±ÈÈçx:\XXXXXX\xxxxx\XXXX\xxxx\X ......