javaÔËÐл·¾³ Àà×°ÔØÆ÷ClassLoader
½ñÌì¹Û¿´ÁËÀ¶É½ÀÏʦjava±³ºóµÄÃØÃÜÏà¹ØÊÓƵ£¬·¢ÏÖÒªÏëд³ö¸ßÐÔÄܵijÌÐò£¬Ò»¶¨Òª¶ÔÆäÔËÐÐÔÀíÒÔ¼°ÆäÔËÐл·¾³ÓÐÏ൱³Ì¶ÈµÄÁ˽⡣ÄÇClassLoaderÊÇÏ൱¹Ø¼üµÄÒ»¸ö²¿·Ö¡£
ÏÈ˵ÏÂjava³ÌÐòÔËÐеĻù±¾Á÷³Ì£¬ÏȽ«javaÎļþ±àÒëΪclassÎļþ£¬È»ºóͨ¹ýClassLoader£¨Àà¼ÓÔØÆ÷£©£¬¼ÓÔص½Runtime Data Area£¨ÀàËÆÓÚÄڴ棩ÖУ¬ÔÙ½»ÓëExecution Engine£¨Ï൱ÓÚCPU£©½øÐÐÖ´ÐвÙ×÷£¬ÈôjavaÓïÑÔÓе÷ÓÃÆäËûµÄÓïÑÔ½øÐÐÏà¹Ø¼ÆË㣬ÔòÐèÒªÓõ½Native interfaceÕâ¸ö²¿·Ö£¬×îÖÕÐγÉNative Libraries£¬ÖÁ´Ë£¬Ö´ÐÐÍê³É¡£
ÄÇ¿´ÁËÉÏÃæµÄÁ÷³Ì£¬ClassLoaderÊÇÒ»¸öClassÎļþµÄÔØÈëÆ÷£¬ÆäÔØÈëµÄ·½Ê½ÓÐÔ¤ÏÈÔØÈëºÍ°´ÐèÔØÈëÁ½ÖÖ·½Ê½¡£Ô¤ÏÈÔØÈëÖ÷ÒªÊÇÔØÈëһЩ¾ßÌåµÄjavaϵͳÎļþ£¬¸÷¸öjavaÔËÐбØÐèµÄÀàÎļþ£»°´ÐèÔØÈëÖ÷ÒªÊÇÎÒÃÇ×Ô¼ºËù±àдµÄ¾ßÌåµÄjavaµÄÀàÎļþ¡£Ô¤ÏÈÔØÈëºÍ°´ÐèÔØÈë¿É¹ËÃû˼Ò壬ԤÏÈÔØÈëÊÇÔÚÖ´ÐÐû¸ö³ÌÐòÇ°¶¼ÐèÒª½øÐÐÔØÈ룬°´ÐèÔØÈëÊÇÖ»ÓÐÔÚµ÷ÓþßÌåµÄÀàÎļþʱ²Å½øÐÐÔØÈë¡£ÎÒÃÇ¿ÉÒÔͨ¹ý¸ÃÃüÁîÀ´×·×Ùjava³ÌÐòÖ´ÐÐʱ£¬ËùÔØÈëµÄ¾ßÌåµÄclassÎļþ---java -verbose:class Main(±àÒëºÃµÄÎļþÃû)¡£
°´ÐèÔØÈëÓÖ·ÖΪÁ½ÖÖ·½Ê½£¬ÎªÏÔʽºÍÒþʽ.ÒþʽÊÇÎÒÃDZȽϳ£ÓõÄ,¾ßÌåµÄÐÎʽ²»Ê¹ÓÃnew()¹Ø¼ü×Ö,¶øÏÔʽµÄ·½·¨Ö÷ÒªÊÇÏÂÃæÁ½ÖÖ·½Ê½,Ò»¸öÊÇClass.forName()ºÍClassLoader.LoadClass()·½·¨.Class.forNameÔÚ×öÓëÊý¾Ý¿âµÄÁ¬½ÓʱÓùý,²»¹ýÒÔÇ°²»Á˽âÆ京Òâ.ÕâÁ½ÖÖ·½·¨ÎÒÄ¿Ç°¸Ð¾õÒþʽµÄÓÃÆðÀ´¸ü·½±ã,µ«ºöÂÔÁ˾ßÌåµÄÔØÈë¹ý³Ì£»ÏÔʽµÄÔØÈëÓÃÆðÀ´¸´ÔÓ£¬µ«¶Ô³ÌÐò¾ßÌåµÄÖ´ÐÐÁ÷³Ì£¬ÎÒÃÇ¿ÉÒÔ½øÐÐÏêϸµÄ¿ØÖÆ¡£
¾ßÌåÔõôÓÃÕâ¸ö»¹Ã»Ì«¸ãÃ÷°×£¬»¹ÐèÔÙÑо¿ÏÂ.Ã÷Ìì»á°ÑclassLoaderÄÚ²¿µÄ¾ßÌå¹¹ÔìÔÙÑо¿Ï¡£
ÏÂÃæÊÇ×öÕâ¸öÁ·Ï°Ê±µÄ¾ßÌåÄÚÈÝ£º
//MyClassLoader
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
public class MyClassLoader extends URLClassLoader{
private static File file = new File("F:\\java\20100108 ");
public MyClassLoader(){
super(getUrl());
}
public static URL[] getUrl(){
try{
return new URL[]{file.toURL()};
}catch(MalformedURLException e){
return new URL[0];
}
}
}
//A.java
import java.lang.reflect.*;
public class A {
public static void main(String[] args){
try{
Ïà¹ØÎĵµ£º
1.¼¯ºÏµÄÌص㣺
¶¼Î»ÓÚ java.util°üÖУ¬²»ÄÜ´æ·Å»ù±¾ÀàÐ͵ÄÊý¾Ý£¬¶øÖ»ÄÜ´æ·Å¶ÔÏóµÄÒýÓ㬲Ù×÷µÄÊýÄ¿¿ÉÒÔ²»¹Ì¶¨£¨ÀàËÆÓÚ¶¯Ì¬Êý×飩¡£
2.·ÖÀࣺ
ÓÐÈý¸öÀࣺ
a.Set(¼¯)£º¶ÔÏó²»°´Ìض¨·½Ê½ÅÅÐò£¬Ã»ÓÐÖظ´ÔªËØ¡£Õâ¸öÓëÊýѧÖеļ¯ºÏ¸ÅÄî×îÏàËÆ¡£
b.List(Áбí)£º°´ÕÕË÷ÒýλÖÃÅÅÐò£¬¿ÉÒÔÓÐÖظ´ÔªËØ£¬ÔÊÐí°´ÕÕ¶ÔÏóÔÚ¼¯ºÏÖеÄË ......
¹ØÓÚJavaµÄ»ù´¡ÖªÊ¶£¬Êµ¼ùÖ¤Ã÷ѧϰOO£¬×îÖÕÁìÎò“¸¸Àà¿ØÖÆÁ÷³Ì£¬×ÓÀàʵÏÖ¾ßÌåµÄÒµÎñÂß¼”µÄOO˼Ï룬ÐèÒªµÄ²»ÊÇÖÇÉ̶øÊÇ»ù´¡£¬Ò²¾ÍÊÇ˵£¬»ù´¡Ô½ºÃÔ½¿ìÁìÎò£¬ËùÒÔÇëÿλS1ѧϰJavaµÄѧԱÇëÀμÇÒÔÏÂJavaÁìÓòµÄ»ù´¡ÖªÊ¶£¬×îºó×£¸÷λѧԱÔÚ¿ª·¢ÏîÄ¿Ç°¿ÉÒÔÁìÎòOOµÄÕæÚУ¬ÀÏʦҲ»á½ß¾¡È«Á¦ÖúÄãÃÇ´òͨÕâµÀͨÏòJavaµÄ¼«ËÙ ......
Java ʵÓþÑé×ܽá --Swing ƪ
Ç°ÑÔ
±¾ÎÄÇ°ÑÔ²¿·ÖΪÎÒµÄһЩ¸ÐÏ룬Èç¹ûÄãÖ»¶Ô±¾ÎĽéÉÜµÄ Java ʵÓü¼ÇɸÐÐËȤ£¬¿ÉÒÔÌø¹ýÇ°ÑÔÖ±½Ó¿´ÕýÎĵÄÄÚÈÝ¡£
±¾ÎĵÄд×÷¶¯»úÀ´Ô´ÓÚ×î½ü½Ó¸øÈ˼ҰïæдµÄÒ»¸öС³ÌÐò£¬Ö÷ÒªÓÃÓÚ¹ÜÀí·ÖÆÚ¸¶¿îµÄ»õ¿îµÄһϵÁйÜÀí£¬°üÀ¨¹ýÆÚ¿îµÄ¼Í¼£¬¹ýÆÚ¿îÀûÏ¢µÄ¼ÆË㣬ΪÌáÇ°¸¶¿îµÄÓû§ÌṩһЩ·µ¿î½ ......
/**
* ´´½¨ËõÂÔͼƬ
*
* @param orgpath
* @param filename
* @return
* @description: ÃèÊö
*/
//´Ë·½·¨¶ÔÓÚsshÏîÄ¿²¢ÇÒÕë¶Ô ÉÏ´«¹¦ÄÜʱ£¬·Ç³£ÓÐÓÃ
public static Boolean createAbbreviateImg(String orgpath, String filename) {
Boolea ......
package test;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
public class XmlTest {
public static void main(String[] args) {
File xmlFile=new File("test/xml.xml");
DocumentBuilderFactory documentBuilderFactor ......