开发者

Deploying Terminal Base Java Application

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 mus开发者_开发百科t 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.


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

  • Servlet
  • Deploying Servlet to tomcat

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
        }

      }

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜