Discussion Board

Results 1 to 3 of 3

Thread: need help

  1. #1
    Registered User
    Join Date
    Feb 2010

    need help

    dear sir
    i have this part of a code that a mobile send input coordinate (startx and starty) to a server using socket
    how can i modify it so that the line in main class

    will display the sended value
    and how to modify the socket code in order to send image from server to mobile
    with best regard

    public class test extends Component {

    public static void main(String args[]) {

    public static void connect() {
    try {
    System.out.println("S: Connecting...");
    ServerSocket serverSocket = new ServerSocket(12344);
    toClient = serverSocket.accept();
    System.out.println("S: Connected");
    Thread desktopServerThread = new Thread(){
    public void run(){
    try {
    in= new BufferedReader(new InputStreamReader(toClient.getInputStream()));
    String str;
    if (!(str=in.readLine()).equals("") | !str.equals(" "))
    System.out.println("C: '" + str);
    int b = str.indexOf('d');
    String startpt = str.substring(1, b);
    int bbb=startpt.indexOf(',');
    String bx = startpt.substring(0, bbb);
    String by = startpt.substring(bbb+1);
    String destpt = str.substring(b+1);
    System.out.println("Sending Message Succesful"+" s "+startpt+" d "+destpt);
    System.out.println("xx "+startx+" yy "+starty);
    } catch(Exception e) {
    System.out.println("S: Error");
    } catch (Exception e) {
    System.out.println("S: Connection Error");

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    The Capital of INDIA

    Re: need help

    I wonder if you are writing the Java ME code.So I am not sure that what are you actually trying to do??

    You can check if this helps you, please create the instance of the class that you have declared inside the main() and then you can call that connect() method inside the constructor of the class.

    This is basic thing in core java.Please read the basics in much more details.
    Thanks with Regards,

    R a j - The K e r n e l

    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Super Contributor
    Join Date
    Apr 2007

    Re: need help

    actually I don't see a startApp method or anything like that except from the main method, which is typical for "normal" java but not for J2ME...
    So I am guessing this is no MIDlet at all...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts