We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Serial library in Eclipse
Page Index Toggle Pages: 1
Serial library in Eclipse (Read 15446 times)
Serial library in Eclipse
Jan 29th, 2007, 1:14am
 
Hi everyone

I need to import the serial library in my sketch using Eclipse in order to communicate with the Auduino board.

I get this error
"Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: gnu/io/SerialPortEventListener"

The error acurs here
String portname = "/dev/cu.usbserial-A1000ewL";
int baudrate = 9600;
port = new Serial(this, portname, baudrate);

I tied to add the native library path to the serial library (/Applications/Processing/libraries/serial/library), but it didn't make any difference.

Everything works fine inside the processing environment.

Any obvious solutions?

Thanks
Carl Emil
Re: Serial library in Eclipse
Reply #1 - Jan 29th, 2007, 1:35am
 
Hi Carl,

Can you check if the path of the portname is correct ? (case-sensitive)

You can type this in the terminal :

cd /dev

(return)

ls

(return)

and then check the name of your usbserial device.
Re: Serial library in Eclipse
Reply #2 - Jan 29th, 2007, 1:46am
 
I checked the portname in the terminal and it is correct.
Re: Serial library in Eclipse
Reply #3 - Jan 29th, 2007, 3:44am
 
Have you tried to list the available serial/usb port

Quote:
String portname = "Serial.list()";  
//int baudrate = 9600;
//port = new Serial(this, portname, baudrate);
port = new Serial(this, Serial.list()[0], 9600);


You can also check here:
http://www.arduino.cc/cgi-bin/yabb2/num_1147890113.html

But the Arduino forum does not mention Eclipse.
Re: Serial library in Eclipse
Reply #4 - Jan 29th, 2007, 10:37am
 
Hi Carl

The java.lang.NoClassDefFoundError means that a particular java class is not being found (nothing to do with native libraries)

In this case it is the RXTXcomm.jar that is missing.

Right click on your project name and go to Build Path->Add External Archives...

Navigate to C:\processing-0123\libraries\serial\library\RXTXcomm.jar


tooteloo,
Stephen
Re: Serial library in Eclipse
Reply #5 - Jan 30th, 2007, 4:41am
 
Problem solved.

The 'RXTXcomm.jar' was not included, nor was it's native library path.

Thanks Stephen and 'jaylfk'. I also recieved a very clear answer from Dennis Paul (d3-is.de), posted below.

"what you have here is a problem with 'eclipse'. you need to point it to the java as well as the native resources of the serial library. if you have a look at the library folder in 'serial' you will notice that there are two jars in it. 'serial.jar' and 'RXTXcomm.jar'. you need to point eclipse to both. additionally the 'RXTXcomm.jar' has a native part 'librxtxSerial.jnilib'. in eclipse you can expand the 'RXTXcomm.jar' entry and point the native library entry to the folder 'librxtxSerial.jnilib' lives in."

I've got happy blinking circuits on my table! =D
Re: Serial library in Eclipse
Reply #6 - Mar 5th, 2007, 6:49am
 
Hullo,
Having what seems to be the same problem, and I've implemented the solutions as per previous posts;

Added core, RXTX and serial jars to build path and set native library paths to libraries/serial/library.

But don't seem be resolving my error messages.  Running Ubuntu and using Processing core 0124 in Eclipse:

Code (Just a simple test):

package com.nitroushead.fyp;

import processing.core.*;
import processing.serial.*;
import gnu.io.*;

public class SerialIn extends PApplet {


Serial inputPort;


String In = null;


public SerialIn() {


System.out.println(Serial.list()[0]);


}


public static void main(String args[]) {


SerialIn serialIn = new SerialIn();

}

}

Error:

java.lang.NoClassDefFoundError: javax/comm/CommDriver thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: javax/comm/CommDriver thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

at com.nitroushead.fyp.SerialIn.<init>(SerialIn.java:14)

at com.nitroushead.fyp.SerialIn.main(SerialIn.java:19)
Experimental:  JNI_OnLoad called.
Re: Serial library in Eclipse
Reply #7 - Mar 6th, 2009, 9:41am
 
I had the exact same problem, added the 2 JAR files, but missed the .jnilib file. Thanks to everyone that added before me. I'm pretty new to Eclipse, so I'm trying to add a bit more Eclipse info.

There are 2 jar files that need to show up in "referenced libraries" You can get them in the correct spot by dragging them into your project, then add them to the Build Path.

--serial.jar
--rxtxcomm.jar

In addition to those two jar files, there is an additional file that rxtxcomm.jar refers to.

--librxtxSerial.jnilib

I made a copy of this file and placed it in my
/Library/Java/Extensions

To link the two together, go to the properties of  rxtxcomm.jar, find Native Library, Location Path...
/Library/Java/Extensions  

I was slightly caught by surprise that was it...
(i know this thread is super old, but i couldn't find any info for this problem... hopefully someone else will)

Update - i forgot how to do this, so i 'found' my old post.
Where is referenced libraries? -- window -> show view ->package explorer.

how to get it the JAR there, drag it to the project, then right click, build path - add


Re: Serial library in Eclipse
Reply #8 - Aug 9th, 2009, 1:10pm
 
Hello everyone..

I ve been facing a weird behaviour or rxtx library here...I am using osx 10.5.8 and java 1.5....the paradox that makes me worry here is that whenever i get  a :

WARNING:  RXTX Version mismatch
Jar version = RXTX-2.1-7
native lib Version = RXTX-2.2pre2

in netbeans and java 1.5 everything seems to be working just fine...(i only include RXTXcomm.jar and other libraries in the project's lib folder and additionally place librxtxSerial.jnilib in System/Library/Java/Extensions)....tho whenever i try to place the correct librxtxSerial.jnilib file in the same folder ,so as to get this:

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

i get this exception SEVERE:
Code:
null java.lang.NullPointerException
       at project.controller.Controller.openPort(Controller.java:131)

..and others..lol...but this exception mathes this line of code
Code:
  try {
       sPort= (SerialPort)portId.open(port, 2000);      
       } catch (PortInUseException e) {}

and nothing seems to be working...

now when i try to set my project to java 6(cause of some nice features) and keep this:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

i still get the exception and nothing works...

moreover the previous librxtxSerial.jnilib that was working
WARNING:  RXTX Version mismatch
Jar version = RXTX-2.1-7
native lib Version = RXTX-2.2pre2  
with java 5, gives a

Invalid memory access of location 0x12825a898 rip=0x12302e12f

Java Result: 139

when i change to java 6 and guess what crashes.
It is not working as java 6 in my mac is 64bit..correct??? So after research and much coffee i found a different librxtxSerial.jnilib with 64-bit Intel support for Java 6 on Mac OS X..but still no wonder.... So i ll have to stay with the libraries mismatch and Java 5 or does anyone has anything to say...
Thanks very much in advance!
Re: Serial library in Eclipse
Reply #9 - Aug 28th, 2009, 2:30am
 
Hi everyone,

I'm trying to move from the p5 IDE to eclipse, but I'm having problems to use the Serial library. I added the jar files and native library without luck.
After following the comments posted in this thread and others, I'm now able to compile my app, but I'm getting this error after launch:

gnu.io.PortInUseException: Unknown Application
     at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
     at processing.serial.Serial.<init>(Serial.java:136)
     at processing.serial.Serial.<init>(Serial.java:102)
     at MyProcessingSketch.setup(MyProcessingSketch.java:17)
     at processing.core.PApplet.handleDraw(PApplet.java:1400)
     at processing.core.PApplet.run(PApplet.java:1328)
     at java.lang.Thread.run(Thread.java:637)

I don't seem to be using the serial port elsewhere while trying to run this inside eclipse, but the "PortInUseException" line looks like maybe it's something related to permissions or locked files/folders?
I tried changing the default Java version in Java Preferences, running Eclipse as root, and some other suggestions I found, but all without success.

Can anybody help me find out what the problem is?

Thanks in advance!
Re: Serial library in Eclipse
Reply #10 - Nov 25th, 2009, 7:41am
 
jmytyk wrote on Mar 6th, 2009, 9:41am:
To link the two together, go to the properties of  rxtxcomm.jar, find Native Library, Location Path...
/Library/Java/Extensions  



thanks , that works
Page Index Toggle Pages: 1