Results 1 to 3 of 3

Thread: Applet fails to start server from webbrowser

Threaded View

  1. #1
    Join Date
    Oct 2007
    Location
    Melbourne, Australia
    Beans
    101
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Applet fails to start server from webbrowser

    Hi all

    My applet connects to a local server. If not found, it loads the server and retries the connection.

    "java class" runs fine, but running in a browser using html fails to load server. html works fine if server is already running.

    I am using the Runtime class to start the server. Dont know if there is a recommended way of doing this


    My client code and html is attached

    Snippet to start server

    Code:
    SocketAddress sa;
            while(starting){
    try{            link= new Socket("localhost",PORT);
                    ta.append("Server connect on port "+PORT+"\n");
                    starting=false;
    }catch (Exception e){
                    ta.append("Server not found\n");
                    ta.append("Error: "+e+"\n");
                    cnt++; if(cnt==3)return;
    try{            ta.append("Starting Server\n");
                    Runtime rt=Runtime.getRuntime();
                    Process proc=rt.exec("java Misam");
    try{            Thread.sleep(1000);
    }catch (InterruptedException ie){ta.append(ie.getMessage()+"\n");}
    }catch (Throwable t){ ta.append("Server started\n");}
                    }
    Last edited by bcz; February 16th, 2011 at 01:39 AM. Reason: Use code tags, attach files which got lost

Tags for this Thread

Bookmarks

Posting Permissions

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