Hello! I am new in J2ME and I had a project about how to build a communication system by java codes.I just need to know the problem I have in my code such that I get an error when execute it through console.The error is:
javax.microedition.io.ConnectionNotFoundException:The requested Protocol doesnot exist btspp://localhost:1101;name: program
package doctor;
import java.io.*;
import javax.microedition.bluetooth.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
//import com.rococosoft.io.*;
public class Program extends MIDlet implements CommandListener
{
private Display display;
private TextBox textBox1;
private Command entryCommand;
private Command exitCommand;
public void startApp()
{display=Display.getDisplay(this);
entryCommand=new Command("OK", Command.SCREEN, 1);
exitCommand=new Command("Quit", Command.SCREEN, 1);
textBox1=new TextBox("How application works..", "This application helps to send an alert ", 256, 0);
textBox1.addCommand(entryCommand);
textBox1.addCommand(exitCommand);
textBox1.setCommandListener(this);
display.setCurrent(textBox1);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command choice,Displayable displayable)
{if(choice==exitCommand)
{destroyApp(false);
notifyDestroyed();
}
else
{
try {
Delp();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
private void Delp() throws IOException
{ StreamConnection con= null;
StreamConnectionNotifier service= null;
InputStream ip= null;
OutputStream op=null;
String serviceURL="btspp://localhost:1101;name=Program";
service=(StreamConnectionNotifier)Connector.open(serviceURL);
con=service.acceptAndOpen();
ip=con.openInputStream();
op=con.openOutputStream();
ReadThread rdthr=new ReadThread(ip,op);
rdthr.start();
}
}
class ReadThread extends Thread
{InputStream ip=null;OutputStream op=null;
public ReadThread (InputStream inp,OutputStream onp){ip=inp;op=onp;}
public void run()
{
try{char data;
data=(char)ip.read();
op.write(data);
}
catch(IOException e){}
}
}
I just need to say that MY PROBLEM IS not knowing how to include the SPP connections into my code so that the connection would be accepted by java compiler...That's what I need help about...
Thanks in advance