hallo
die sache mit dem commport ist immer nervig, weil du dich GENAU an die installationsanweisungen halten musst.
ansonsten wirft er gerne keinen fehler, sondern tut einfach nix.
folgendes programm aus go to java ist voll funktionsfähig:
import java.util.*;
import java.io.*;
import javax.comm.*;
public class Listing2604
{
public static void printHello(Writer out)
throws IOException
{
String s = "Hello LPT1 World";
s += " " + s + " " + s;
for (int i = 1; i <= 50; ++i) {
out.write(s.substring(0, i) + "\r\n");
}
out.write("\f");
}
public static void main(String[] args)
{
Enumeration en = CommPortIdentifier.getPortIdentifiers();
while (en.hasMoreElements()) {
CommPortIdentifier cpi = (CommPortIdentifier)en.nextElement();
if (cpi.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
if (cpi.getName().equals("LPT1")) {
try {
ParallelPort lpt1 = (ParallelPort)cpi.open(
"LPT1Test",
1000
);
OutputStreamWriter out = new OutputStreamWriter(
lpt1.getOutputStream()
);
printHello(out);
out.close();
lpt1.close();
System.exit(0);
} catch (PortInUseException e) {
System.err.println(e.toString());
System.exit(1);
} catch (IOException e) {
System.err.println(e.toString());
System.exit(1);
}
}
}
}
}
}
printet bei mir ein dreieck mit hallo worlds ,)
ok, was ist zutun:
so ist der baum aufgebaut, mach es nicht anders, sonst geht nix.
java 5 an board, die neue comportapi gezogen
E:\Java\jdk1.5.0
E:\Java\jdk1.5.0\bin\win32com.dll
E:\Java\jdk1.5.0\lib\javax.comm.properties
E:\Java\jdk1.5.0\lib\comm.jar
und: elementar wichtig
E:\Java\jdk1.5.0\jre\lib\javax.comm.properties
E:\Java\jdk1.5.0\jre\bin\win32com.dll
die comm.jar nicht im classpath von der jre.
viel spaß