Jun 16, 2017

Project facets problem arises when importing maven project into eclipse IDE

why project facets problem arises when importing maven project into eclipse IDE
and how to resolve it.

file>import>maven>existing maven project


rightclick on project>properties>project facets


uncheck java and dynamic web module

rightclick on project>maven>update poject

The best solution is to include plugin in to the POM before importing
Example:
<plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-compiler-plugin</artifactId>  <version>2.1</version>  <configuration>    <source>1.8</source>    <target>1.8</target>  </configuration> </plugin>

which makes java 1.8 as facet.

Jun 15, 2017

Creating and running the maven as a stand alone application in windows

A.Installing  maven 
1.Download maven standalone package at https://maven.apache.org/download.cgi 
2.unzip on to a prefered location
3.copy the path of the bin say D:\installedSoft\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin
4.create environment variable (USER variable) M2_HOME = D:\installedSoft\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin
5.copy the M2_HOME user variable to the system variable  path=%M2_HOME%;

B.Install java JDK
1.create JAVA_HOME and copy to path

C. Check installation and run demo project
1. check the version by executing >> mvn --version in the command line
you should get:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:4
7+05:30)
Maven home: D:\installedSoft\apache-maven-3.3.9-bin\apache-maven-3.3.9
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_65\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows server 2008", version: "6.0", arch: "amd64", family: "dos"

2.Creating a Project by executing
>> mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

3.Build the Project
First change directory to the place where project is generated usually
>> CD C:\Users\Administrator\my-app
>> mvn package

Now that the maven has compiled and created the exucutable jar in the new target folder.

4.Run the application
>> java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App

OUTPUT:
Hello World!

Jun 9, 2017

How to setup a HTTPS server

Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\Administrator>cd %JAVA_HOME%

C:\Program Files\Java\jdk1.8.0_65>cd bin

C:\Program Files\Java\jdk1.8.0_65\bin>keytool -help
Key and Certificate Management Tool

Commands:

 -certreq            Generates a certificate request
 -changealias        Changes an entry's alias
 -delete             Deletes an entry
 -exportcert         Exports certificate
 -genkeypair         Generates a key pair
 -genseckey          Generates a secret key
 -gencert            Generates certificate from a certificate request
 -importcert         Imports a certificate or a certificate chain
 -importpass         Imports a password
 -importkeystore     Imports one or all entries from another keystore
 -keypasswd          Changes the key password of an entry
 -list               Lists entries in a keystore
 -printcert          Prints the content of a certificate
 -printcertreq       Prints the content of a certificate request
 -printcrl           Prints the content of a CRL file
 -storepasswd        Changes the store password of a keystore

Use "keytool -command_name -help" for usage of command_name

Generating own SSL RSA key using java keytool

C:\Program Files\Java\jdk1.8.0_65\bin>keytool -genkey -alias tomcat -keyalg RSA
Enter keystore password: abc@123
Re-enter new password: abc@123
What is your first and last name?
  [Unknown]:  raghavendra B A
What is the name of your organizational unit?
  [Unknown]:  srh
What is the name of your organization?
  [Unknown]:  srh
What is the name of your City or Locality?
  [Unknown]:  bangalore
What is the name of your State or Province?
  [Unknown]:  karnataka
What is the two-letter country code for this unit?
  [Unknown]:  in
Is CN=raghavendra B A, OU=srh, O=srh, L=bangalore, ST=karnataka, C=in correct?
  [no]:  yes

Enter key password for
        (RETURN if same as keystore password):

Output:
the file will be generated at the location C:\Users\Administrator as .keystore

If you want to specify the location and name during the process then use -keystore filename
example:
C:\Program Files\Java\jdk1.8.0_65\bin>keytool -genkey -alias tomcat -keyalg RSA
-keystore C:\Users\Administrator\Desktop\mykey

Apache Tomcat 8 configuration in server.xml

 <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" 
  keystoreFile="C:\Users\Administrator\Desktop\SRHSSLKey"
          keystorePass="baikadi@99"/>

Used https://www.opinionatedgeek.com/codecs/htmlencoder for encoding the above code snippet 

Checking the working of HTTPS

https://localhost:8443/