²»µÃ²»¿´µÄ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
Ïà¹ØÎĵµ£º
1.¼ÆËãijһÔ·ݵÄ×î´óÌìÊý
1Calendar time=Calendar.getInstance();
2time.clear();
3time.set(Calendar.YEAR,year); //year Ϊ int
4time.set(Calendar.MONTH,i-1);//×¢Òâ,Calendar¶ÔÏóĬÈÏÒ»ÔÂΪ0
5int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);//±¾Ô·ݵÄÌìÊý
×¢£ºÔÚʹÓÃset·½·¨Ö®Ç°£¬±ØÐë ......
Ò»£® InputºÍOutput
1. stream´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputºÍOut stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
1.1 ÒÔ×Ö½ÚΪµ¼ÏòµÄstream
ÒÔ×Ö½ÚΪµ¼ÏòµÄstream£¬±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈëÐÅÏ¢¡£ÒÔ×Ö½ÚΪµ¼ÏòµÄstream°üÀ¨ÏÂÃæ¼¸Ö ......
Èç¹ûÄãÊÇÒ»ÃûJava³ÌÐòÔ±£¬²¢ÇÒ¹Ø×¢Õâ±à³ÌÓïÑÔ·½ÃæµÄ·¢Õ¹£¬±ÈÈç¾³£È¥TIOBEÍøÕ¾Á˽â±à³ÌÓïÑÔÁ÷ÐжÈÅÅÐУ¬ÄÇôÄãÓ¦¸ÃÌý˵¹ýScala£¬Èç¹ûÄ㻹ûÓпªÊ¼Ñ§Ï°Scala£¬»òÕß´òËãϸöÀñ°Ý¿ªÊ¼Ñ§µÄ»°£¬ÇëÏÈ¿´¿´ÏÂÃæÕâƪÎÄÕ£¬¿´¿´Äܲ»ÄܸıäÄãµÄÏë·¨¡£
ScalaÊÇΪÄã×¼±¸µÄÂð?Äã±ØÐë×Ô¼º¿´Ã÷°×²¢×ö¾ö¶¨¡£³ýÁËÉìÕ¹ÐÔÖ®Í⣬ÎÒÃÇ·¢ÏÖϲ»¶ÓÃS ......
Properties props=System.getProperties(); //ϵͳÊôÐÔ
System.out.println("JavaµÄÔËÐл·¾³°æ±¾£º"+props.getProperty("java.version"));
System.out.println("JavaµÄÔËÐл·¾³¹©Ó¦ÉÌ£º"+props.getProperty("java.vendor"));
System.out ......
Java¼ò½é
¡¡¡¡JavaÊÇÓÉSun Microsystems¹«Ë¾ÓÚ1995Äê5ÔÂÍƳöµÄJava³ÌÐòÉè¼ÆÓïÑÔ£¨ÒÔϼò³ÆJavaÓïÑÔ£©ºÍJavaƽ̨µÄ×ܳơ£ÓÃJavaʵÏÖµÄHotJavaä¯ÀÀÆ÷£¨Ö§³ÖJava applet£©ÏÔʾÁËJavaµÄ÷ÈÁ¦£º¿çƽ̨¡¢¶¯Ì¬µÄWeb¡¢Internet¼ÆËã¡£´Ó´Ë£¬Java±»¹ã·º½ÓÊܲ¢Íƶ¯ÁËWebµÄѸËÙ·¢Õ¹£¬³£ÓõÄä¯ÀÀÆ÷ÏÖÔÚ¾ùÖ§³ÖJava applet¡£ÁíÒ»·½Ã棬Java ......