0

I tried to install a java Serial communication lib on my Raspberry PI (https://github.com/scream3r/java-simple-serial-connector), so I copied the .so file (src/java/libs/linux/libjSSC-2.8_armhf.so) to my lib path (usr/lib/jvm/java-1.11.0-openjdk-armhf/lib).

and then, when I test the lib code example :

   import jssc.SerialPortList;

   public class Main {

       public static void main(String[] args) {
           String[] portNames = SerialPortList.getPortNames();
           for(int i = 0; i < portNames.length; i++){
           System.out.println(portNames[i]);
           }
       }
    }

I get many errors saying that SerialPortList is not found.

So I would like to know how to properly install the lib. errors :

 javac Main.java

 Main.java:1: error: package jssc does not exist
 import jssc.SerialPortList;
       ^
 ./SerialPortList.java:38: error: cannot find symbol
 private static SerialNativeInterface serialInterface;
               ^
 symbol:   class SerialNativeInterface
 location: class SerialPortList
 Main.java:6: error: cannot access SerialPortList
 String[] portNames = SerialPortList.getPortNames();
                     ^
 bad source file: ./SerialPortList.java
 file does not contain class SerialPortList
 Please remove or make sure it appears in the correct subdirectory of the 
 sourcepath.
./SerialPortList.java:43: error: cannot find symbol
    serialInterface = new SerialNativeInterface();
                          ^
 symbol:   class SerialNativeInterface
 location: class SerialPortList
 ./SerialPortList.java:44: error: cannot find symbol
    switch (SerialNativeInterface.getOsType()) {
            ^
 symbol:   variable SerialNativeInterface
 location: class SerialPortList
 ./SerialPortList.java:45: error: cannot find symbol
        case SerialNativeInterface.OS_LINUX: {
             ^
 symbol:   variable SerialNativeInterface
 location: class SerialPortList
 ./SerialPortList.java:50: error: cannot find symbol
        case SerialNativeInterface.OS_SOLARIS: {
             ^
 symbol:   variable SerialNativeInterface
 location: class SerialPortList
 ./SerialPortList.java:55: error: cannot find symbol
        case SerialNativeInterface.OS_MAC_OS_X: {
             ^
 symbol:   variable SerialNativeInterface
 location: class SerialPortList
 ./SerialPortList.java:60: error: cannot find symbol
        case SerialNativeInterface.OS_WINDOWS: {
             ^
  symbol:   variable SerialNativeInterface
  location: class SerialPortList
  ./SerialPortList.java:293: error: cannot find symbol
    if(SerialNativeInterface.getOsType() == 
  SerialNativeInterface.OS_WINDOWS){
       ^
  symbol:   variable SerialNativeInterface
  location: class SerialPortList
  ./SerialPortList.java:293: error: cannot find symbol
    if(SerialNativeInterface.getOsType() == 
   SerialNativeInterface.OS_WINDOWS){
                                            ^
   symbol:   variable SerialNativeInterface
   location: class SerialPortList
   ./SerialPortList.java:334: error: cannot find symbol
                    if(portHandle < 0 && portHandle != 
    SerialNativeInterface.ERR_PORT_BUSY){
                                                       ^
    symbol:   variable SerialNativeInterface
    location: class SerialPortList
    ./SerialPortList.java:337: error: cannot find symbol
                    else if(portHandle != 
     SerialNativeInterface.ERR_PORT_BUSY) {
                                          ^
     symbol:   variable SerialNativeInterface
     location: class SerialPortList
     13 errors

Thanks.

kml2019
  • 63
  • 6

1 Answers1

0

You need to add your library as an external library.
Check how to do so on your IDE : Example for Intellij

EDIT to match OP's IDE:
Geany Tutorial for external libraries.

Right-click on the name of the project that needs the library -> Properties -> The Project Properties window opens. In Categories tree select “Libraries” node -> On the right side of the Project Properties window press button “Add JAR/Folder” -> Select jars you need.

IQbrod
  • 2,060
  • 1
  • 6
  • 28
  • 3
    This should be a comment. You are only providing a link to someone else's answer and not actually providing a full comprehensive answer. – Popeye Aug 20 '19 at 08:36