السلام عليكم
أنا مبتدئ (بل من الصفر) في الجافا خصوصًا برمجة الجولات،
قرأت هنا كثيرًا ونصبت الأدوات التي أحتاجها، وجربت البرامج البسيطة ونجحت معي ولله الحمد
لكن واجهتني مشكلة في برامج البلوتوث
جربت البرنامج التجريبي الذي يأتي في برنامج J2ME Wireless Toolkit 2.2 باسم BluetoothDemo
ونجح
وعندما جربت برنامجا آخر فشل،
البرنامج الذي جربته هو
اسم الملف
FTServer.java
import javax.microedition.io.*;
import java.io.*;
import javax.bluetooth.*;
import javax.obex.*;
public class FTServer extends ServerRequestHandler
{
public FTServer() throws BluetoothStateException
{
// initialize the stack, if needed
}
public int onConnect(HeaderSet request, HeaderSet reply)
{
System.out.println("A OBEX connection has received.... ");
return ResponseCodes.OBEX_HTTP_OK;
}
public int onGet(Operation op)
{
try{
//The server has received a GET request for client.
System.out.println("Received a GET request from client.... . ");
HeaderSet hdr = op.getReceivedHeaders();
System.out.println("Server has received a request for the file " + (hdr.getHeader(HeaderSet.NAME)).toString());
String url = "file://name=" + (hdr.getHeader(HeaderSet.NAME)).toString() + ";mode=r";
InputConnection inpcon = (InputConnection)Connector.open(url);
InputStream in = inpcon.openInputStream();
byte[] fileAsBytes = new byte[97];
in.read(fileAsBytes);
System.out.println("File read fully into the port.... ");
for(int i =0; i<fileAsBytes.length; i++)
System.out.print((char)fileAsBytes);
DataOutputStream out = op.openDataOutputStream();
out.write(fileAsBytes, 0, fileAsBytes.length);
System.out.println("\n" + "File written back to client.... ");
op.close();
in.close();
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e.getMessage());
}
return ResponseCodes.OBEX_HTTP_OK;
}
public static void main(String args[]) throws IOException
{
FTServer server = new FTServer();
LocalDevice localDevice = LocalDevice.getLocalDevice();
SessionNotifier sn = (SessionNotifier)Connector.open("btgoep://localhost:1106;name=FTP");
System.out.println("Waiting for a client connection.... . ");
sn.acceptAndOpen(server);
System.out.println("A Client now connected.... ");
}
}وعند التجميع يظهر لي هذا الخلل
Project settings saved Building "B1" Build complete Running with storage root SonyEricsson_K750_Emu Unable to create MIDlet FTServer java.lang.InstantiationException: Class not a MIDlet at com.sun.midp.midlet.MIDletState.createMIDlet(+51) at com.sun.midp.midlet.Selector.run(+22) Execution completed. 0 bytecodes executed 0 thread switches 781 classes in the system (including system classes) 0 dynamic objects allocated (0 bytes) 0 garbage collections (0 bytes collected)
فما المشكلة؟