¶¯Ì¬Éú³ÉjavaÎļþµÄ·½·¨
package com.hongsoft.test;
import java.io.*;
//¶¨ÖƵÄÀà×°ÈëÆ÷
public class TestCompile extends ClassLoader
{
String _compiler;
String _classpath;
public static void main(String[] args)
{
new TestCompile();
}
public TestCompile()
{
super(ClassLoader.getSystemClassLoader());
//ĬÈϱàÒëÆ÷
if (_compiler == null)
_compiler = "D:\\j2sdk1.4.2\\bin\\javac";
_classpath = ".";
String extraclasspath =
"c:\\Program Files\\Java\\j2re1.4.2\\lib\\rt.jar";
// = System.getProperty("calc.classpath");
if (extraclasspath != null)
{
_classpath =
_classpath
+ System.getProperty("path.separator")
+ extraclasspath;
}
compile();
}
public void compile()
{
String filename = "";
String classname = "";
try
{
//´´½¨ÁÙʱÎļþ
File javafile =
File.createTempFile("compiled_", ".java", new File("."));
filename = javafile.getName();
classname = filename.substring(0, filename.lastIndexOf("."));
generateJavaFile(javafile, classname);
//±àÒëÎļþ
invokeCompiler(javafile);
//´´½¨javaÀà
byte[] buf = readBytes(classname + ".class");
Class c = defineClass(buf, 0, buf.length);
try
{
c.newInstance();
}
catch (IllegalAccessException e)
{
throw new RuntimeException(e.getMessage());
}
catch (InstantiationException e)
{
throw new RuntimeException(e.getMessage());
}
}
catch (IOException e)
{
throw new RuntimeException(e.getMessage());
}
}
//Éú³ÉjavaÎļþ
void generateJavaFile(File javafile, String classname) throws IOException
{
FileOutputStream out = new FileOutputStream(javafile);
String text =
"public class "
+ classname
+ " {"
+ " public int getCreater() {return 1;}"
+ "}";
out.write(text.getBytes());
out.close();
}
//±àÒëjavaÎļþ
void invokeCompiler(File javafile) throws IOException
{
String[] cmd =
{ _compiler, "-classpath", _classpath, javafile.getName()};
//Ö´ÐбàÒëÃüÁî
//A1£º
Process process = Run
Ïà¹ØÎĵµ£º
ÓÐÐí¶àÈËѧÁ˺ܳ¤Ê±¼äµÄJava£¬µ«Ò»Ö±²»Ã÷°×hashCode·½·¨µÄ×÷Óã¬
ÎÒÀ´½âÊÍһϰɡ£Ê×ÏÈ£¬ÏëÒªÃ÷°×hashCodeµÄ×÷Óã¬Äã±ØÐëÒªÏÈÖªµÀJavaÖеļ¯ºÏ¡£¡¡¡¡
×ܵÄÀ´Ëµ£¬JavaÖеļ¯ºÏ£¨Collection£©ÓÐÁ½À࣬һÀàÊÇList£¬ÔÙÓÐÒ»ÀàÊÇSet¡£
ÄãÖªµÀËüÃǵÄÇø±ðÂð£¿Ç°Õß¼¯ºÏÄÚµÄÔªËØÊÇÓÐÐòµÄ£¬ÔªËØ¿ÉÒÔÖØ¸´£»ºóÕßÔªËØÎÞÐò£¬µ«ÔªËز» ......
JAVAѧϰ·Ïßͼ
ÔÚ¿ªÊ¼Ö®Ç°ÓбØÒªÔÙÌÖÂÛÒ»ÏÂJ2ME£¬J2SE£¬J2EEÕâЩ¸ÅÄî¡£J2ME£¬The
Micro Edition of the Java 2 Platform¡£Ö÷ÒªÓÃÓÚǶÈëʽJava£¬ÈçÊÖ»ú£¬PDAµÈµÈ¡£J2SE£¬Java 2
Platform£¬Standard Edition£¬ÎÒÃÇͨ³£Ëù˵µÄJDK(Java Development
Kit)°üº¬ÔÚ´Ë£¬ÊÇJ2EEµÄ»ù´¡¡£J2EE£¬Java 2 Platform£¬Enterprise
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cn.vicky.socket;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Vector;
/**
*
* @author Vicky
* ¹ã²¥Àà
*/
public class BMana ......
È¡:
Cookie[] cookies = request.getCookies();
if(cookies!=null){
for(Cookie cookie : cookies){
if(cookie.getName().equals("mid")){
String mid = cookie.getValue();
}
}
}
´æ:
String mid ......
ÔÚjava³ÌÐòÖÐ,ΪÁËʵÏÖͬ±¾µØÏµÍ³µÄÓ²¼þ¶Ë¿Ú(RS-232±ê×¼´®¿Ú/IEEE1284±ê×¼²¢¿Ú)ͨѶ,ĿǰÓÐÁ½¸ö·½·¨,µÚÒ»¸ö¾ÍÊÇÒÔǰ˵¹ýµÄ,ʹÓÃJNI¼¼Êõ×Ô¼ºÐ´Ò»¸öÓëjava³ÌÐòÏà¹ØµÄdll/soÎļþ,Õâ¸öÎļþ¿ÉÒÔÖ±½ÓºÍ±¾µØÏµÍ³Í¨ÐÅ,´Ó¶ø¹ÜÀí±¾µØ»úÆ÷µÄ¶Ë¿Ú,²»¹ýʹÓÃjava³ÌÐò¶À×ÔʵÏÖÒ»¸ö±È½ÏÍêÉÆµÄ¶Ë¿Ú¹ÜÀí½â¾ö·½°¸¶Ô¸öÈ˶øÑÔÊÇÒ»¸ö»¨·Ñ¾Þ´óÇÒ²»Ê ......