New to using 3rd party jars so this may be something very basic…
Trying to add some serial port functionality using fazecast.jSerialComm and running into an error.
I can only find one instance similar…and it didn’t help me
I have added the jSerialComm.jar to c:\lucee\tomcat\lib and restarted. Seems to be loaded because I can’t change the file name because “open in tomcat”
(I also tried using LoadPaths in application.cfc but same issue)
When I run
SerialPort = createObject( "java", "com.fazecast.jSerialComm.*");
dump( SerialPort );
cannot load class through its string name, because no definition for the class with the specified name [com.fazecast.jSerialComm.*] could be found caused by (java.lang.ClassNotFoundException:com.fazecast.jSerialComm.*;java.lang.ClassNotFoundException:com.fazecast.jSerialComm.* not found by lucee.core ;)
Any ideas on what I’m doing wrong?
Java 11.0.6 (AdoptOpenJDK) 64bit
OS Windows Server 2019 (10.0) 64bit
i never use the asterisk at the end of the class.
try to remove it
Already tried that. Same issue
cannot load class through its string name, because no definition for the class with the specified name [com.fazecast.jSerialComm] could be found caused by (java.lang.ClassNotFoundException:com.fazecast.jSerialComm;java.lang.ClassNotFoundException:com.fazecast.jSerialComm not found by lucee.core ;)
You probably want
SerialPort = createObject( "java", "com.fazecast.jSerialComm.SerialPort");
* is used in a java import statement, and that is telling it to import all classes in the package
com.fazecast.jSerialComm - a package is just like a folder that has a bunch of classes in it, so you need to include the class name, which I’m guessing is SerialPort, but you’ll need to check the java docs to be sure. Hope that helps.
That works. Thanks Pete.
I did try com.fazecast.jSerialComm.getCommPorts but that didn’t work because that’s accessing a method before the class was loaded (I assume)
This now works as well