²»µÃ²»¿´µÄ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
Ïà¹ØÎĵµ£º
http://edu.itfuture.org/index.jsp ³ÌÐòÔ±Ö®¼Ò
www.8isp.com
www.wang48.com
www.topsage.com ´ó¼ÒÍø
www.cnsd.com
http://www.jpeixun.com / ʱ´ú¿¥êÉ
http://bbs.langsin.com/forum-9-3.html ÀËêØÍø
www.123w.net
w ......
Properties props=System.getProperties(); //ϵͳÊôÐÔ
System.out.println("JavaµÄÔËÐл·¾³°æ±¾£º"+props.getProperty("java.version"));
System.out.println("JavaµÄÔËÐл·¾³¹©Ó¦ÉÌ£º"+props.getProperty("java.vendor"));
System.out ......
¡¡JavaÓïÑÔµÄÊäÈëÊä³ö¹¦ÄÜÊÇÊ®·ÖÇ¿´ó¶øÁé»îµÄ£¬ÃÀÖв»×ãµÄÊÇ¿´ÉÏÈ¥ÊäÈëÊä³öµÄ´úÂë²¢²»ÊǺܼò½à£¬ÒòΪÄãÍùÍùÐèÒª°ü×°Ðí¶à²»Í¬µÄ¶ÔÏó¡£ÔÚJavaÀà¿âÖУ¬IO²¿·ÖµÄÄÚÈÝÊǺÜÅÓ´óµÄ£¬ÒòΪËüÉæ¼°µÄÁìÓòºÜ¹ã·º:±ê×¼ÊäÈëÊä³ö£¬ÎļþµÄ²Ù×÷£¬ÍøÂçÉϵÄÊý¾ÝÁ÷£¬×Ö·û´®Á÷£¬¶ÔÏóÁ÷£¬zipÎļþÁ÷....±¾ÎĵÄÄ¿µÄÊÇΪ´ó¼Ò×öÒ»¸ö¼òÒªµÄ½éÉÜ¡£
¡¡¡ ......
SpringÄÜÓÐЧµØ×éÖ¯J2EEÓ¦Óø÷²ãµÄ¶ÔÏó¡£²»¹ÜÊÇ¿ØÖƲãµÄAction¶ÔÏ󣬻¹ÊÇÒµÎñ²ãµÄService¶ÔÏ󣬻¹Êdz־òãµÄDAO¶ÔÏ󣬶¼¿ÉÔÚSpringµÄ¹ÜÀíÏÂÓлúµØÐµ÷¡¢ÔËÐС£Spring½«¸÷²ãµÄ¶ÔÏóÒÔËÉñîºÏµÄ·½Ê½×éÖ¯ÔÚÒ»Æð£¬Action¶ÔÏóÎÞÐë¹ØÐÄService¶ÔÏóµÄ¾ßÌåʵÏÖ£¬Service¶ÔÏóÎÞÐë¹ØÐij־òã¶ÔÏóµÄ¾ßÌåʵÏÖ£¬¸÷²ã¶ÔÏóµÄµ÷ÓÃÍêÈ«ÃæÏò½Ó ......
´ó¼Ò¶¼ËµjavaʹÓõÄ×Ö·û¼¯ÊÇunicode£¬ÄÇôĬÈϱàÂë²»¾ÍÊÇÓ¦¸ÃÊÇUTF8,UTF16Ö®ÀàµÄunicode±àÂëÂð£¿
¿ÉÊǵ÷ÓÃCharset.defaultCharset()µÄ½á¹û²¢·ÇÈç´Ë¡£
import java.nio.charset.Charset;
public class javaCode {
public static void main(String args[])
{
String defaultCharsetName=Charset.defaultChars ......