jSSC - start working with library
Let's try start working with jSSC. I'll show you how do it in NetBeans IDE.
1. Downloading jSSC
Download last version of jSSC. http://code.google.com/p/java-simple-serial-connector/downloads/list
2. Unpacking
Unpack downloaded file:
Bins folder contains binary files of jSSC. Javadoc folder contains documentation on English and Russian languages. And src folder contains jSSC source files.
3. Adding jSSC in NetBeans
Run NetBeans IDE. Go to Library Manages(Tools->Libraries):
Add new library:
On Classpath tab press Add JAR/Folder… button and select jssc.jar file:
Then, on Javadoc tab select your javadoc folder (en for English and ru for Russian documentation):
4. Creating project
Now, let's create a simple project. In project properties we must add jSSC-0.7.1 library:
After that, we must put a libjssc.dll file in project folder. We can do it in NetBeans or in file manager:
5. Coding
Nice. Now, let's write some code to make sure everything works:
``` package jssc_test;
import jssc.SerialPort; import jssc.SerialPortException;
/** * * @author scream3r */ public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SerialPort serialPort = new SerialPort("COM1");
try {
System.out.println("Port opened: " + serialPort.openPort());
System.out.println("Params setted: " + serialPort.setParams(9600, 8, 1, 0));
System.out.println("\"Hello World!!!\" successfully writen to port: " + serialPort.writeBytes("Hello World!!!".getBytes()));
System.out.println("Port closed: " + serialPort.closePort());
}
catch (SerialPortException ex){
System.out.println(ex);
}
}
} ```
After executing this simple program we'll receive this result:
That's great !!! All work fine, and now we can start working on own projects.