I'm trying to run this sample code which is querying available com ports from here: http://www.java2s.com/Code/Java/Development-Class/QueryingAvailableCOMPorts.htm
// Install the Java Comm API first. if there is no necessary file, say Dll files, the API
// won't work.
import java.util.Enumeration;
import javax.comm.*;
import java.util.Enumeration;
public class ListPorts {
public static void main(String args[]) {
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
while (ports.hasMoreElements()) {
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);
}
}
}
I added comm api properly into my project, i can see my comm.jar file under Libraries folder of my project. But when i build the project, netbeans gives me this message:
ant -f C:\Users\Timur\Documents\NetBeansProjects\KEYCON clean jar
C:\Users\Timur\Documents\NetBeansProjects\KEYCON\nbproject\build-impl.xml:63:
Source resource does not exist:
C:\Users\Timur\Desktop\javax.comm\nblibraries.properties BUILD FAILED
(total time: 0 seconds)
And when i try to run project, Netbeans gives this message:
run: Error loading win32com: java.lang.UnsatisfiedLinkError: no
win32com in java.library.path BUILD SUCCESSFUL (total time: 0 seconds)
Should i store my comm.jar file somewhere specifically? It's in my desktop now. Or does the problem occurs because of something else?
Best Answer
Another question of mine which wasn't answered by this community :/
And again i have write answer by my own. so here it is:
but the thing is what i write here is generally the same solution for similar questions on this site or other sites and yet i didn't work out at first 8-9 times.