¶¯Ì¬Éú³É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£¬ÕâÊǺܶàÐÂÊÖ¾³£»áÎÊÎÒµÄÎÊÌ⣬ÏÖÔÚÎÒ¼òµ¥ÃèÊöÏÂÒ»¸öJava³õѧÕßµ½¾ÍҵҪѧµ½µÄһЩ¶«Î÷£º
Ê×ÏÈÒªÃ÷°×JavaÌåϵÉè¼Æµ½µÃÈý¸ö·½Ã棺J2SE,J2EE,J2ME£¨KJAVA£©¡£J2SE£¬Java 2 Platform Standard
Edition£¬ÎÒÃǾ³£Ëµµ½µÄJDK£¬¾ÍÖ÷ÒªÖ¸µÄÕâ¸ö£¬ËüÊÇÈýÕߵĻù ......
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
......
TIOBE
µÄ
±à³ÌÓïÑÔÅÅÃû°ñ£¬Ïë±Ø´ó¼Ò¶¼·Ç³£ÊìϤ£¬Ã¿Ô·¢²¼È«Çò±à³ÌÓïÑÔµÄÈȶȺÍÇ÷ÊÆ¡£ÔÚËÄÔ·ݷ¢²¼µÄÊý¾ÝÖУ¬CÓïÑÔÖÕÓÚ³¬¹ýJava³ÉΪNo.1£¬µ«ÕæÕýÈÃÈ˵£ÓÇ
µÄ£¬²¢²»ÊÇCµÄ¶á¹Ú£¬¶øÊÇJavaµÄ³ÖÐøÆ£Èõ£¬¸üÔã¸âµÄÊÇ£¬ËƺõûÓÐÄĸöÀÏ´óÕ¾³öÀ´Íì¾ÈÍÇÊÆ¡£
×÷ΪһÃûJava´ÓÒµÕߣ¬ÎÒÔÚÆóÒµÓ¦ÓÃÁìÓò×öÈí¼þ£¬´Ó¹¤×÷Öв¢Î´¸ÐÊܵ½Javaµ ......
ÔÚjava³ÌÐòÖÐ,ΪÁËʵÏÖͬ±¾µØϵͳµÄÓ²¼þ¶Ë¿Ú(RS-232±ê×¼´®¿Ú/IEEE1284±ê×¼²¢¿Ú)ͨѶ,Ä¿Ç°ÓÐÁ½¸ö·½·¨,µÚÒ»¸ö¾ÍÊÇÒÔǰ˵¹ýµÄ,ʹÓÃJNI¼¼Êõ×Ô¼ºÐ´Ò»¸öÓëjava³ÌÐòÏà¹ØµÄdll/soÎļþ,Õâ¸öÎļþ¿ÉÒÔÖ±½ÓºÍ±¾µØϵͳͨÐÅ,´Ó¶ø¹ÜÀí±¾µØ»úÆ÷µÄ¶Ë¿Ú,²»¹ýʹÓÃjava³ÌÐò¶À×ÔʵÏÖÒ»¸ö±È½ÏÍêÉƵĶ˿ڹÜÀí½â¾ö·½°¸¶Ô¸öÈ˶øÑÔÊÇÒ»¸ö»¨·Ñ¾Þ´óÇÒ²»Ê ......