Javaµ÷ÓÃϵͳÃüÁîѧϰ£¨Èý£©
ѧϰÁËÁ½ÆªµÄRuntimeÀ࣬ÏÖÔÚ¶ÔËüÓÐÁ˸üÉîÒ»²ãµÄÁ˽⣬ÄÇôÎÒÃÇÀ´¿´¿´ÏÂÃæµÄ´úÂ룺
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader ;
import java.io.BufferedReader;
public class Exec_Output{
public static void main(String []args)throws IOException,InterruptedException{
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("dir");
//int exitValue = p.exitValue();
//int exitValue = p.waitFor();
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("<OUTPUT>");
while((line = br.readLine())!=null){
System.out.println(line);
System.out.println("</OUTPUT>");
int exitValue = p.waitFor();
System.out.println("Process exitValue="+exitValue);
}
}
}
//Ö´Ðнá¹û£¨ÔÚUbuntu9.10ÏÂÖ´ÐУ©
<OUTPUT>
class CUtil.java Exec.java Exec_Javac.java Exec_Output.java Str.java
</OUTPUT>
ÒòΪÒÔÉÏ´úÂ룬ÎÒʹÓÃÁËUbuntu9.10ÏÂÖ´ÐУ¬ÊÇÒ»µãÎÊÌⶼûÓУ¬µ«µ±ÎÒÔÚwindows xpÏÂÖ´ÐУ¬ÒâÍâÈ´·¢ÉúÁË¡£
E:classescomjavaworldjpitfallsarticle2>java BadExecWinDir
java.io.IOException: CreateProcess: dir error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at BadExecWinDir.main(BadExecWinDir.java:12)
Ò²Ðí´ó¼Ò¾õµÃÆæ¹Ö£¬ÆäʵÎÒÒ²ºÜÆæ¹Ö£¬ÎªÊ²Ã´ÄØ¡£ºÃºÃÔÚLinuxÏ£¬Õ¦µ½XP¾ÍÓÐÎÊÌâÁËÄØ¡£
ÒÔÏÂÒýÓÃÁ˱ðÈ˵Ļ°£º
˵ʵ
Ïà¹ØÎĵµ£º
Ò»:¼ò½é
±¾ÎĽéÉÜÁËJavaÓë.NET¿ª·¢µÄWeb ServicesÏ໥µ÷Óõļ¼Êõ¡£±¾ÎÄ°üÀ¨Á½¸ö²¿·Ö£¬µÚÒ»²¿·Ö½éÉÜÁËÈçºÎÓÃ.NET×ö¿Í»§¶Ëµ÷ÓÃJavaдµÄWeb Services,µÚ¶þ²¿·Ö½éÉÜÁËÈçºÎÓÃJava×ö¿Í»§¶Ëµ÷ÓÃ.NET¿ª·¢µÄWeb Services¡£ ¡¡
¡¡
¶þ:ÏîÄ¿ÐèÒªµÄ¹¤¾ß¡¡¡¡
WindowsXP Professial(IIS)
¡¡ Eclipse3.1(ÒÑ×°ºÃTomcat axis)
¡¡¡¡VS ......
ͨ¹ýjavaµÄ·´Éä»úÖÆ£¬¶¯Ì¬µ÷ÓÃij¸ö·½·¨£º
ÈçÏ£º
public Object invokeMethod(String className, String methodName,
Object[] args) throws Exception{
Class ownerClass = Class.forName(className);
Object owner = ownerClass.newInstance();
Class[] argsClass = new Class[args.length ......
±àÕß°´£ºJavaÄÚ´æй©ÊÇÿ¸öJava³ÌÐòÔ±¶¼»áÓöµ½µÄÎÊÌ⣬³ÌÐòÔÚ±¾µØÔËÐÐÒ»ÇÐÕý³££¬¿ÉÊDz¼Êðµ½Ô¶¶Ë¾Í»á³öÏÖÄÚ´æÎÞÏÞÖƵÄÔö³¤£¬×îºóϵͳ̱»¾£¬ÄÇôÈç
ºÎ×î¿ì×îºÃµÄ¼ì²â³ÌÐòµÄÎȶ¨ÐÔ£¬·Àֹϵͳ±ÀÅÌ£¬×÷ÕßÓÃ×ÔÒѵÄÇ×Éí¾ÀúÓë¸÷λÍøÓÑ·ÖÏí½â¾öÕâЩÎÊÌâµÄ°ì·¨¡£
×÷ΪInternet×îÁ÷Ðеı ......
1ʹÓò»´ø²ÎÊýµÄ´æ´¢¹ý³Ì
¡¡¡¡Ê¹Óà JDBC Çý¶¯³ÌÐòµ÷Óò»´ø²ÎÊýµÄ´æ´¢¹ý³Ìʱ£¬±ØÐëʹÓà call SQL תÒåÐòÁС£²»´ø²ÎÊýµÄ call תÒåÐòÁеÄÓï·¨ÈçÏÂËùʾ£º
¡¡¡¡
ÒÔÏÂÊÇÒýÓÃƬ¶Î£º
{call procedure-name}
¡¡¡¡×÷ΪʵÀý£¬ÔÚ SQL Server 2005 AdventureWorks ʾÀýÊý¾Ý¿âÖд´½¨ÒÔÏ´洢¹ý³Ì£º
¡¡¡¡
ÒÔÏÂÊÇÒýÓÃƬ¶Î£º
......
import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte ......