HowToDoInJava https://howtodoinjava.com Tue, 24 Apr 2018 10:10:17 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.5 https://howtodoinjava.com/wp-content/uploads/2015/05/howtodoinjava_logo-55696c1cv1_site_icon-32x32.png HowToDoInJava https://howtodoinjava.com 32 32 [SOLVED] TLS 1.2 – SSLHandshakeException: Remote host closed connection during handshake https://howtodoinjava.com/security/tls12-sslhandshakeexception/ https://howtodoinjava.com/security/tls12-sslhandshakeexception/#respond Tue, 24 Apr 2018 10:10:17 +0000 https://howtodoinjava.com/?p=10286 SSLHandshakeException appear in logs when there is some error occur while validating the certificate installed in client machine with certificate on server machine. In this post, we will learn about fixing this if you are using Apache HttpClient library to create HttpClient to connect to SSL/TLS secured URLs.

The post [SOLVED] TLS 1.2 – SSLHandshakeException: Remote host closed connection during handshake appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/security/tls12-sslhandshakeexception/feed/ 0
RestTemplate with HttpClient – Java Configuration Example https://howtodoinjava.com/spring/spring-restful/resttemplate-httpclient-java-config/ https://howtodoinjava.com/spring/spring-restful/resttemplate-httpclient-java-config/#respond Sat, 21 Apr 2018 12:24:05 +0000 https://howtodoinjava.com/?p=10282 We have already gone through the RestTemplate examples for accessing REST APIs inside spring application. In this example, we are extending the configuration to use Apache HttpClient 4. The purpose of this tutorial is to give you pre-cooked recipe for little head-start, and save you from writing all bits and pieces.

The post RestTemplate with HttpClient – Java Configuration Example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-restful/resttemplate-httpclient-java-config/feed/ 0
Java sort Map by values (ascending and descending orders) https://howtodoinjava.com/core-java/collections/java-sort-map-by-values/ https://howtodoinjava.com/core-java/collections/java-sort-map-by-values/#respond Thu, 19 Apr 2018 12:44:14 +0000 https://howtodoinjava.com/?p=10261 Simple quick to use examples to sort Map by values, using Java 8 Stream APIs, in ascending and descending (reverse) orders. In the center of logic is the method Map.Entry.comparingByValue() which compares Map.Entry in natural order on value. Sort Map by Values using Stream APIs In java 8, Map.Entry class has static method comparingByValue() to […]

The post Java sort Map by values (ascending and descending orders) appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/collections/java-sort-map-by-values/feed/ 0
Java sort Map by key (ascending and descending orders) https://howtodoinjava.com/core-java/collections/java-sort-map-by-key/ https://howtodoinjava.com/core-java/collections/java-sort-map-by-key/#respond Thu, 19 Apr 2018 12:26:34 +0000 https://howtodoinjava.com/?p=10256 Simple quick to use examples to sort a Map by key, using TreeMap and Stream APIs, in ascending and descending (reverse) orders.

The post Java sort Map by key (ascending and descending orders) appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/collections/java-sort-map-by-key/feed/ 0
JavaScript Logs – Mask Sensitive Information in JSON https://howtodoinjava.com/scripting/javascript/mask-sensitive-info-json-logs/ https://howtodoinjava.com/scripting/javascript/mask-sensitive-info-json-logs/#respond Wed, 18 Apr 2018 16:18:42 +0000 https://howtodoinjava.com/?p=10245 Masking sensitive information is very practical need of applications which deal with sensitive customer data. For example, banking applications. When these applications run inside organization intra-net, many times UI logs are generated and stored on user’s machine for debugging purpose. In above scenario, it is regulatory requirement to mask all such sensitive informations so that […]

The post JavaScript Logs – Mask Sensitive Information in JSON appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/scripting/javascript/mask-sensitive-info-json-logs/feed/ 0
Java Garbage Collection Algorithms [till Java 9] https://howtodoinjava.com/core-java/garbage-collection/all-garbage-collection-algorithms/ https://howtodoinjava.com/core-java/garbage-collection/all-garbage-collection-algorithms/#comments Thu, 12 Apr 2018 11:27:38 +0000 https://howtodoinjava.com/?p=10236 In java garbage collection tutorial, we will learn about object life cycle, difference between mark-sweep, mark-sweep-compact and mark-copy mechanisms, different single threaded and concurrent GC algorithms (e.g. G1), and various flags to control the gc algorithm’s behavior and log useful information for applications.

The post Java Garbage Collection Algorithms [till Java 9] appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/garbage-collection/all-garbage-collection-algorithms/feed/ 1
Java 9 – Compact Strings Improvement [JEP 254] https://howtodoinjava.com/java9/compact-strings/ https://howtodoinjava.com/java9/compact-strings/#comments Tue, 10 Apr 2018 10:55:23 +0000 https://howtodoinjava.com/?p=10233 Till Java 8, String in java were internally represented by char[]. Each char is stored in 2 bytes in memory. JDK developers at oracle analyzed lots of client’s application help dumps and they noticed that most of the strings can be represented only using Latin-1 characters set. A latin-1 char can be stored in one byte, which is 50% (1 byte) less than char data type storage.

The post Java 9 – Compact Strings Improvement [JEP 254] appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/java9/compact-strings/feed/ 1
Spring Boot 2.0 – Developer Tools Module Tutorial https://howtodoinjava.com/spring/spring-boot2/developer-tools-module-tutorial/ https://howtodoinjava.com/spring/spring-boot2/developer-tools-module-tutorial/#respond Fri, 06 Apr 2018 12:35:04 +0000 https://howtodoinjava.com/?p=10219 If you have worked on latest UI development frameworks e.g. Node, angular, gulp etc. then you must have appreciated the auto-reload of UI in browser whenever there is change in some code. Its pretty useful and saves a lot of time. Well, same feature can be utilized in spring boot applications using spring-boot-devtools dependency provided […]

The post Spring Boot 2.0 – Developer Tools Module Tutorial appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/developer-tools-module-tutorial/feed/ 0
Spring Boot 2.0 – WAR Packaging Example https://howtodoinjava.com/spring/spring-boot2/war-packaging-example/ https://howtodoinjava.com/spring/spring-boot2/war-packaging-example/#respond Thu, 05 Apr 2018 08:17:03 +0000 https://howtodoinjava.com/?p=10216 In Spring boot applications, default packaging is jar which is deployed in embedded servers. If you want to generate a war file for deployment in seperate application server instances such as Jboss, Weblogic or tomcat, then follow below instructions.

The post Spring Boot 2.0 – WAR Packaging Example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/war-packaging-example/feed/ 0
Spring Boot – Request validation of REST APIs https://howtodoinjava.com/spring/spring-boot2/spring-rest-request-validation/ https://howtodoinjava.com/spring/spring-boot2/spring-rest-request-validation/#respond Wed, 04 Apr 2018 12:08:31 +0000 https://howtodoinjava.com/?p=10211 In this spring boot tutorial, we will learn to validate request body sent to PUT/POST REST APIs. We will also learn to add custom error messages in API responses for validation errors using ResponseEntityExceptionHandler, @ControllerAdvice and @ExceptionHandler annotations.

The post Spring Boot – Request validation of REST APIs appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/spring-rest-request-validation/feed/ 0
Spring Boot 2.0 – @SpringBootApplication and Auto Configuration https://howtodoinjava.com/spring/spring-boot2/springbootapplication-auto-configuration/ https://howtodoinjava.com/spring/spring-boot2/springbootapplication-auto-configuration/#respond Mon, 02 Apr 2018 20:03:34 +0000 https://howtodoinjava.com/?p=10201 String boot is very easy to use and it does a lot of things under the hood, you might not be aware of. In future, a good developer will be who will know exactly what is going on behind spring boot auto configuration, how to use it in your favor and how to disable certain sections which you do not want into your project.

The post Spring Boot 2.0 – @SpringBootApplication and Auto Configuration appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/springbootapplication-auto-configuration/feed/ 0
Spring Boot 2.0 – Spring HATEOAS Example https://howtodoinjava.com/spring/spring-boot2/rest-with-spring-hateoas-example/ https://howtodoinjava.com/spring/spring-boot2/rest-with-spring-hateoas-example/#respond Mon, 02 Apr 2018 16:34:09 +0000 https://howtodoinjava.com/?p=10204 In this Spring HATEOAS example, we will learn to add HATEOAS links to existing REST APIs created in a spring boot project. We will use the class org.springframework.hateoas.ResourceSupport along with org.springframework.hateoas.mvc.ControllerLinkBuilder and org.springframework.hateoas.Link classes provided by spring HATEOAS module. To demo the creation of links, we will first create few REST APIs and see their […]

The post Spring Boot 2.0 – Spring HATEOAS Example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/rest-with-spring-hateoas-example/feed/ 0
Spring Boot Starter Parent Dependency https://howtodoinjava.com/spring/spring-boot2/spring-boot-starter-parent-dependency/ https://howtodoinjava.com/spring/spring-boot2/spring-boot-starter-parent-dependency/#respond Mon, 02 Apr 2018 03:59:37 +0000 https://howtodoinjava.com/?p=10199 The spring-boot-starter-parent dependency is the parent POM providing dependency and plugin management for Spring Boot-based applications. It contains the default versions of Java to use, the default versions of dependencies that Spring Boot uses, and the default configuration of the Maven plugins.

The post Spring Boot Starter Parent Dependency appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/spring-boot-starter-parent-dependency/feed/ 0
Spring Boot 2 – Spring Boot starter templates https://howtodoinjava.com/spring/spring-boot2/spring-boot-starter-templates/ https://howtodoinjava.com/spring/spring-boot2/spring-boot-starter-templates/#respond Sun, 01 Apr 2018 10:27:45 +0000 https://howtodoinjava.com/?p=10196 Spring Boot comes with over 50+ different starter modules, which provide ready-to-use integration libraries for many different frameworks, such as database connections that are both relational and NoSQL, web services, social network integration, monitoring libraries, logging, template rendering, and the list just keeps going on.

The post Spring Boot 2 – Spring Boot starter templates appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-boot2/spring-boot-starter-templates/feed/ 0
Microservices monitoring with hystrix, eureka admin and spring boot admin https://howtodoinjava.com/spring/spring-cloud/microservices-monitoring/ https://howtodoinjava.com/spring/spring-cloud/microservices-monitoring/#respond Mon, 19 Mar 2018 17:54:18 +0000 https://howtodoinjava.com/?p=9910 Spring boot is widely being used while delivering micro services based application. Eventually it has become a necessity to monitor Spring boot applications running on different hosts. There are many tools available to monitor different health stats of these microservices. In this post, we will learn to use three such monitoring tools i.e. Hystrix dashboard, […]

The post Microservices monitoring with hystrix, eureka admin and spring boot admin appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/spring/spring-cloud/microservices-monitoring/feed/ 0
Swagger2 – Spring Boot REST API Code Generation https://howtodoinjava.com/swagger2/code-generation-for-rest-api/ https://howtodoinjava.com/swagger2/code-generation-for-rest-api/#comments Mon, 12 Mar 2018 06:31:17 +0000 https://howtodoinjava.com/?p=10109 Swagger can be integrated with REST APIs in below ways - A top-down approach – First API specification and then code generation. A botton-up approach – First API code and then Swagger integration. In this tutorial, we will learn the top down approach.

The post Swagger2 – Spring Boot REST API Code Generation appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/swagger2/code-generation-for-rest-api/feed/ 1
Maven – Create Fat/Uber Jar for Spring Boot Applications https://howtodoinjava.com/maven/create-fat-jar-spring-boot-applications/ https://howtodoinjava.com/maven/create-fat-jar-spring-boot-applications/#respond Sat, 10 Mar 2018 10:31:13 +0000 https://howtodoinjava.com/?p=10077 In this maven tutorial, we will learn to create fat jar or uber jar for spring boot applications using maven plugin. Its very easy and require very few config changes in pom.xml file.

The post Maven – Create Fat/Uber Jar for Spring Boot Applications appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/maven/create-fat-jar-spring-boot-applications/feed/ 0
ANT build war file example https://howtodoinjava.com/ant/apache-ant-build-war-file-example/ https://howtodoinjava.com/ant/apache-ant-build-war-file-example/#respond Fri, 09 Mar 2018 10:54:11 +0000 https://howtodoinjava.com/?p=10066 In this ANT tutorial, we will learn to build war file for our java web application project. This example uses minimum code and configuration so you can use it for sample ant build.xml for war as well. ANT Installation Download Apache Ant from ant.apache.org. Extract the zip file into a directory structure of your choice. […]

The post ANT build war file example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/ant/apache-ant-build-war-file-example/feed/ 0
ANT build jar file example https://howtodoinjava.com/ant/ant-build-jar-file-example/ https://howtodoinjava.com/ant/ant-build-jar-file-example/#respond Wed, 07 Mar 2018 13:22:59 +0000 https://howtodoinjava.com/?p=10018 Learn to build jar files for our java project. This example uses minimum code and configuration so you can use it for sample build.xml example as well.

The post ANT build jar file example appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/ant/ant-build-jar-file-example/feed/ 0
How to read typesafe user input using Scanner class https://howtodoinjava.com/core-java/io/read-typesafe-input-scanner-class/ https://howtodoinjava.com/core-java/io/read-typesafe-input-scanner-class/#respond Wed, 07 Feb 2018 19:26:10 +0000 https://howtodoinjava.com/?p=9887 Learn to read typesafe user inputs from console in any interactive java application i.e. prompt the user until user inputs the value in correct format/datatype.

The post How to read typesafe user input using Scanner class appeared first on HowToDoInJava.

]]>
https://howtodoinjava.com/core-java/io/read-typesafe-input-scanner-class/feed/ 0