0

I'm migrating from .net to java and I'm not yet used in java application deployment. I'm used in deploying console base application that acts as a stand alone application , a mixed of tcp and udp servers with custom protocol.

I have a requirement that my ported .net application to java must be deployed inside tomcat or glass fish ( no embedding stuff ). I really don't know what technology I must used. I've been searching the net but my understanding is that tomcat is like IIS and for web application only and glass fish is somewhat an application server for hosting web application too. Can I really run my java console base application inside tomcat or glass fish? Can someone point out a good tutorials for this kind of stuff? Thanks!

EDIT 1 Ok got the reason why I need to deploy my app in tomcat/glassfish. I need to provide a web ui for my application since I'm currently using the console for user input. Now my application will not just support a custom tcp/udp server inside but also web functionality for management. Any suggestion how I can implement this is greatly appreciated, I just don't know yet what java api/technology to start with.

powerbox
  • 271
  • 4
  • 18
  • So you use the console for user input? – home Sep 24 '11 at 13:13
  • Currently I'm using console for user input just for simple manipulation of my configuration file. But now that my objective is to be able to deploy my app in tomcat/glassfish then I might as well use a web ui for communicating with my app. – powerbox Sep 25 '11 at 05:33
  • I've been researching alot for this stuff again check this [post][1] [1]: http://stackoverflow.com/questions/791986/background-thread-for-a-tomcat-servlet-app – powerbox Sep 27 '11 at 09:59

1 Answers1

0

I am not sure why your requirement says that you need to run an application using a servlet container . I don't think at least based on your description your application fits servlet container programming model.

As long as you create an entry point, I think you can launch your application from command line either using java or javaw,

But If you are unable to change the requirement on the deployment to tomcat, You can do this by using a servlet to launch your application, I would read up on these things

Here is one way you could do using a servlet and deploy this to tomcat

  public class LaunchServlet extends HttpServlet
  {
    private static final long serialVersionUID = 4277145689972356257L;
        //this method is run as tomcat starts up this servlet
    public void init() throws ServletException
   {
        try
        {
            System.out.println("Launching my application...");
            new Thread(new ApplicationLauncher()).start();
            System.out.println("Launched my application successfully. ");
        }
        catch(Exception e)
        {
           throw new RuntimeException("Fail Fast: Unable to launch exception.");
        }
    }

      class ApplicationLauncher implements Runnable
      {
      public void run()
       {
              //start you applicaton here
        }

      }

    }
Prasanna Talakanti
  • 2,294
  • 1
  • 15
  • 14
  • If my going to do this then I need to manage my application main thread since I doubt tomcat/glassfish knows about it. – powerbox Sep 25 '11 at 05:36