Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

eclipse and jsp #242

Closed zhouruikun closed 5 years ago

zhouruikun commented 5 years ago

import com.fazecast.jSerialComm.SerialPort; public class GetSerial extends HttpServlet { public void service(HttpServletRequest req, HttpServletResponse res) {

    System.out.println(System.getProperty("java.classpath"));

    SerialPort[] comPort = SerialPort.getCommPorts();

    try {
        res.getWriter().println(comPort.length);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

}

hello, thanks for your attantion, I write code just above, that is ok, has no error . but i get a error when i run this code

java.lang.ClassNotFoundException: com.fazecast.jSerialComm.SerialPort

but i can use this jar correct on a new maven project with maven dependency import

hedgecrw commented 5 years ago

It means that somehow in your configuration, Eclipse is not including the jSerialComm JAR and/or external native libraries correctly when compiling your full application (but it is including them correctly when you include it as a Maven dependency). Unfortunately, I have no way of debugging this issue since it's not a jSerialComm library issue but rather an Eclipse configuration one. Maybe try posting this question to a general forum or Google to see if anyone has had a similar issue including a third-party JAR with native libraries in their own Eclipse/JSP project. Thanks!