JavaɳÏäµÄʵÏÖ
JavaɳÏäʵÏÖÊÇÖØдÀà¼ÓÔØÆ÷ºÍ°²È«¹ÜÀíÆ÷,ͨ¹ýÉèÖõÄÈ«¾Ö°²È«¹ÜÀíÆ÷À´¿ØÖÆÖ´ÐгÌÐòµÄȨÏÞ
˵Ã÷: °²È«²ßÂÔÖ»¶Ô°²×°°²È«¹ÜÀíÆ÷Ö®ºóµÄÀàÉúЧ,֮ǰµÄÀ಻Ôٴ˹ÜÀí·¶Î§Ö®ÄÚ,ÀûÓÃÕâÒ»µã¿ÉÒÔÔ¤ÏÈÉèÖÃÎÒÃÇÐèÒªµÄ²Ù×÷,¶ø¶Ôij¸öµãÖ®ºóµÄËùÓзǷ¨²Ù×÷½øÐÐȨÏÞÉèÖÃ.
Àà¼ÓÔØÆ÷ÖØд
/**
* [ÖØдµÄÀà¼ÓÔØÆ÷]
* ɳÏä³ÌÐòÀà¼ÓÔØÆ÷,¿É¸ù¾ÝÖ¸¶¨Â·¾¶¼ÓÔØÖƶ¨ÀàclassÎļþ.
*
* [˵Ã÷]
* ½ö°üÄڿɼû
*
* @author Áõ½ðöÎ
* @version 1.0
* */
package org.hljoj.core.judge.sandbox;
import java.io.File;
import java.io.FileInputStream;
import org.hljoj.core.judge.util.ConstantParam;
class SandboxClassLoader extends ClassLoader{
/**ĬÈÏclassPath*/
private String _classPath;
/**
* ¹¹Ô캯Êý
* @param classPath Àà¼ÓÔØÆ÷ĬÈÏclassPath
* */
public SandboxClassLoader(String classPath) {
this._classPath = classPath;
}
@Override
protected Class<?> findClass(String className) throws ClassNotFoundException {
return loadClass(_classPath, className);
}
/**
* ¸ü¸ÄÀà¼ÓÔØÆ÷¼ÓÔØÀàµÄclasspath,ÔÚÖƶ¨Â·¾¶Ï¼ÓÔØÖƶ¨µÄÀàclassÎļþ
* @param classPath Òª¼ÓÔصÄÀà·¾¶
* @param className Òª¼ÓÔصÄÀàÃû
* ×îΪÏÞ¶¨,Ö»ÄܼÓÔز»º¬°üµÄÀà.
* */
public Class<?> loadClass(String classPath, String className) throws ClassNotFoundException{
if(className.indexOf('.') >= 0) {
throw new ClassNotFoundException(className);
}
File classFile = new File(classPath + ConstantParam.SEPARATOR + className + ".class");
byte[] mainClass = new byte[(int) classFile.length()];
try {
FileInputStream in = new FileInputStream(classFile);
in.read(mainClass);
in.close();
} catch (Exception e) {
//e.printStackTrace();
throw new ClassNotFoundException(className);
}
return super.defineClass(className, mainClass, 0, mainClass.length);
}
/**
* »ñÈ¡classPath
* @return String classPath
* */
public Stri
Ïà¹ØÎĵµ£º
javaÉú³Éword,htmlÎļþ²¢½«ÄÚÈݱ£´æÖÁÊý¾Ý¿â
Posted on 2005-12-15 17:19 Kela ÔĶÁ(3126) ÆÀÂÛ(3) ±à¼ ÊÕ²Ø
ÔÚ×î½üµÄÒ»¸öÏîÄ¿ÖÐÐèÒª½«Ò»¶Î×Ö·ûÀàÐ͵ÄÎı¾´æΪword£¬html²¢Òª½«wordµÄÄÚÈݱ£´æÔÚÊý¾Ý¿âÖУ¬ÓÚÊ ......
»Øµ÷¸ÅÄî:
Èí¼þÄ£¿éÖ®¼ä×ÜÊÇ´æÔÚ×ÅÒ»¶¨µÄ½Ó¿Ú£¬´Óµ÷Ó÷½Ê½ÉÏ£¬¿ÉÒÔ°ÑËûÃÇ·ÖΪÈýÀࣺͬ²½µ÷Óᢻص÷ºÍÒì²½µ÷Óá£Í¬²½µ÷ÓÃÊÇÒ»ÖÖ×èÈûʽµ÷Ó㬵÷Ó÷½ÒªµÈ´ý¶Ô·½Ö´ÐÐÍê±Ï²Å·µ»Ø£¬ËüÊÇÒ»ÖÖµ¥Ïòµ÷Ó㻻ص÷ÊÇÒ»ÖÖË«Ïòµ÷ÓÃģʽ£¬Ò²¾ÍÊÇ˵£¬±»µ÷Ó÷½ÔÚ½Ó¿Ú±»µ÷ÓÃʱҲ»áµ÷ÓöԷ½µÄ½Ó¿Ú£»Òì²½µ÷ÓÃÊÇÒ»ÖÖÀàËÆÏûÏ¢»òʼþµÄ»úÖÆ£¬² ......
½ñÌì·¢ÏÖÒ»¸öºÜNBµÄÍæÒ⣬ÈÃÎÒÃÇÔÚ¿ª·¢µÄʱºòÐÞ¸ÄJavaÎļþ£¬²»ÓÃÖØÆô·þÎñÆ÷Á¢¿ÌÉúЧ£¡Ö§³ÖJetty tomcat jbossµÈºÜ¶à·þÎñÆ÷£¬Ëü¾ÍÊÇJRebel¡£ http://www.zeroturnaround.com/jrebel/installation/ ÕâÀïÓÐÕë¶Ô²»Í¬·þÎñÆ÷µÄ°²×°·½·¨£¬»ù±¾ÉÏÖ÷Á÷µÄ¶¼º¸ÇÁË£¬¾ø´ó¶àÊý³ÌÐòÔ±¶¼ÄÜʹÓã¡ÎÒÃǹ«Ë¾ÓÃmaven/jetty¶ÔÏîÄ¿½øÐй¹½¨ºÍ¿ª ......
×î½üÔÚÕÒ¹¤×÷£¬»ù±¾¶¼ÊÇjava¿ª·¢µÄ·½Ïò£¬ºÜ¶à±ÊÊÔ¡¢ÃæÊÔÌⶼÊÇΧÈÆStringÀà¶ÔÏóÕ¹¿ªµÄ£¬»¨ÑùºÜ¶à£¬µ«ÊÇÍò±ä²»ÀëÆäÖУ¬ÕÆÎÕÁË»ù±¾µÄÔÀí£¬ÎÞÂÛÔõô±ä£¬ÊµÖʶ¼ÊÇÒ»ÑùµÄ¡£ÏÂÃæ×ܽáһϹØÓÚStringµÄ»ù±¾ÖªÊ¶µã£º
£¨Ò»£©StringÊÇfinalµÄ
¿ÉÄÜÎÒÃǺܶàÈËÓöµ½¹ýÕâ¸öÎÊÌâfinal¹Ø¼ü×ÖÓÐʲô×÷Óã¬ÆäÖÐÒ»¸ö»Ø´ð¾ÍÊÇfinalÐÞÊÎ ......