Java communications API ʵÏÖ²¢Ðж˿ڴòÓ¡
ʹÓà Java communications API ʵÏÖ²¢Ðж˿ڴòÓ¡
ÕâÊÇÒ»¸öÔÚ¿Í»§Ö§³ÖÖÐÓöµ½µÄÐÂÎÊÌ⣬ÎÒÔÚÏà¹ØµÄÍøÕ¾([url]www.rxtx.org[/url] and [url]www.sun.com.cn[/url])ÉÏÕÒµ½ÁËһЩÓÐÓõÄÐÅÏ¢£¬×îºóÖÕÓÚÔÚWindows XP ºÍ LinuxIA32 ƽ̨ÏÂʵÏÖ²¢Ðж˿ڴòÓ¡ÕâÒ»¹¦ÄÜ¡£
Ê×ÏÈ£¬ÎÒÃÇÒª´ÓSUNµÄÍøÕ¾ÏÂÔØJava communications API×îеİü(javacomm20-win32.zip)£¬È»ºó½âѹËõÔÚcommapiĿ¼Ï£¬½øÈëcommapiĿ¼ÖУ¬ÎÒÃÇ¿ÉÒÔ¿´µ½win32com.dll£¬comm.jar£¬javax.comm.properties Èý¸öÎļþ¡£ÔÚÕýȷʹÓÃJava communications API֮ǰ£¬ÎÒÃDZØÐëÏÈÅäÖÃJava communications APIÔÚJDK1.4.2ÔËÐл·¾³ÖС£ÎÒÃǼٶ¨JDK1.4.2µÄ°²×°Ä¿Â¼Îª"C:\java142"¡£
1. ¸´ÖÆ win32com.dll µ½ C:\java142\bin
2. ¸´ÖÆ comm.jar µ½ C:\java142\jre\lib\ext
3. ¸´ÖÆ javax.comm.properties µ½ C:\java142\jre\lib£¬javax.comm.properties Ò»¶¨Òª°²×°£¬·ñÔò£¬ÎÒÃǽ«ÕÒ²»µ½ÏµÍ³ÖеÄÈκβ¢Ðж˿ڡ£
ÏÖÔÚ£¬ÎÒÃÇÒѾÍê³ÉÁËcomm.jar µÄ°²×°¹¤×÷£¬¿ÉÒÔ²âÊÔÎÒÃǵijÌÐòÁË¡£ÏÂÃæÎÒ½«¸ø³öÎÒдµÄÒ»¸ö¼òµ¥µÄÀý×Ó£ºSimpleLPTPort.java
---------- BEGIN SOURCE ----------
import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleLPTPort {
Enumeration ports;
CommPortIdentifier portId;
ParallelPort LPTPort;
protected OutputStream out;
String outPrintStr = "When an \n\rinput method \n\ris activated, ";
public SimpleLPTPort() {
checkLPTPort();
}
public void checkLPTPort() {
ports = CommPortIdentifier.getPort
Ïà¹ØÎĵµ£º
1¡¢Java.utilµÄ¼¯ºÏÀàÖеÄÔªËرØÐëÊǶÔÏ󻯵ģ¬ËûÃDz»ÄÜÊÇ»ù±¾ÀàÐÍ¡£Èç²»ÄÜÉùÃ÷Set<char>»òList<int>¡£µ«¶ÔList<Integer>£¬¿ÉÒÔÍùÀïÃæ¼ÓintÐÍÊý¾Ý£¬Ëü»áÓÃJavaµÄautoboxing»úÖÆ×Ô¶¯×ª»»³ÉInteger¶ÔÏó¡£
2¡¢²ÎÊý»¯ÀàÖеÄÀàÐͲÎÊý¿ÉÒÔÊÇÊý×éÀàÐÍ£¬ÈçMap< ......
1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
2. Õ»µÄÓÅÊÆÊÇ£¬´æÈ¡ËٶȱȶÑÒª¿ì£¬½ö´ÎÓÚÖ±½ÓλÓÚCPUÖеļĴæÆ÷¡£µ«È±µãÊÇ£¬´æÔÚÕ»ÖеÄÊý¾Ý´óСÓëÉú´æÆÚ±ØÐëÊÇÈ·¶¨µÄ£¬È±·¦Áé»îÐÔ¡£ÁíÍ⣬ջÊý¾Ý¿ÉÒÔ¹²Ïí£¬Ïê¼ûµÚ3µã¡£¶ÑµÄÓÅÊÆÊÇ¿ÉÒÔ¶¯Ì¬µØ·ÖÅä ......
//µ÷Óô洢¹ý³Ì´ø²Î
CallableStatement ca = conn.prepareCall("{call Login (?,?)}");
ca.setString(1,username);
& ......
Ò»¡¢JavaÔËÐÐʱµÄÁ½ÖÖºËÐÄ»úÖÆ
£¨1£©JavaÐéÄâ»ú£¨Java Virtual Machine£©
ÓÃÀ´´¦ÀíJavaÔ´Îļþ±àÒëºóµÄ×Ö½ÚÂ룬ÆÁ±Îµ×²ãÔËÐÐƽ̨µÄ²îÒ죬ʵÏÖ“Ò»´Î±àÒ룬Ëæ´¦Ö´ÐД£¬¶øÇÒ²»Í¬µÄÔËÐÐÆ ......