Java SE6µ÷ÓÃJava±àÒëÆ÷µÄÁ½ÖÖз½·¨
ÔںܶàJavaÓ¦ÓÃÖÐÐèÒªÔÚ³ÌÐòÖе÷ÓÃJava±àÒëÆ÷À´±àÒëºÍÔËÐС£µ«ÔÚÔçÆڵİ汾ÖУ¨Java SE5¼°ÒÔÇ°°æ±¾£©ÖÐÖ»ÄÜͨ¹ýtools.jarÖеÄcom.sun.tools.javac°üÀ´µ÷ÓÃJava±àÒëÆ÷£¬µ«ÓÉÓÚtools.jar²»ÊDZê×¼µÄJava¿â£¬ÔÚʹÓÃʱ±ØÐëÒªÉèÖÃÕâ¸öjarµÄ·¾¶¡£¶øÔÚJava SE6ÖÐΪÎÒÃÇÌṩÁ˱ê×¼µÄ°üÀ´²Ù×÷Java±àÒëÆ÷£¬Õâ¾ÍÊÇjavax.tools°ü¡£Ê¹ÓÃÕâ¸ö°ü£¬ÎÒÃÇ¿ÉÒÔ²»Óý«jarÎļþ·¾¶Ìí¼Óµ½classpathÖÐÁË¡£
¡¡¡¡Ò»¡¢Ê¹ÓÃJavaCompiler½Ó¿ÚÀ´±àÒëJavaÔ´³ÌÐò
¡¡¡¡Ê¹ÓÃJava APIÀ´±àÒëJavaÔ´³ÌÐòÓкܶ෽·¨£¬ÏÖÔÚÈÃÎÒÃÇÀ´¿´Ò»ÖÖ×î¼òµ¥µÄ·½·¨£¬Í¨¹ýJavaCompiler½øÐбàÒë¡£
¡¡¡¡ÎÒÃÇ¿ÉÒÔͨ¹ýToolProviderÀàµÄ¾²Ì¬·½·¨getSystemJavaCompilerÀ´µÃµ½Ò»¸öJavaCompiler½Ó¿ÚµÄʵÀý¡£
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
¡¡¡¡JavaCompilerÖÐ×îºËÐĵķ½·¨ÊÇrun¡£Í¨¹ýÕâ¸ö·½·¨¿ÉÒÔ±àÒëjavaÔ´³ÌÐò¡£Õâ¸ö·½·¨ÓÐ3¸ö¹Ì¶¨²ÎÊýºÍ1¸ö¿É±ä²ÎÊý£¨¿É±ä²ÎÊýÊÇ´ÓJave SE5¿ªÊ¼ÌṩµÄÒ»¸öеIJÎÊýÀàÐÍ£¬ÓÃtype… argu±íʾ£©¡£Ç°3¸ö²ÎÊý·Ö±ðÓÃÀ´Îªjava±àÒëÆ÷Ìṩ²ÎÊý¡¢µÃµ½Java±àÒëÆ÷µÄÊä³öÐÅÏ¢ÒÔ¼°½ÓÊÕ±àÒëÆ÷µÄ´íÎóÐÅÏ¢£¬ºóÃæµÄ¿É±ä²ÎÊý¿ÉÒÔ´«ÈëÒ»¸ö»ò¶à¸öJavaÔ´³ÌÐòÎļþ¡£Èç¹ûrun±àÒë³É¹¦£¬·µ»Ø0¡£
int run(InputStream in, OutputStream out, OutputStream err, String... arguments)
¡¡¡¡Èç¹ûÇ°3¸ö²ÎÊý´«ÈëµÄÊÇnull£¬ÄÇôrun·½·¨½«ÒÔ±ê×¼µÄÊäÈë¡¢Êä³ö´úÌ棬¼´System.in¡¢System.outºÍSystem.err¡£Èç¹ûÎÒÃÇÒª±àÒëÒ»¸ötest.javaÎļþ£¬²¢½«Ê¹Óñê×¼ÊäÈëÊä³ö£¬runµÄʹÓ÷½·¨ÈçÏ£º
int results = tool.run(null, null, null, "test.java");
¡¡¡¡ÏÂÃæÊÇʹÓÃJavaCompilerµÄÍêÕû´úÂ룺
import java.io.*;
import javax.tools.*;
public class test_compilerapi
{
¡¡public static void main(String args[]) throws IOException
¡¡{
¡¡¡¡JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
¡¡¡¡int results = compiler.run(null, null, null, "test.java");
¡¡¡¡System.out.println((results == 0)?"±àÒë³É¹¦":"±àÒëʧ°Ü");
¡¡¡¡// ÔÚ³ÌÐòÖÐÔËÐÐtest
¡¡¡¡Runtime run = Runtime.getRuntime();
¡¡¡¡Process p = run.exec("java test");
¡¡¡¡BufferedInputStream in = new BufferedInputStream(p.getInputStream());
¡¡¡¡BufferedReader br = new BufferedReader(new InputStreamReader(in));
¡¡¡¡String s;
¡¡¡¡while ((s = br.readLi
Ïà¹ØÎĵµ£º
ÎÒÔÚѧϰthinking in Java4 µÄʱºò£¬ÔÚ´´½¨×Ô¶¨Òå°üµÄʱºò£¬Åöµ½Á˺ܶà´íÎó£¬ÈÃÎÒÓôÃÆÁ˼¸Ì죬ͨ¹ýÔÚÍøÉϵÄ×ÊÁÏËÑË÷£¬°Ñ°üµÄ´´½¨¹ý³Ì¸ø´ó¼ÒÏêϸÁгöÀ´¡£
ÎÒÃÇÒÔthinking in Java4ÖеÄÀý×ÓΪÀý
´´½¨Á½¸öÀàVectorºÍList¡£½«±àÒëºóµÄVector.classºÍList.classÎļþ·ÅÔÚ°ünet.mindview.simpleÏÂ(¸Ã°üλÓÚc:\DOC\JavaT).
//Vec ......
ΪÁËʵÏÖÁ½¸öÊý×Ö½øÐн»»»£¬ÎÒÃÇͨ³£¿ÉÒÔÀûÓÃλÔËËãÀ´ÊµÏÖ
C++³ÌÐò swap(int a ,int b){a^=b^=a^=b;}
JAVA³ÌÐò swap(int a, int b){ a^=b;b^=a;a^=b; }»òÕß{ b^=(a^=b) ; a^=b;}
Èç¹ûJAVAÓÃC++µÄʵÏÖ·½Ê½Ôò»áµÃµ½ bµÃµ½ÁËaµÄÖµ£¬µ«ÊÇaÏÖÔÚµÄֵȴ² ......
ʹÓÃJava³ÌÐò´ÓÊý¾Ý¿âÖвéѯ´óÁ¿µÄÊý¾ÝʱÈÝÒ׳öÏÖÒì³£:
java.lang.OutOfMemoryError: Java heap space
ÔÚJVMÖÐÈç¹û98£¥µÄʱ¼äÊÇÓÃÓÚGCÇÒ¿ÉÓÃµÄ Heap size ²»×ã2£¥µÄʱºò½«Å׳ö´ËÒì³£ÐÅÏ¢¡£
»¹ÓÐʹÓÃjxl¶ÁдexcelÎļþʱ£¬Í¬Ê±¶ÁÈëËùÓмǼ£¬Ò²ÈÝÒ׳öÏÖÕâ¸öÎÊÌâ¡£
JVM¶ÑµÄÉèÖÃÊÇÖ¸java³ÌÐòÔËÐйý³ÌÖÐJVM¿ÉÒÔµ÷ÅäʹÓõÄÄÚ ......
´Ó×î³£¹æµÄ·Ö²ã½á¹¹À´Ëµ£¬ÏµÍ³²ã´Î´ÓÉϵ½ÏÂÒÀ´ÎΪ£º
±íÏֲ㣺Ö÷ÒªÊÇ¿Í»§¶ËµÄչʾ¡£
·þÎñ²ã£ºÖ±½ÓΪ¿Í»§¶ËÌṩµÄ·þÎñ»ò¹¦ÄÜ¡£Ò²ÊÇϵͳËùÄܶÔÍâÌṩµÄ¹¦ÄÜ¡£
ÁìÓò²ã£ºÏµÍ³ÄÚµÄÁìÓò»î¶¯¡£
DAO²ã£ºÊý¾Ý·ÃÎʶÔÏó£¬Í¨¹ýÁìÓòʵÌå¶ÔÏóÀ´²Ù×÷Êý¾Ý¿â¡£
ÆäÖÐÓÐЩָµ¼ÔÔò£º
& ......