我在JDK1.3.1上用Javax.comm调通了得呀,建议你看Javax.comm包随身带得帮助,即如何配置Javax.comm包,不是就直接放到ClassPath下那么简单的。 Copy win32com.dll to your <JDK>\bin directory. C:\>copy c:\commapi\win32com.dll to c:\jdk1.3.1\bin Copy comm.jar to your <JDK>\lib directory. C:\>copy c:\commapi\comm.jar c:\jdk1.3.1\lib Copy javax.comm.properties to your <JDK>\lib directory. ...................... 下面还有好多啦,你只要按照帮助文档所说的去做,肯定能成功。建议你和超级终端配合使用。
javax.commAPI 2.0.1 for Winnt/2000谢谢
Copy win32com.dll to your <JDK>\bin directory.
C:\>copy c:\commapi\win32com.dll to c:\jdk1.3.1\bin
Copy comm.jar to your <JDK>\lib directory.
C:\>copy c:\commapi\comm.jar c:\jdk1.3.1\lib
Copy javax.comm.properties to your <JDK>\lib directory.
......................
下面还有好多啦,你只要按照帮助文档所说的去做,肯定能成功。建议你和超级终端配合使用。
谢谢
你可以到ibm和sun 的网站上查一下资料,看有没有新的解决方案,在这儿耗是没意义的。
package javacomm;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.comm.*;
import java.util.*;
import javax.swing.*;public class Applet1 extends Applet {
boolean isStandalone = false;
static CommPortIdentifier portId;
static Enumeration portList = null;
JTextArea jTextArea1 = new JTextArea();
BorderLayout borderLayout1 = new BorderLayout(); //Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} //Construct the applet
public Applet1() {
}
//Initialize the applet
public void init() {
try {
jbInit(); String drivername = "javax.comm.CommDriver";
System.setSecurityManager(null);
try {
CommDriver driver =
(CommDriver)Class.forName(drivername).newInstance();
driver.initialize();
} catch (Exception e) {
System.out.println (e.getMessage ());
} portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
System.out.println(portId.getName());
jTextArea1.setText(jTextArea1.getText() + portId.getName());
} }
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jTextArea1.setText("jTextArea1");
this.setLayout(borderLayout1);
this.add(jTextArea1, BorderLayout.CENTER);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
} public void start(){
// portList = CommPortIdentifier.getPortIdentifiers();
} public static void main(String[] args){
Applet1 applet1=new Applet1();
applet1.start();
}}
跟applet读取本地文件一样,要进行安全设置applet才能访问本地资源。
串口算不算本地资源。