²»µÃ²»¿´µÄJava¼¼ÇÉ:SE6µ÷ÓñàÒëÆ÷µÄ·½·¨
Ôںܶà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.readLine()) != null)
S
Ïà¹ØÎĵµ£º
ÈçºÎ»ñÈ¡LCDSÇëÇó¹ý³ÌÖÐJAVAÅ׳öÀ´µÄExceptionÄØ£¿ µ±flexͨ¹ýÇëÇó¶ÔÏóÇëÇó·þÎñ¶ËµÄʱºò£¬ÇëÇó³É¹¦»á·¢mx.rpc.events.ResultEventʼþ£¬Óöµ½·þÎñ¶ËÒì³£»òÆäËû·Ç200µÄHTTP״̬Â루ÀýÈç404£¬403£©Ôò»á·¢mx.rpc.events.FaultEventʼþ£¬µ«ÇëÇóʧ°ÜÊÇÒòΪʲôÔÒòÄØ£¿ÒòΪ²»Í¬µÄÔÒò¿ÉÄܵ¼Ö½çÃæÉϲ»Í ......
Ò»£® InputºÍOutput
1. stream´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputºÍOut stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
1.1 ÒÔ×Ö½ÚΪµ¼ÏòµÄstream
ÒÔ×Ö½ÚΪµ¼ÏòµÄstream£¬±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈëÐÅÏ¢¡£ÒÔ×Ö½ÚΪµ¼ÏòµÄstream°üÀ¨ÏÂÃæ¼¸Ö ......
2009-08-19
תÔØ £º http://yahaitt.javaeye.com/blog/453032
java Adapterģʽ
¹Ø¼ü×Ö: android adapter
ͨ³££¬¿Í»§Àࣨclients of class£©Í¨¹ýÀàµÄ½Ó¿Ú·ÃÎÊËüÌṩµÄ·þÎñ¡£ÓÐʱ£¬ÏÖÓеÄÀࣨexisting class£©¿ÉÒÔÌṩ¿Í»§ÀàµÄ¹¦ÄÜÐèÒª£¬µ«ÊÇËüËùÌṩµÄ½Ó¿Ú²»Ò»¶¨ÊÇ¿Í»§ÀàËùÆÚÍûµÄ¡£ÕâÊÇÓÉÓÚÏÖÓеĽӿÚÌ«Ïêϸ»òÕßȱ·¦ ......
¡¡¡¡ËäÈ»JavaScriptÓëJavaÓнôÃܵÄÁªÏµ£¬µ«È´ÊÇÁ½¸ö¹«Ë¾¿ª·¢µÄ²»Í¬µÄÁ½¸ö²úÆ·¡£JavaÊÇSUN¹«Ë¾ÍƳöµÄÐÂÒ»´úÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÓïÑÔ£¬ÌرðÊʺÏÓÚInternetÓ¦ÓóÌÐò¿ª·¢£»¶øJavaScriptÊÇNetscape¹«Ë¾µÄ²úÆ·£¬ÆäÄ¿µÄÊÇΪÁËÀ©Õ¹Netscape Navigator¹¦ÄÜ,¶ø¿ª·¢µÄÒ»ÖÖ¿ÉÒÔǶÈëWebÒ³ÃæÖеĻùÓÚ¶ÔÏóºÍʼþÇý¶¯µÄ½âÊÍÐÔÓïÑÔ, ËüµÄÇ°ÉíÊ ......
SpringÄÜÓÐЧµØ×éÖ¯J2EEÓ¦Óø÷²ãµÄ¶ÔÏó¡£²»¹ÜÊÇ¿ØÖƲãµÄAction¶ÔÏ󣬻¹ÊÇÒµÎñ²ãµÄService¶ÔÏ󣬻¹Êdz־òãµÄDAO¶ÔÏ󣬶¼¿ÉÔÚSpringµÄ¹ÜÀíÏÂÓлúµØе÷¡¢ÔËÐС£Spring½«¸÷²ãµÄ¶ÔÏóÒÔËÉñîºÏµÄ·½Ê½×éÖ¯ÔÚÒ»Æð£¬Action¶ÔÏóÎÞÐë¹ØÐÄService¶ÔÏóµÄ¾ßÌåʵÏÖ£¬Service¶ÔÏóÎÞÐë¹ØÐij־òã¶ÔÏóµÄ¾ßÌåʵÏÖ£¬¸÷²ã¶ÔÏóµÄµ÷ÓÃÍêÈ«ÃæÏò½Ó ......