Fazecast / jSerialComm

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

Please clarify installation procedure on LINUX #281

Closed ar99 closed 4 years ago

ar99 commented 4 years ago

Hi. Sorry for my few java knowlegement. I'm try to find a update replacement to RXTXon Java. I didn't use eclipse, maven, glander.. only javac. Please clarify the install procedore to ubuntu. I try to download https://fazecast.github.io/jSerialComm/binaries/jSerialComm-2.6.1.jar on my directory, and also copy to /usr/share/java, but didn't work.

My code:

import com.fazecast.jSerialComm.*;

public class jSerialtest {

public static void main(String[] args) {
        SerialPort comPort = SerialPort.getCommPorts()[0];
        comPort.openPort();
        try {
           while (true)
           {
              while (comPort.bytesAvailable() == 0)
                 Thread.sleep(20);
              byte[] readBuffer = new byte[comPort.bytesAvailable()];
              int numRead = comPort.readBytes(readBuffer, readBuffer.length);
              System.out.println("Read " + numRead + " bytes.");
           }
        } catch (Exception e) { e.printStackTrace(); }
        comPort.closePort();
    }       
}

Errors:

$ javac src/jSerialtest.java  -nowarn  -d bin -Xlint:unchecked  -Xdiags:verbose
src/jSerialtest.java:1: error: package jSerialComm does not exist
import jSerialComm.*;
^
src/jSerialtest.java:7: error: cannot find symbol
                SerialPort comPort = SerialPort.getCommPorts()[0];
                ^
  symbol:   class SerialPort
  location: class jSerialtest
src/jSerialtest.java:7: error: cannot find symbol
                SerialPort comPort = SerialPort.getCommPorts()[0];
                                     ^
  symbol:   variable SerialPort
  location: class jSerialtest
3 errors