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
Ïà¹ØÎĵµ£º
ÊÖÉÏÒ»¸öÏîÄ¿ÐèҪͨ¹ýusb¿ÚÈ¥¶ÁÈ¡usbkeyµÄÐÅÏ¢£¬³§¼ÒÌṩµÄÖ»ÓÐC/C++µÄ½Ó¿Ú£¬¶øÖ÷Ó¦ÓÃÊÇjavaµÄ£¬ËùÒÔÐèҪʹÓÃjavaÈ¥µ÷Óö¯Ì¬Á´½Ó¿â£¬ËùÒÔ»¨Á˵ãʱ¼äÑо¿ÁËÏÂJNI¼¼Êõ£¬jdk¶ÔJNI¼¼Êõ·â×°µÃºÜµ½Î»£¬Ê¹ÓÃÆðÀ´·Ç³£¼òµ¥£¬JNI¼¼Êõ×î¹Ø¼ü»¹ÊÇÔÚÓÚjniÊý¾ÝÀàÐͺͱ¾µØÊý¾ÝÀàÐ͵Äת»»¡£Ïȼòµ¥ÂÞÁÐÏÂJNIµ ......
ѧϰJavaÀàµÄÊôÐÔ-Î人±±´óÇàÄñ
¡¡¡¡Public¡¢private¡¢protectedÏÔʾÁËÈýÖÖÀàÖеÄÊôÐԺͷþÎñµÄÀàÐÍ£¬publicÊÇ¿ÉÒÔËæÒâ·ÃÎʵġ¢privateÊÇÍâ½ç²»ÄÜ·ÃÎʵÄ(ÏÔʾÁËÊý¾ÝµÄ·â×°ÐÔ)¡¢protected˵Ã÷Êý¾ÝÊÇÊܱ£»¤µÄ¡£ÏÂÃæ¾ÍÀ´Ïêϸ½²ÊöÒ»ÏÂÕâÈý¸ö¾¿¾¹ÓÐʲôÇø±ð¡£
¡¡¡¡Ê×ÏÈÒªÁ˽âһϰüµÄ¸ÅÄî¡£ÓÐÈô¸É¸öÀ࣬ËüÃÇÏ໥֮¼äÓÐÒ»¶¨µÄ¹ØÏ ......
¶ÔÓÚÒ»¸öʵÏÖÁËComparable½Ó¿ÚµÄ¶ÔÏ󣬸ýӿÚÖ»ÄÜʵÏÖÒ»´Î¡£Èç¹ûÔÚÒ»¸ö¼¯ºÏÀïÃæÐèҪʹÓÃidÅÅÐò£¬¶øÔÚÁíÍâÒ»¸ö¼¯ºÏÀïÐèÒª°´Ãû×ÖÅÅÐòÕâʱ¾ÍÐèÒªÔÚÕâ¸ö¼¯ºÏÀïÃæÖ¸¶¨±È½ÏÆ÷¡£
Comparable½Ó¿ÚÉùÃ÷ÁËcompareTo(Object o)·½·¨
Comparator ½Ó¿ÚÉùÃ÷ÁËcompare(Object o1,Object o2)·½·¨
eg:
µÚÒ»¸öÊ÷¼¯ÊÇ°´ÕÕ¶ÔÏóĬÈϵÄidÅÅÐò£¬µ ......
Ò»¡¢JavaÔËÐÐʱµÄÁ½ÖÖºËÐÄ»úÖÆ
£¨1£©JavaÐéÄâ»ú£¨Java Virtual Machine£©
ÓÃÀ´´¦ÀíJavaÔ´Îļþ±àÒëºóµÄ×Ö½ÚÂ룬ÆÁ±Îµ×²ãÔËÐÐƽ̨µÄ²îÒ죬ʵÏÖ“Ò»´Î±àÒ룬Ëæ´¦Ö´ÐД£¬¶øÇÒ²»Í¬µÄÔËÐÐÆ ......