problemas con javax.comm y eclipse
No encuentra los puertos al ejecutar:
import javax.comm.*;
import java.util.Enumeration;
public class comunicaPuerto {
public static void main(String[] args) {
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
System.out.println("aqui si que llega");
while (ports.hasMoreElements())
{
System.out.println("aqui si que llega 2");
CommPortIdentifier port = (CommPortIdentifier)ports.nextElement();
String type;
switch (port.getPortType()) {
case CommPortIdentifier.PORT_PARALLEL:
type = "Parallel";
break;
case CommPortIdentifier.PORT_SERIAL:
type = "Serial";
break;
default: /// Shouldn't happen
type = "Unknown";
break;
}
System.out.println(port.getName() + ": " + type);
}
try{
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("COM1");
}catch (NoSuchPortException e){
System.out.println("El puerto no existe");
}
}
}
¿Cual es el problema?
import javax.comm.*;
import java.util.Enumeration;
public class comunicaPuerto {
public static void main(String[] args) {
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
System.out.println("aqui si que llega");
while (ports.hasMoreElements())
{
System.out.println("aqui si que llega 2");
CommPortIdentifier port = (CommPortIdentifier)ports.nextElement();
String type;
switch (port.getPortType()) {
case CommPortIdentifier.PORT_PARALLEL:
type = "Parallel";
break;
case CommPortIdentifier.PORT_SERIAL:
type = "Serial";
break;
default: /// Shouldn't happen
type = "Unknown";
break;
}
System.out.println(port.getName() + ": " + type);
}
try{
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("COM1");
}catch (NoSuchPortException e){
System.out.println("El puerto no existe");
}
}
}
¿Cual es el problema?
tengo el mismo problema, en la misma plataforma (eclipse), si ya solucionaste el problema por favor dime como
Gracias
Gracias
