易截截图软件、单文件、免安装、纯绿色、仅160KB

Java URLClassLoader

Closing a URLClassLoader
By Michael McMahon
 
Complex Java programs, such as application servers, sometimes create their own class loaders using the URLClassLoader type. With URLClassLoader, applications can load classes and resources from a search path of URLs. The following URL types are supported:
file: (loads from file-system directories)
jar: (loads from JAR files)
http: (loads from http servers)
 
 
A frequent problem has been how to support updated implementations of the classes and resources loaded from a particular codebase, and in particular from JAR files. In principle, once the application clears all references to a loader object, the garbage collector and finalization mechanisms will eventually ensure that all resources (such as the JarFile objects) are released and closed.
 
The application can then replace the JAR file, and create a new URLClassLoader instance to load from the same location, but this time using the new implementation of the classes/resources.
 
However, since it can't be predicted exactly when finalization and garbage collection will occur, this causes problems for applications which need to be able to do this in a predictable and timely fashion. It is a particular problem on Windows, because open files cannot be deleted or replaced.
 
To alleviate this problem, URLClassLoader has acquired a new method called close(). It has been implemented since Build 48 of JDK7.
 
The close() method effectively invalidates the loader, so that no new classes can be loaded from it. It also closes any JAR files that were opened by the loader. This allows the application to delete or replace these files and, if necessary, create new loaders using new implementations.
 
The new method follows the familiar "Closeable" pattern, and URLClassLoader now implements the Closeable interface, which defines URLClassLoader.close(). The following sample code shows how one might use the method.
 
&n


相关文档:

java连接Oracle

    花了两天时间,终于把access数据库里的数据换到Oracle了。当然这其中要感谢同学和博友的热心帮助拉。现将今天的收获整理下。
    我用的是Oracle 10 express edition版本,这个版本建数据库挺麻烦的,所以我就直接在它自带的数据库XE下建表了。
    注意:建表可一定要 ......

Java序列化的机制和原理(讲的很详细也很易懂)


本文讲解了Java序列化的机制和原理。从文中你可以了解如何序列化一个对象,什么时候需要序列化以及Java序列化的算法。
 
00 00 00 0B: 11, containVersion的值.
 
0x70:TC_NULL,没有超类了。
 
0x49: 域类型. 49 代表"I", 也就是Int..
00 0E: 域名字长� ......

你必须知道的11个Java第三方类库

http://apache.freelamp.com/hadoop/hive/hive-0.4.0/
http://sourceforge.net/projects/dbunit/files/
Java第三方library ecosystem是一个很广阔的范畴。不久前有人撰文:每个项目中,你必须知道的11个Java第三方类库。
单元测试
1.DBUnit
DBunit是一个基于junit扩展的数据库测试框架。它提供了大量的类对与数据库相� ......

将Java对象保存为XML文档

package com.kiloway.trace.utils;
import java.lang.reflect.Field;
/**
* @author Zhang Qi
* @Create Time 2010/01/09
* */
public class ObjectToXML {
public String toString(Object object) throws Exception {
StringBuilder sb = new StringBuilder();
//得到类的名称
String classname = obj ......

Java中JNDI的配置

方案一步骤:
1、配置Tomcat\conf\context.xml添加 <Resource>
 <Resource name="jdbc/books" auth="Container"
  type="javax.sql.DataSource" maxActive="100" maxIdle="30"
  maxWait="10000" username="sa" password=""
  driverClassName="com.microsoft.jdbc.sqlse ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号