Class JKWebApplication

java.lang.Object
com.jk.web.embedded.JKWebApplication

public class JKWebApplication extends Object
This class provides utility methods for running a web application using Apache Tomcat.

It allows you to start a web server, specify the port, and optionally open a browser.

Version:
1.0.
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    This method closes any existing instance of the web server running on the default port.
    static void
    closeInstance(int portNumber)
    This method closes any existing instance of the web server running on the specified port.
    protected static int
    getClosePortDeamon(int portNumber)
    This method gets the port number for closing the web server instance (daemon port).
    static int
    This method gets the port number for the web server from configuration.
    static void
    run()
    This method starts the web server with the default port and opens a web browser.
    static void
    run(int portNumber)
    This method starts the web server with the specified port and opens a web browser.
    static void
    run(int portNumber, boolean autoOpenBrowser)
    This method starts the web server with the specified port and optionally opens a web browser.
    static void
    run(int portNumber, boolean autoOpenBrowser, String context)
    This method starts the web server with the specified port, optionally opens a web browser, and sets a custom context path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JKWebApplication

      public JKWebApplication()
  • Method Details

    • run

      public static void run()
      This method starts the web server with the default port and opens a web browser.
    • run

      public static void run(int portNumber)
      This method starts the web server with the specified port and opens a web browser.
      Parameters:
      portNumber - Specifies the port number on which the web server will listen.
    • run

      public static void run(int portNumber, boolean autoOpenBrowser)
      This method starts the web server with the specified port and optionally opens a web browser.
      Parameters:
      portNumber - Specifies the port number on which the web server will listen.
      autoOpenBrowser - Indicates whether to automatically open a web browser.
    • run

      public static void run(int portNumber, boolean autoOpenBrowser, String context)
      This method starts the web server with the specified port, optionally opens a web browser, and sets a custom context path.
      Parameters:
      portNumber - Specifies the port number on which the web server will listen.
      autoOpenBrowser - Indicates whether to automatically open a web browser.
      context - Specifies the custom context path for the web application.
    • closeInstance

      public static void closeInstance()
      This method closes any existing instance of the web server running on the default port.
    • closeInstance

      public static void closeInstance(int portNumber)
      This method closes any existing instance of the web server running on the specified port.
      Parameters:
      portNumber - Specifies the port number of the web server to close.
    • getClosePortDeamon

      protected static int getClosePortDeamon(int portNumber)
      This method gets the port number for closing the web server instance (daemon port).
      Parameters:
      portNumber - Specifies the main port number.
      Returns:
      the port number for closing the web server instance.
    • getDefaultPort

      public static int getDefaultPort()
      This method gets the port number for the web server from configuration.
      Returns:
      the default port number if not configured.