Profiling Java Apps Using Bundled Tools

Background

Lately I have found myself playing with a lot of Applications that are running inside Java’s JVM.

The responsible next step is to start profiling their consumption patterns.

 

Referenced Work

These days most of my work are begun from a Google Search.

This work started from Karun Subramanian’s well thought effort.

Here are his blog posts:

  1. 5 not so easy ways to monitor the Heap Usage of your Java Application
    Link

 

Constraints

The tools that we will be evaluating have the following constraints:

  1. They should be run under the same account as the Java Processes that will be monitored

 

Tools

In this exercise we will look at our tools from the prism of Interface; Command Line  Interface ( CLI ) or Graphical User Interface.

Outline

  1. Interface
    • Command Line Tools ( CLI )
      • jstat
      • jmap
    • GUI
      • visualvm
      • jconsole

Preparation

jps

Outline

jps is analogous to the ps command in Linux.

While ps list all processes; jps lists all running Java Processes.

 

Syntax


jps

 

Sample


jps | find /I /V "Jps"

 

Output

 

Explanation

  1. The first column is the LVMDID ( process ID)
  2. The second column is the Process Name

 

Command Line Interface ( CLI )

jstat

Artifacts

Upon installing Java’s JDK, jstat is available in the JDK’s HOME bin folder.

Code

syntax

jstat -gc [process-id]

Sample

jstat -gc 13800

Output

jstat_20180811_0913AM

Explanation
Column Meaning Sample
EC Eden Capacity (KB) 69952
EU Eden Space Utilization (KB) 19112.8
OU Old Space Utilization (KB) 120747.8
OC Old Space Capacity (KB) 174784.0

jmap

Artifacts

jmap is available in the JDK’s HOME bin folder.

Code

syntax

jmap -heap [process-id]

Sample

jmap -heap 13800

Output

es.20180811.0943AM

Explanation
Attribute Meaning Sample
MaxHeapSize Maximum Heap Size 256 MB
NewSize Eden Space Utilization 85 MB
MaxNewSize Eden Space Capacity 85 MB
OldSize Old Space Utilization 170 MB

jhsdb

Artifacts

From Java JDK v9, jhsdb is available in the JDK’s HOME bin folder.

Code

syntax

jhsdb jmap -heap --pid [process-id]

Sample

jhsdb jmap --heap --pid 1960

Output

Explanation
Attribute Meaning Sample
G1
Regions 2020
Capacity 2020 MB ( 2 GB )
Used 98 MB
Free 1921 MB ( 1.92 GB)
Used % 4.90%
G1 – Eden Space
Regions 62
Capacity 74 MB
Used 62 MB
Free 12 MB
Used % 83.78%
G1 – Survivor Space
Regions 4
Capacity 4 MB
Used 4 MB
Free 0
Used % 100 %
G1 Old Generation
Regions 34
Capacity 50 MB
Used 32 MB
Free 17 MB
Used % 65.79 %

 

Graphical User Interface ( GUI )

visualVM

Artifacts

Java Version
Java Version v1.8 and Before

Up to Java v1.8 Visual M was bundled with Java JDK.

Once Java’s JDK is installed, please access visualvm.exe from the JDK’s HOME bin folder.

Java Version  9 and Above

Please download VisualVM from here.

Extract the zip file and run visualvm.exe from the bin folder.

Visual

Tab – Overview
Image

es_Tab_Overview_20180811_1004AM.PNG

Textual
  1. JDK
    1. Bitness :- x64
    2. v1.8
  2. JVM Arguments
    • -XX:+UseConcMarkSweepGC
      • Garbage Collection Algorithm
      • Web Links
    • HeapDumpPath = data
    • ErrorFile :- logs/hs_err_pid%p.log
Tab – Monitor
Image

es_Tab_Monitor_20180811_1005AM.PNG

Textual
  1. Heap
    • Max :- 256 MB
    • In use :-  120 MB

 

Tab – Threads
Image

es_Tab_Threads_20180811_1004AM

 

jconsole

Artifacts

JDK is accessible from the bin folder of Java’s JDK HOME folder.

Visual

Tab – Overview
Image

jconsole_Tab_Overview_20180811_1121AM

Textual
  1. Heap Memory Usage :- 137 MB
  2. Live Threads :- 60
  3. Classes :- 16,000
Tab – Memory
Image

jconsole_Tab_Memory_20180811_1112AM

Textual
  1. Used :- 156 MB
  2. Committed :- 256 MB

 

Tab – Threads
Image

jconsole_Tab_Threads_20180811_1128AM

Textual
  1. Live Threads :- 60
  2. Peak :- 63

 

 

References

  • Oracle
    • Home / Java / Oracle JDK 9 Documentation
      • Java Platform, Standard Edition Tools Reference
    • Java
      • jps
        • jps – Java Virtual Machine Process Status Tool
          Link
  • Karun Subramanian
    • 5 not so easy ways to monitor the Heap Usage of your Java Application
      Link
  • Dustin Marx
    • Dzone
      • jhsdb: A New Tool for JDK 9
        Link

Logstash – Error – ” Unrecognized VM option ‘UseParNewGC’ “

Background

During my initial evaluation of Logstash ran into an easy to address error.

Reproduce

Invoke

The invocation is straight forward


set "_binfolder=C:\Downloads\Elastic\Logstash\v6.3.2\extract\bin"
set "_configuration=stackOverflow2010.User.conf"

call %_binfolder%\logstashImpl.bat -f %_configuration%

Output

Image

UseParNewGC_20180802_0334PM

Textual


Unrecognized VM option 'UseParNewGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Troubleshooting

Java

Java Version

Outline

We can request the version Number for the java runtime executable, java.exe.

Script


java -version

Output

Image

java_version_20180808_0332PM

Textual


java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

Knowledge Base ( KB)

Googled on the the term and got a good hit

  1. [META] Java 10 Support #9345
    • Opened By :- andrewvc
    • Date Opened :- 2018-April-9th
    • Link
      Link
    • Resolution
      • Resolution #1
        • By :- Armin Braun ( original-brownbear )
        • Web Links
        • Workaround :- Currently there is no temporary fix sorry. Switching to Java 8 is the only stable solution for the time being.
      • Resolution #2
        • By :- Josh Daone ( JoshDaone )
        • Web Links
        • Workaround :- @original-brownbear thanks! Switched back to openjdk-8-jre and working properly.

Resolution

Target Specific Java Version

Objective

Rather than rely on Java that is referenced in our path, we will set the environment variable JAVA_HOME to a pre-v10 Version.

Review Installed Java

Launched Windows explorer and access the “C:\Program Files\Java” folder.

Review Java Folders

java_explorer_20180808_0424PM

Code


set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181"

Additional Reading

  1. Andy Luis
    • mpvjava
      • JDK 9 Migration : 5 point checklist for Garbage Collection
        Link
      • About
        Link
  2.  OpenJDK
    • JEP 214: Remove GC Combinations Deprecated in JDK 8
      Link
  3. ORACLE
    • JDK 9 Release Notes – Removed APIs, Features, and Options
      Link

 

Dedicated

Dedicated to Armin Braun ( original-brownbear )
Less Talking … More Coding …

References

  1. Elastic
    • elastic/logstash
      [META] Java 10 Support #9345
      Link

ElasticSearch (v6) – Installation ( on Windows )

Background

Trying to review ElasticSearch.

Our choices is to search the Net for Web Hosting Services that avail it or “Install it locally“.

Installation Material Choices

There are a couple of options for installing ElasticSearch on MS Windows.

ElasticSearch is packaged via zip and MSI.

If you will like to install to run it as a Windows Service and have it registered as a Windows Program, please choose the MSI route.

If you will to simply test things out, please proceed down the ZIP path, extract it, and run it from the command line, please choose the ZIP package.

Installation Material Location

The Install Materials are available here.

Installation Choice

We chose to go down the MSI Package.

Prerequisite

The lone Prerequisite is Java’s JDK.

Java’s JDK

Version

Our targeted ElasticSearch’s Version is 6.

That minimum supported version is JDK 9.  As JDK 10 is now available and supported by ES 6, we chose to go with JDK 10.

Installed Vejava_version_20180729_0123AM.PNGrsion

To determine the Version of Java JDK installed, please launch a command prompt and run java passing along the -version option.

Code


java -version

Output

java_version_20180729_1258AM.PNG

Explanation

We can see that java JDK is not installed.

Download Location

JDK v10 is available here.

installMaterial_20180729_0102AM

Installing

GUI

Welcome

welcome_20180729_0107AM.PNG

Options
Options – Before

optionalFeatures_20180729_0108AM.PNG

Options – After

Changed Install Location from C:\Program Files\Java\jdk-10.0.2\ to E:\Program Files\Java\jdk-10.0.2\

optionalFeatures_20180729_0109AM.PNG

Status
Status -1

status_20180729_0109AM.PNG

Status -2

successfullyInstalled_20180729_0120AM.PNG

Complete

status_20180729_0111AM.PNG

Validate Version

Let us go back and validate that we have the right Java Installed.

Code


java -version

Output

java_version_20180729_0123AM.PNG

Explanation

Confirmed that we Java JDK 10.0.2 installed.

Bitness is 64-Bit.

Install Elastic Search…

GUI

Locations

Locations – Original

locations_20180729_0124AM.PNG

Locations – Create Folder

We don’t want to target the system drive and thus will create folders on another drive; in our case drive E:


setlocal 

set "_base=E:\Program Files\Elastic\Elasticsearch\6.3.2"

if not exist "%_base%\data" mkdir "%_base%\data"

if not exist "%_base%\config" mkdir "%_base%\config"

if not exist "%_base%\logs" mkdir "%_base%\logs"

endlocal
<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>

Locations – Revised

locations_20180729_0134AM.PNG

 

Services

Revised

Have the following:

  1. Account Information from Local System to Network Service
  2. Chose to have Service start upon completion of Installation
  3. Opted not to have Service automatically during OS Starts

Service_20180729_0135AM.PNG

Configuration

Original

Configuration_20180729_0136AM.PNG

Revised

Have the following:

  1. Changed Memory  from 2 GB to 256 MB
  2. Opted not to have “Lock JVM memory

Configuration_20180729_0137AM.PNG

 

Plugins

Original

plugins_20180729_0138AM.PNG

 

Revised

Chose to enable the following plugins:

  1. Ingest Attachment Processor
  2. Ingest GeoIP Processor
  3. Store SMB
Revised -01
  1. plugins_20180729_0147AM_A.PNG
Revised -02

plugins_20180729_0147AM_B.PNG

XPack

Chose to enable the following plugins:

  1. License :- BASIC

XPack_20180729_0148AM.PNG

 

Installing

Installing – 01

Installing_20180729_0149AM.PNG

 

Installing – “Downloading Plugins….”

Installing_Plugins_20180729_0151AM.PNG

Installing – “Downloading Plugins…store-smb”

Installing_Plugins_StoreSMB_20180729_0151AM.PNG

 

Start Elasticsearch Service

startingService_20180729_0152AM.PNG

 

Installed Successful

ElasticSearchInstalledSuccessfully_20180729_0153AM.PNG

Validation

Launch a browser and access the following URL http://localhost:9200

Image

browser_20180729_0154AM.PNG

Explanation

  1. Version
    • number :- 6.3.2
    • Build Date :- 2018-07-20
  2. Lucene Version
    • 7.3.1

 

References

  1. Elastic
    • Installation
      • Elasticsearch Reference [6.3] » Set up Elasticsearch » Installing Elasticsearch » Install Elasticsearch with Windows MSI Installer
        Link
      • Elasticsearch Reference [2.4] » Getting Started » Installation
        Link
    • Artifacts
      • Download ElasticSearch
        Link
    • Plugin
      • Store SMB
        • Store SMB Plugin
          Link
        • Elasticsearch Plugins and Integrations [6.3] » Store Plugins » Store SMB Plugin » Working around a bug in Windows SMB and Java on windows
          Link
  2. Apache.Org
    • Issues
      • Lucene – CoreLUCENE-6176
        • Modify FSIndexOutput in FSDirectory to open output steam for Write and Read
          Link

 

WebSphere/Liberty :- Reading data file

Background

Having to read a data file and wanted to see the options available.

Let us go over some of those options.

Option

  1. API :- File / File Reader
    • Location
      • File System
        • Sample
          • /home/
          • /WEB-INF/datafile/dbo.users.txt
  2. API :- classLoader.getResourceAsStream
    • Location
      • File System
        • relative to class path
        • Sample
          • \datafile\dbo.users.txt

Packaging

Using https://extract.me/, an online WAR file extractor we can visualize our targeted layout.

Image

rearfileDOTwar_20180724__20180724__0827PM

Explanation

  1. WEB-INF
    • Artifacts
      • Read Method
        • API :- File
      • Sample
        • datafile
          • dbo.users.txt
    • Java Classes
      • Read Method
        • API :- Class Loader
      • Sample
        • datafile
          • dbo.users.txt

Configuration

The location of our file can be saved in various locations.

web.xml

In our case we will save in the web.xml file.

Image

webDOTxml_20180724_0402PM.png

Source

Read web.xml and get servlet parameters


 private void getDataFilePath
(
    PrintWriter out
)
{

    ServletConfig config;

    config = getServletConfig();

    String initparamValue;      

    Enumeration enumeration = null;

    String parm;

    enumeration = getInitParameterNames();

    while (enumeration.hasMoreElements())
    {
        parm = enumeration.nextElement();

        strLog = parm
                    + " "
                    + getInitParameter(parm)
                    + ""
                    ;

        out.println(strLog);

    }

    //datafileOS
    initparamValue = config.getInitParameter
                        ("datafileOS");

    strDatafileOS = initparamValue;

    //datafileResource
    initparamValue = config.getInitParameter
                        ("datafileResource");

    strDatafileResource
        = config.getServletContext().getRealPath(initparamValue);

    //datafileOS
    initparamValue = config.getInitParameter
                        ("datafileClass");

    strDatafileClass = initparamValue;

}   

Reading Text File through File API


private BufferedReader getBufferedReaderUsingTraditionalMethod
(
      String strDatafile
    , PrintWriter out
)
{

    BufferedReader bufferedReaderLocal = null;

    try
    {   

        file = new File(strDatafile);

        if (file != null)
        {

            fileReader = new FileReader(file);

            bufferedReaderLocal = new BufferedReader(fileReader);

        }
    }
    catch (Exception ex)
    {

        ex.printStackTrace();

        System.out.println(ex.getMessage());

    }

    return(bufferedReaderLocal);

}

Reading as Class File


private BufferedReader getBufferedReaderUsingClassLoader
(
	  String strDatafile
	, PrintWriter out
)
{

	BufferedReader bufferedReaderLocal = null;

	try
	{

		classLoader = getClass().getClassLoader();

		objInputStream = classLoader.getResourceAsStream(strDatafile);

		if (objInputStream == null)
		{

			return (bufferedReaderLocal);

		}
		else
		{	

			bufferedReaderLocal = new BufferedReader
				(
					new InputStreamReader(objInputStream)
				);

		}

	}
	catch (Exception ex)
	{

		ex.printStackTrace();

		System.out.println(ex.getMessage());

		out.println(ex.getMessage());

	}

	return (bufferedReaderLocal);

} 	

Read data file


private void readDatafile(PrintWriter out )
{

    BufferedReader bufferedReader = null;

    StringBuffer stringBuffer = null;
    String line;
    long lNumberofRecordsRead = 0;

    Collection objListDisplayName = new ArrayList();    

    try
    {

        strDatafile = strDatafileOS;

        // Read OS File
        bufferedReader = getBufferedReaderUsingTraditionalMethod
                         (
                              strDatafile
                            , out
                         );

        // If unable to read OS File
        // read data file from web.inf/
        if (bufferedReader == null)
        {

            strDatafile = strDatafileResource;

            bufferedReader = getBufferedReaderUsingTraditionalMethod
                                (
                                      strDatafile
                                    , out
                                );

        }

        //servlet class file
        if (bufferedReader == null)
        {

            strDatafile = strDatafileClass;

            bufferedReader = getBufferedReaderUsingClassLoader
                                (
                                      strDatafile
                                    , out
                                );

        }           

        if (bufferedReader == null)
        {
            return;
        }

        stringBuffer = new StringBuffer();

        while ((line = bufferedReader.readLine()) != null)
        {

            objListDisplayName.add(line);

            lNumberofRecordsRead = lNumberofRecordsRead + 1;

        }

        if (fileReader != null)
        {
            fileReader.close();
        }

        if ( classLoader != null)
        {
            classLoader = null;
        }

        if (objInputStream != null)
        {
            objInputStream = null;
        }

        if (bDebug)
        {
            strData = lNumberofRecordsRead
                        + " record(s) read";

            out.println(strData);

        }

    }
    catch (IOException ex)
    {

        ex.printStackTrace();

        System.out.println(ex.getMessage());

        out.println(ex.getMessage());

    }

}

DisplayReadFile

private void displayReadFile(PrintWriter out )
{

    long i = 0;

    iterator = objListDisplayName.iterator();

    String strData;

    strData = "";

    out.println(strData);

    // while loop
    while (iterator.hasNext())
    {

        i = i + 1;

        strData = "
                    + iterator.next()
                    + ""
                    ;

        out.println(strData);

        if (i == 6)
        {
            break;
        }

    }

}

Source Code

DanielAdeniji/javaReadFileText
Link

Dedicated

Dedicated to Ivan S. & Joe L.

I was really struggling with this.

But, these brothers wrestled with me and made sure I did not get it wrong.

And, so here is gratitude for brothers who take time and think we deserve better; especially when we clearly don’t.

Ivan S.

ivanS_20180724_0456PM

WebSphere Liberty :- Simple Servlet ( DB )

 

Preparation

WebSphere / Liberty

Java Database Connectivity ( JDBC )

Download

Download JDBC Driver from your Database Software provider.

For us Microsoft, and we get the JDBC Driver from here :-

Docs / SQL / Connect your client to SQL / JDBC
Download Microsoft JDBC Driver for SQL Server
Link

Configuration

Server.xml

Data Source

Outline
  1. Data Source
    • jndi
      • Unique name within each application
      • Will be referred to by the Application
      • Sample :- jdbc/inform
    • jdbcDriver
      • libraryRef
        • Sample :- MSJDBCLib
    • properties.microsoft.sqlserver
      • serverName=”localhost”
      • portNumber=”1433″
      • databaseName=”StackOverflow2010″
      • user=”stackoverflow”
      • password=”password”
  2. Library
    • id
      • Sample :- MSJDBCLib
      • file name :- C:\Downloads\Microsoft\Java\jdbc\v6.0.8112.200\extract\sqljdbc_6.0\enu\jre8\sqljdbc42.jar
Sample
Image

serverDotxml_20180723_0819AM

 

Code

	<dataSource
		id="jdbc/inform"
		jndiName="jdbc/inform"
	>
		<jdbcDriver
			libraryRef="MSJDBCLib"
		/>

		<properties.microsoft.sqlserver
			serverName="localhost"
			portNumber="1433"
			databaseName="StackOverflow2010"
			user="stackoverflow"
			password="hIy8jA2lNl"
		/>

	</dataSource>

	<library id="MSJDBCLib">
		<file
			name="C:\Downloads\Microsoft\Java\jdbc\v6.0.8112.200\extract\sqljdbc_6.0\enu\jre8\sqljdbc42.jar"
		/>
	</library>

Code

Outline

  1. table.java
    • java source code
  2. compileDBInform.cmd
    • Command file for compiling Java Source Code
  3. web.xml
    • web.xml file
  4.  packageDBInform.cmd
    • Package java class files into War file
  5. deployDBInform.cmd
    • Copyy War file unto WebSphere Server dropins folder

Source Code

table.java


package dbInform;

import java.io.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.annotation.Resource;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;

import javax.sql.DataSource;

import javax.naming.*;

public class table
    extends HttpServlet
{

    private static final long serialVersionUID = 1L;

    private DataSource objDS;
    private Connection objDBConn = null;

    private static final String DB = "jdbc/inform";  

    private static final String QUERY_TABLE
        = "select * "
            + " from INFORMATION_SCHEMA.TABLES tblIST "
            + " order by TABLE_SCHEMA, TABLE_NAME"
            ;

    private String strData;
    private String strRow;

    private String strBGColor = "";
    private int    iRowNumber = 0;

    private String TR_COLUMN_EVEN = " bgcolor = '#AF601A'";
    private String TR_COLUMN_ODD = " bgcolor = '#1D8348'";

    private String strTableSchema;
    private String strTableName;
    private String strTableType; 

    public table()
    {
        super();
    }
    public void doGet
    (
          HttpServletRequest request
        , HttpServletResponse response
    )
        throws
               ServletException
             , IOException
    {

        response.setContentType("text/html");

        PrintWriter out = response.getWriter();

        out.println("
<H1>Inform.table</H1>

\n");

        try
        {

            Context objCTX = new InitialContext();

            Object obj = null;

            obj = objCTX.lookup
                    (
                        DB
                    );

            objDS = (DataSource) obj;

            objDBConn = objDS.getConnection();

            Statement stmt = null;

            stmt = objDBConn.createStatement();

            ResultSet rs = stmt.executeQuery
                            (
                                QUERY_TABLE
                            );

            out.println("
<TABLE BORDER="1" WIDTH='80%'>");    

            strData =
                          "
<TH>" + "SCHEMA" + "</TH>

"
                        + "
<TH>" + "TABLE" + "</TH>

"
                        + "
<TH>" + "TYPE" + "</TH>

"
                  ;

        strRow = "
<TR>" + strData + "</TH>

";

        out.println(strRow);

       while (rs.next())
       {

            iRowNumber = iRowNumber + 1;

            if ((iRowNumber %2) == 0)
            {
                strBGColor = TR_COLUMN_EVEN;
            }
            else
            {
                strBGColor = TR_COLUMN_ODD;
            }

            strTableSchema = rs.getString("TABLE_SCHEMA");
            strTableName = rs.getString("TABLE_NAME");
            strTableType = rs.getString("TABLE_TYPE");

            strData =
                        "
<TD>" + strTableSchema + "</TD>

"
                      + "
<TD>" + strTableName + "</TD>

"
                      + "
<TD>" + strTableType + "</TD>

"

                      ;

            strRow = "<TR>"
                        + strData
                        + "</TR>

";

            out.println(strRow);

        }

       out.println("</TABLE>

"); 

    }
    catch (SQLException e)
    {
       e.printStackTrace();
    }
    catch (NamingException e)
    {
       e.printStackTrace();
    }
    finally
    {

       if (objDBConn != null)
       {
            try
            {
                objDBConn.close();
            }
            catch (SQLException e)
            {
                e.printStackTrace();
            } 

           }
       }
    }
}

Compile Java Source Code

compileDBInform.cmd


setlocal

set "_folderCompiler=C:\Program Files\Java\jdk-10.0.2\bin"

set "_relVer=8"

set "_relTag= --release %_relVer%"

set "_folderJar=C:\IBM\WebSphere\Liberty\v18.0.0.2\extract\\wlp\dev\api\spec"

set "_fileServlet=com.ibm.websphere.javaee.servlet.3.1_1.0.21.jar"

set "_fileAnnotation=com.ibm.websphere.javaee.annotation.1.3_1.0.21.jar"

set "_folderDeploy=C:\IBM\WebSphere\Liberty\v18.0.0.2\extract\wlp\usr\servers\defaultServer\dropins"

set "_targetFolder=WEB-INF\classes"

"%_folderCompiler%\javac" -cp %_folderJar%\%_fileServlet%;%_folderJar%\%_fileAnnotation%  %_relTag% -d %_targetFolder% table.java

endlocal

Configuration Files

xml.web

Image

webDotxml_20180723_0813AM

Code


<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>
        DBInform
    </display-name>

    <description>
    Simple Application that shows database schema via INFORMATION_SCHEMA.
    </description>

    <!--
        dbInformTable
            dbInform.table
    -->
    <servlet>
        <servlet-name>table</servlet-name>
        <servlet-class>dbInform.table</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>table</servlet-name>
        <url-pattern>/table</url-pattern>
    </servlet-mapping>

</web-app>

Package

packageDBInform.cmd


setlocal

set "_folderCompiler=C:\Program Files\Java\jdk-10.0.2\bin"
set "_targetFolder=WEB-INF\classes\"

"%_folderCompiler%\jar" cvf dbInform.war WEB-INF\web.xml %_targetFolder%\dbInform\table.class

endlocal

Deploy WAR File

deployDBInform.cmd


setlocal

set "_folderBase=C:\IBM\WebSphere\Liberty\v18.0.0.2\extract\wlp\usr\servers\defaultServer\dropins"

echo F | xcopy dbInform.war %_folderBase%\dbInform.war /d /Y /Q 

endlocal

Browser

Launched browser and pointed it at ( https://localhost:9443/dbInform/table )

and we got a list of the tables in our database.

dbInform_table_20180722_1054PM

Source Code Control

Github

DanielAdeniji/javaDBInform
link