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 & HelpElectronics,  Serial Library › serial in applet not working
Page Index Toggle Pages: 1
serial in applet not working (Read 1516 times)
serial in applet not working
Nov 26th, 2008, 3:26pm
 
Hello, I just installed today the processing to test the serial port access. It works in Processing, the exe for Windows also, the applet is not starting. The error is:
--------------------------------------------------------
Exception in thread "Animation Thread" java.lang.NoClassDefFoundError
at processing.serial.Serial.<init>(Serial.java:128)
at processing.serial.Serial.<init>(Serial.java:102)
at serial_read.setup(serial_read.java:42)
at processing.core.PApplet.handleDraw(PApplet.java:1383)
at processing.core.PApplet.run(PApplet.java:1311)
at java.lang.Thread.run(Unknown Source)
----------------------------------------------------------

I have installed the JRE-Version 1.5.0_15

Here is the code:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import processing.core.*;
import processing.serial.*;


Serial myPort;  // Create object from Serial class
String myString = null;
PFont fontA;


void setup()
{
 size(400, 400);
 background(255,255,255);
 myPort=new Serial(this,"COM2",9600);
 myPort.clear();
 myString = myPort.readStringUntil(10);
 myString = null;
 
 fontA = loadFont("ArialNarrow-48.vlw");
 textFont(fontA, 25);
}

void draw() {
 
 while (myPort.available() > 0) {
   myString = myPort.readStringUntil(10);
   if (myString != null) {
      background(255,255,255);
      fill(0);
      text("COM2 >> " + myString,30,30);
   }
 }
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Re: serial in applet not working
Reply #1 - Nov 27th, 2008, 10:10am
 
normal applets are not allowed to do serial communication (and many other possibly harmfull things), think viewing an applet on a website and it's reading your serial ports ..

the only way to do it is signing your applet, that opens a message asking the user to trust your applet to use the serial port.

http://processing.org/hacks/hacks:signapplet
Re: serial in applet not working
Reply #2 - Nov 27th, 2008, 1:13pm
 
Hello fjen,
thank you for your sugestion. I have signed the applet, after opening it in IE the message was shown (about the signature) but the same error comes in the console.
Re: serial in applet not working
Reply #3 - Nov 27th, 2008, 1:55pm
 
well to be honest i never tried to do serial in an applet before. what exactly are you trying to do?

F
Re: serial in applet not working
Reply #4 - Nov 27th, 2008, 2:34pm
 
I want to read/write to the serial port from a java applet communicating whith some µC.
Re: serial in applet not working
Reply #5 - Nov 27th, 2008, 7:29pm
 
that was the part is was able to guess, why do you need it to be an applet if it anyways is only going to run on the _one_ computer that has that certain microcontroller attached?

F
Re: serial in applet not working
Reply #6 - Nov 28th, 2008, 8:41am
 
Good morning fjen,
You are right, there are other ways also to communicate with serial devices, I was only curious to test what I can do with Java (or not).
Anyway thank you for your interest.
mac
Page Index Toggle Pages: 1