Menu

Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

How to store multiple values for a key into Map using JAVA

Today we will practice a program to assign or set multiple values or list of values or ArrayList for a key in Map. And also how to iterate on that map and find the value from the list of values.

Declare a Map, with a string or integer key and list or ArrayList type of value; as given in below code in line 10. In this Map, you can store a single value as a key and a list of values you could store into that key in form of a list or array list.
Line 10: Map<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
In line 12 we are creating an ArrayList in which we will store the list of values and we will put this list into Map.
Line 12: ArrayList<String> list = new ArrayList<String>();
Later in line 13 and 14, we are adding values in ArrayList.
Line 13 and 14: list.add("A"+i);
                          list.add("B"+i);
On top of this ArrayList we have created a for loop which will help us to create the pair of 10 unique values of key and value and mapped and put those values into the map.

Line 15 of the code is to put a pair of key and value into a map.
Line 15: map.put("index"+i, list);
We have completed the creation of map. Now we will see how to iterate through the map and pull a particular key or value. or how to find a value into map? or how to find a matching value from a list stored into a map?
To iterate on map first we have to create an object of Entry class with the help of Map and entrySet(). Below is the foreach loop using that we can iterate on all keys of the map.  
Line 19: for(Map.Entry<String, ArrayList<String>> entry : map.entrySet())
Now using the entry object we can pull the key and values of the current iteration index. Below are the codes to getKey() and getValue() from the map. Line 20 of the code will return the value stored as a key, and line 21 will return a list of values stored into the value of the map of the current index.
Line 20: String key = entry.getKey();Line 21: ArrayList<String> value = entry.getValue();
To find a value from map or the list of values stored into the map we will use the matches() method and using regex we could find the matching values at the specified index. In line 23 of the code, we are searching a value B5 which we have stored in the list of values. If we have a list of values then we have to specify the index number using get(index) in which method matches() will search for the requested value.
Line 23: if(entry.getValue().get(1).matches("B5")) 
To search a value from simple key-value pairs of map then we could simply write the above line without get() method. e.g. if(entry.getValue().matches("B5")) and in similar way you could find a key as well. e.g. if(entry.getKey().matches("index7"))

Below is the complete example code which you could directly copy and paste in your IDE and practice this exercise.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package rashidjorvee;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MultipleValuesInMap {

 public static void main(String[] args) {
  Map<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
  for(int i=1; i<=10; i++) {
   ArrayList<String> list = new ArrayList<String>();
   list.add("A"+i);
   list.add("B"+i);
   map.put("index"+i, list);
  }

  System.out.println(map);
  for(Map.Entry<String, ArrayList<String>> entry : map.entrySet()) {
   String key = entry.getKey();
   ArrayList<String> value = entry.getValue();
   //System.out.println(value.get(1).matches("(?i)b2|B3|B4"));
   if(entry.getValue().get(1).matches("B5")) {
    System.out.println(entry.getKey() +" " +entry.getValue().get(0) +" " +entry.getValue().get(1));
   }
  }
  System.out.println(map.size());

 }

}

Error: Could not find or load main class

If you are getting the error Error: Could not find or load main class when you try to run any java program in using eclipse then you could perform any of the following resolutions to fix the issue. If a single resolution doesn't work for you then perform the next solution which is given below.

1. Go to your project path for e.g. C:\Users\java\rashid\jorvee > open .classpath file and verify all the entries given in this file are actually exist in your system. Below is the sample file.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<?xml version="1.0" encoding="UTF-8"?>

<classpath>

 <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>

 <classpathentry kind="src" path="src"/>

 <classpathentry exported="true" kind="lib" path="C:/Users/java/rashid/java-json.jar/java-json.jar"/>

 <classpathentry kind="output" path="bin"/>

</classpath>

2. Go to run > run configuration > classpath> Select Project > Advance > select option add folder and select the bin folder where your .class file get stored.

3. There might be a possibility that there is no classpath set for java class files. Please go ahead and set classpath manually by executing the below command on cmd.
javac -cp . PackageName/*.java

4. In some cases we have found that Java build path is not set up for the project, or somehow it gets removed from the directory then go ahead and set your project classpath here. Add your project in the source tab and JRE in libraries tab.
Project > Properties > Java Build Path

Adobe Experience Manager for Content Author

Pass by reference and pass by value in Java

Today in this tutorial of Java program we will see how to work with pass by value and pass by reference. 

Below is code snippet.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

package com.rashid.jorvee;


public class ValueRef {

 public static void main(String[] args) {

  Employee emp=new Employee();

  ValueRef valref=new ValueRef();

  emp.setSalary(12000.00);

  System.out.println("Employee emp salary: " +emp.getSalary());

  valref.salary(emp);

 }

 public void salary(Employee em){

  em.setSalary(14000.00);

  em=new Employee();

  em.setSalary(15000.0);

  System.out.println("Employee em salary: " +em.getSalary());

 }

}



class Employee{

 double salary;

 public double getSalary() {

  return salary;

 }


 public void setSalary(double salary) {

  this.salary = salary;

 }
}

Output:
Employee emp salary: 12000.0
Employee em salary: 15000.0 

Working with list and arrayList in Java.

In this tutorial we will see a simple and small implementation of List and ArrayList using Java.

ArrayList is resize-able implementation is List type. Each ArrayList instance has a capacity. The capacity is the size of the array used to store the elements in the list. It is always at least as large as the list size. As elements are added to an ArrayList, its capacity grows automatically.

We are writing a program where we will add some values in the ArrayList and then we will iterate on that List and print the values on console.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
package rashid.jorvee;

import java.util.ArrayList;
import java.util.List;

public class ListImpl {

 public static void main(String[] args) {
  List list=new ArrayList();
  List newlist=new ArrayList();
  newlist.add("New Delhi");
  newlist.add("9999999");
  newlist.add("1212121");
  newlist.add("Rashid");
  newlist.add("Jorvee");
  for(int i=0;i<newlist.size();i++) {
   System.out.println("At Index "+i +" List has value "+newlist.get(i));
  }

 }

}
Output:
At Index 0 List has value New Delhi
At Index 1 List has value 9999999
At Index 2 List has value 1212121
At Index 3 List has value Rashid
At Index 4 List has value Jorvee

If else || nested if statement in JSTL

Today we will discuss about; how to write simple if else and nested if else statements in JSTL.

If you have to check only a single value then you can use if statement "<c:if>" in JSTL. But if you want to achieve nested if else then you have to use <c:when> and <c:otherwise>.

Will will see both if and nested if else in JSTL with an example.

To use the JSTL in your JSP file we have to first import the JSTL tag library in our JSP file. Below is the import statement to where we are importing JSTL core tag library in our JSP. Specify a prefix to this tag which we will prefix further with our tag.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
prefix="c" use c when you use JSTL tags in your JSP file.
e.g. <c:if>, <c:choose>

Suppose we have a variable name which have a name of an user. let see how will check this using if statement in jstl.
Using <c:set> tag we can declare and set value to a variable. In below statement we are declaring a variable name and assigning its value RASHID.
<c:set var=name value="RASHID">
Now see the if condition 
 <c:if test="${name == 'RASHID'}">
 <c:set var=age value=23 />
</c:if>
Now we will using nested if else how will check the value of variable name in jstl.
<c:choose>
         <c:when test = "${name == 'RASHID'}">
            HIS NAME IS RASHID.
         </c:when>
         <c:when test = "${name == 'Ranjan'}">
            HIS NAME IS Ranjan.
         </c:when>
         <c:otherwise>
            No machtes....
         </c:otherwise>
 </c:choose>
Hope this will help you to understand the if else and nested if else condition using JSTL. Do let me know if you have any question and suggestions. 

If else condition in shell script with $? and grep command

In shell script condition check is very easy and simple using if else statements. Here is a example which we would like to discuss with our readers.

Scenario: We have a variable that contains long string value, user wants to find matching value from given string and perform check whether that text/character has matched from string value or or not.


#Program in Bash Shell
Line 1: CHECK_SOURCE="[main] INFO com.adobe.jcr.checknode.existence - Node does not exist"
line 2: echo $CHECK_SOURCE | grep -w -o -i 'Node exists'
Line 3: if [ $? == 0 ]; then
Line 4:        echo " matched"
Line 5: else 
Line 6: echo "not matched" 
Line 7: fi 

Explanation:

In line 1 we have declared a variable CHECK_SOURCE which have some value.
In line 2 we are finding text "Node exists" in value of variable CHECK_SOURCE using grep command.
In line 3 using if statement we are checking number of matches from last executed statement. $? sign will return number of matches. If text passed in grep command will find some matching text in variable then $? will number of matching otherwise it will return zero. 



Import and Export Java project in a Zip file in Eclipse

Importing a Java Project from a Zip File into a Workspace

In the past, we have imported projects as JAR files into the src folder of an existing project. For this course, it will probably be easier to import projects directly into the workspace. This is especially true with shader programs since they often require additional text file resources (in our case, shader source code in simple text files) that we didn’t encounter in previous Java programs. When I create demo projects for you, I will often create them for you as zip files.

To import a Java project from a zip file into a workspace:

1. Open Eclipse and navigate to the workspace. To make life easier for us all, make that the workspace that includes your other JOGL projects.
2. Select File…Import…
3. Expand General, select Existing Projects into Workspace and click Next.
4. Click the Select archive file radio button and browse for the zip file containing the project.
5. Click Finish and the project should appear in your workspace. Note: Eclipse will not import a project if you already have one with the same name. If you still want to proceed, rename the existing one and try importing again.

Exporting a Java Project to a Zip File

If you want to export one of your projects to a zip file, do this:

1. Left-click the project name in Package Explorer that you want to export (For example, if the project is named ColorMixer, left-click on that name).
2. Select File…Export…
3. Expand General, select Archive File, and click Next.
4. In the Export dialog, make sure that your selected project is checked and that the options Save in zip format and Create directory structure for files are both selected.
5. Browse for a location to save the archive file. A zip extension will be added automatically.
6. Click Finish and your project should be saved as a zip file in the location you requested.

Google Analytics questions and answers for beginner

1. What would you use to compare two date ranges in a report?

  1. Hourly, Day, Week, Month views in the time graph
  2. Real-time reports
  3. Date range comparison
  4. Account selector

2. What does the “Users” metric measure?

  1. The total number of visits to your website
  2. Users that had at least one session on your site in the given date range
  3. Users that landed on the homepage of your website
  4. Users who have signed up to an email newsletter on your website

3. In Google Analytics, what is the “Bounce Rate”?

  1. The number of times unique users returned to your website in a given time period
  2. The percentage of sessions in which a user exits from your homepage
  3. The percentage of total site exits
  4. The percentage of visits when a user landed on your website and exited without any interactions

4. In Google Analytics, what is a “dimension”?

  1. The total amount of revenue a business has made in a given date range.
  2. An attribute of a data set that can be organized for better analysis.
  3. A comparison of data between two date ranges.
  4. A report that offers information about your audience.

5. In Google Analytics, what is a “metric”?

  1. A dimension that can help you analyze site performance.
  2. The dates in your date range.
  3. A segment of data separated out in a report for comparison.
  4. The numbers in a data set often paired with dimensions.

6. In Google Analytics, what is a “secondary dimension”?

  1. An additional widget you can add to a dashboard for more specific analysis.
  2. An additional metric you can add to a report for more specific analysis.
  3. An additional dimension you can add to a report for more specific analysis.
  4. A visualization that allows you to view understand the impact of your data.

7. If you wish to see if report data is performing above or below the website average, which Google Analytics visualization should you choose?

  1. Pivot view
  2. Comparison view
  3. Performance view
  4. Percentage view

8. How do you increase the amount of data in a sampled Google Analytics report?

  1. Choose “Greater precision” in the sampling pulldown menu
  2. Choose “Faster response” in the sampling pulldown menu
  3. Apply additional filters
  4. Remove the Secondary Dimension

9. By selecting “Share Template Link” you can share your dashboard and your data with another user.

  1. True
  2. False

10. If you share a dashboard with others, they can change the information that shows on their dashboard

  1. True
  2. False

Correct Answers:

1. Date range comparison
2. Users that had at least one session on your site in the given date range
3. The percentage of visits when a user landed on your website and exited without any interactions
4. An attribute of a data set that can be organized for better analysis.
5. The numbers in a data set often paired with dimensions.
6. An additional dimension you can add to a report for more specific analysis.
7. Comparison view
8. Choose “Greater precision” in the sampling pulldown menu
9. False
10. True

Running Apache Tomcat 8.5 Servlet/JSP Container

Apache Tomcat 8.5 requires a Java Standard Edition Runtime Environment (JRE) version 7 or later.

Running With JRE 7 Or Later


(1) Download and Install a Java SE Runtime Environment (JRE)


(1.1) Download a Java SE Runtime Environment (JRE), release version 7 or later, from       http://www.oracle.com/technetwork/java/javase/downloads/index.html

(1.2) Install the JRE according to the instructions included with the
      release.

      You may also use a full Java Development Kit (JDK) rather than just
      a JRE.


(2) Download and Install Apache Tomcat


(2.1) Download a binary distribution of Tomcat from:


(2.2) Unpack the binary distribution so that it resides in its own
      directory (conventionally named "apache-tomcat-[version]").

      For the purposes of the remainder of this document, the name
      "CATALINA_HOME" is used to refer to the full pathname of that
      directory.

NOTE:  As an alternative to downloading a binary distribution, you can create your own from the Tomcat source code, as described in "BUILDING.txt".  You can either

  a)  Do the full "release" build and find the created distribution in the
      "output/release" directory and then proceed with unpacking as above, or

  b)  Do a simple build and use the "output/build" directory as       "CATALINA_HOME".  Be warned that there are some differences between the contents of the "output/build" directory and a full "release" distribution.

(3) Configure Environment Variables


Tomcat is a Java application and does not use environment variables directly.
Environment variables are used by the Tomcat startup scripts. The scripts use
the environment variables to prepare the command that starts Tomcat.

(3.1) Set CATALINA_HOME (required) and CATALINA_BASE (optional)

The CATALINA_HOME environment variable should be set to the location of the
root directory of the "binary" distribution of Tomcat.

The Tomcat startup scripts have some logic to set this variable
automatically if it is absent, based on the location of the startup script
in *nix and on the current directory in Windows. That logic might not work
in all circumstances, so setting the variable explicitly is recommended.

The CATALINA_BASE environment variable specifies location of the root
directory of the "active configuration" of Tomcat. It is optional. It
defaults to be equal to CATALINA_HOME.

Using distinct values for the CATALINA_HOME and CATALINA_BASE variables is
recommended to simplify further upgrades and maintenance. It is documented
in the "Multiple Tomcat Instances" section below.


(3.2) Set JRE_HOME or JAVA_HOME (required)

These variables are used to specify location of a Java Runtime
Environment or of a Java Development Kit that is used to start Tomcat.

The JRE_HOME variable is used to specify location of a JRE. The JAVA_HOME
variable is used to specify location of a JDK.

Using JAVA_HOME provides access to certain additional startup options that
are not allowed when JRE_HOME is used.

If both JRE_HOME and JAVA_HOME are specified, JRE_HOME is used.

The recommended place to specify these variables is a "setenv" script. See
below.


(3.3) Other variables (optional)

Other environment variables exist, besides the four described above.
See the comments at the top of catalina.bat or catalina.sh scripts for the list and a description of each of them.

One frequently used variable is CATALINA_OPTS. It allows specification of
additional options for the java command that starts Tomcat.

See the Java documentation for the options that affect the Java Runtime Environment.

See the "System Properties" page in the Tomcat Configuration Reference for the system properties that are specific to Tomcat.

A similar variable is JAVA_OPTS. It is used less frequently. It allows specification of options that are used both to start and to stop Tomcat as well as for other commands.

Note: Do not use JAVA_OPTS to specify memory limits. You do not need much memory for a small process that is used to stop Tomcat. Those settings belong to CATALINA_OPTS.

Another frequently used variable is CATALINA_PID (on *nix only). It specifies the location of the file where process id of the forked Tomcat java process will be written. This setting is optional. It will enable the following features:

 *  better protection against duplicate start attempts and
 *  allows forceful termination of Tomcat process when it does not react to
    the standard shutdown command.


(3.4) Using the "setenv" script (optional, recommended)

Apart from CATALINA_HOME and CATALINA_BASE, all environment variables can be specified in the "setenv" script. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory and is named
setenv.bat (on Windows) or setenv.sh (on *nix). The file has to be readable.

By default the setenv script file is absent. If the script file is present both in CATALINA_BASE and in CATALINA_HOME, the one in CATALINA_BASE is preferred.

For example, to configure the JRE_HOME and CATALINA_PID variables you can
create the following script file:

On Windows, %CATALINA_BASE%\bin\setenv.bat:

  set "JRE_HOME=%ProgramFiles%\Java\jre7"
  exit /b 0

On *nix, $CATALINA_BASE/bin/setenv.sh:

  JRE_HOME=/usr/java/latest
  CATALINA_PID="$CATALINA_BASE/tomcat.pid"


The CATALINA_HOME and CATALINA_BASE variables cannot be configured in the setenv script, because they are used to locate that file.

All the environment variables described here and the "setenv" script are used only if you use the standard scripts to launch Tomcat. For example, if you have installed Tomcat as a service on Windows, the service wrapper launches Java directly and does not use the script files.


(4) Start Up Tomcat


(4.1) Tomcat can be started by executing one of the following commands:

  On Windows:

      %CATALINA_HOME%\bin\startup.bat

    or

      %CATALINA_HOME%\bin\catalina.bat start

  On *nix:

      $CATALINA_HOME/bin/startup.sh

    or

      $CATALINA_HOME/bin/catalina.sh start

(4.2) After startup, the default web applications included with Tomcat will be
      available by visiting:


(4.3) Further information about configuring and running Tomcat can be found in
      the documentation included here, as well as on the Tomcat web site:



(5) Shut Down Tomcat


(5.1) Tomcat can be shut down by executing one of the following commands:

  On Windows:

      %CATALINA_HOME%\bin\shutdown.bat

    or

      %CATALINA_HOME%\bin\catalina.bat stop

  On *nix:

      $CATALINA_HOME/bin/shutdown.sh

    or

      $CATALINA_HOME/bin/catalina.sh stop


Advanced Configuration - Multiple Tomcat Instances

In many circumstances, it is desirable to have a single copy of a Tomcat binary distribution shared among multiple users on the same server.  To make this possible, you can set the CATALINA_BASE environment variable to the directory that contains the files for your 'personal' Tomcat instance.

When running with a separate CATALINA_HOME and CATALINA_BASE, the files
and directories are split as following:

In CATALINA_BASE:

 * bin  - Only the following files:

           * setenv.sh (*nix) or setenv.bat (Windows),
           * tomcat-juli.jar

          The setenv scripts were described above. The tomcat-juli library
          is documented in the Logging chapter in the User Guide.

 conf - Server configuration files (including server.xml)

 lib  - Libraries and classes, as explained below

 logs - Log and output files

 webapps - Automatically loaded web applications

 work - Temporary working directories for web applications

 temp - Directory used by the JVM for temporary files (java.io.tmpdir)


In CATALINA_HOME:

 bin  - Startup and shutdown scripts

          The following files will be used only if they are absent in
          CATALINA_BASE/bin:

          setenv.sh (*nix), setenv.bat (Windows), tomcat-juli.jar

 lib  - Libraries and classes, as explained below

 endorsed - Libraries that override standard "Endorsed Standards"
              libraries provided by JRE. See Classloading documentation
              in the User Guide for details.
              This is only supported for Java <= 8.
              By default this "endorsed" directory is absent.

In the default configuration the JAR libraries and classes both in CATALINA_BASE/lib and in CATALINA_HOME/lib will be added to the common
classpath, but the ones in CATALINA_BASE will be added first and thus will be searched first.

The idea is that you may leave the standard Tomcat libraries in CATALINA_HOME/lib and add other ones such as database drivers into
CATALINA_BASE/lib.

In general it is advised to never share libraries between web applications, but put them into WEB-INF/lib directories inside the applications. See Classloading documentation in the User Guide for details.


It might be useful to note that the values of CATALINA_HOME and CATALINA_BASE can be referenced in the XML configuration files processed
by Tomcat as ${catalina.home} and ${catalina.base} respectively.

For example, the standard manager web application can be kept in CATALINA_HOME/webapps/manager and loaded into CATALINA_BASE by using
the following trick:

 * Copy the CATALINA_HOME/webapps/manager/META-INF/context.xml
   file as CATALINA_BASE/conf/Catalina/localhost/manager.xml

 * Add docBase attribute as shown below.

The file will look like the following:

  <?xml version="1.0" encoding="UTF-8"?>  <Context docBase="${catalina.home}/webapps/manager"    antiResourceLocking="false" privileged="true" >    <Valve className="org.apache.catalina.valves.RemoteAddrValve"         allow="127\.0\.0\.1" />  </Context>

See Deployer chapter in User Guide and Context and Host chapters in the Configuration Reference for more information on contexts and web application deployment.

Troubleshooting


There are only really 2 things likely to go wrong during the stand-alone
Tomcat install:

(1) The most common hiccup is when another web server (or any process for that
    matter) has laid claim to port 8080.  This is the default HTTP port that
    Tomcat attempts to bind to at startup.  To change this, open the file:

       $CATALINA_HOME/conf/server.xml

    and search for '8080'.  Change it to a port that isn't in use, and is
    greater than 1024, as ports less than or equal to 1024 require superuser
    access to bind under UNIX.

    Restart Tomcat and you're in business.  Be sure that you replace the "8080"
    in the URL you're using to access Tomcat.  For example, if you change the
    port to 1977, you would request the URL http://localhost:1977/ in your
    browser.

(2) The 'localhost' machine isn't found.  This could happen if you're behind a
    proxy.  If that's the case, make sure the proxy configuration for your
    browser knows that you shouldn't be going through the proxy to access the
    "localhost".

    In Firefox, this is under Tools/Preferences -> Advanced/Network ->
    Connection -> Settings..., and in Internet Explorer it is Tools ->
    Internet Options -> Connections -> LAN Settings.


Optional Components


The following optional components may be included with the Apache Tomcat binary
distribution. If they are not included, you can install them separately.

 1. Apache Tomcat Native library

 2. Apache Commons Daemon service launcher

Both of them are implemented in C language and as such have to be compiled
into binary code. The binary code will be specific for a platform and CPU
architecture and it must match the Java Runtime Environment executables
that will be used to launch Tomcat.

The Windows-specific binary distributions of Apache Tomcat include binary
files for these components. On other platforms you would have to look for
binary versions elsewhere or compile them yourself.

If you are new to Tomcat, do not bother with these components to start with.
If you do use them, do not forget to read their documentation.


Apache Tomcat Native library


It is a library that allows to use the "Apr" variant of HTTP and AJP
protocol connectors in Apache Tomcat. It is built around OpenSSL and Apache
Portable Runtime (APR) libraries. Those are the same libraries as used by
Apache HTTPD Server project.

This feature was especially important in the old days when Java performance
was poor. It is less important nowadays, but it is still used and respected
by many. See Tomcat documentation for more details.

For further reading:

Apache Tomcat documentation


    * Documentation for APR/Native library in the Tomcat User's Guide


    * Documentation for the HTTP and AJP protocol connectors in the Tomcat
      Configuration Reference



 - Apache Tomcat Native project home


 - Other projects

    * OpenSSL


    * Apache Portable Runtime


    * Apache HTTP Server


To disable Apache Tomcat Native library:

 - To disable Apache Tomcat Native library when it is installed, or
 - To remove the warning that is logged during Tomcat startup when the
   library is not installed:

   Edit the "conf/server.xml" file and remove "AprLifecycleListener" from
   it.

The binary file of Apache Tomcat Native library is usually named

  - "tcnative-1.dll" on Windows
  - "libtcnative-1.so" on *nix systems


Apache Commons Daemon


Apache Commons Daemon project provides wrappers that can be used to
install Apache Tomcat as a service on Windows or as a daemon on *nix
systems.

The Windows-specific implementation of Apache Commons Daemon is called
"procrun". The *nix-specific one is called "jsvc".

For further reading:

 - Apache Commons Daemon project


 - Apache Tomcat documentation

    * Installing Apache Tomcat


    * Windows service HOW-TO


The binary files of Apache Commons Daemon in Apache Tomcat distributions
for Windows are named:

  - "tomcat8.exe"
  - "tomcat8w.exe"

These files are renamed copies of "prunsrv.exe" and "prunmgr.exe" from
Apache Commons Daemon distribution. The file names have a meaning: they are used as the service name to register the service in Windows, as well as the
key name to store distinct configuration for this installation of "procrun". If you would like to install several instances of Tomcat 8.5 in parallel, you have to further rename those files, using the same naming scheme.