Wednesday, December 20, 2017

SendGrid Email API integration with Spring Boot REST Application

SendGrid is a popular cloud-based email delivery service. A few months ago, I had an opportunity to work with this technology along with Spring Boot application to send email to subscribers. Today I am going to develop a very simple Spring Boot REST application to integrate SendGrid email API to send an email to a valid email address.

Sunday, December 17, 2017

Breadth First Search(BFS) In Java

BFS or Breadth First Search is a very well-known graph traversal algorithm. The following java program performs this algorithm using adjacency list representation of graphs. Graphs may contain a cycle. To avoid processing a node twice, we used a Boolean array, name visited.

Friday, December 15, 2017

Generate unique permutation in Java

We already saw how to generate all possible permutation in java. Today we will modify our algorithm to remove duplicate entries to keep only unique permutation.

For an example, if the given string is: 112, our program will generate:

112
121
211

Spring Boot REST API - Convert English Number into Words

Spring is one of the most popular Java EE application framework. Today we will develop a very simple Spring Boot REST API which receives a number as a request and in response, we will get the corresponding English words.

Please note that, this is not a tutorial to learn about Spring Boot REST API. I assumed you already familiar with this technology.

Spring Boot REST API - Spring Bean Scope illustration

We already know that Spring defines 5 types of bean scopes:

a) singleton
b) prototype
c) request
d) session
e) globalSession

Last three scopes are only available on web-aware application. Singleton and prototype are spring’s core scope and singleton is the default scope.


Thursday, November 23, 2017

Sieve of Eratosthenes In Java

The sieve of Eratosthenes is a famous ancient algorithm to find all prime numbers up to a given limit. We are going to implement this algorithm in Java.


Steps we will follow:

a) Lets we have an array of size 25.
b) First start with 2, remove all numbers which are divisible by 2.
c) Find the next number, which is 3. Remove all numbers which are divisible by 3.
d) Next survivor is 5 and we repeat the same procedure.
e) For the given limit 25, we don't need to find anymore survivor after 5, as 5 X 5 = 25. In other words, we only process up to the square root of the limit.
 f) All survivor numbers in the array are Prime. We save those numbers in a separate array.

Generate all possible permutations in Java using recursion.

In the previous example, we drew a pyramid in java without any loop. We used recursion to achieve our goal and hopefully, you got a very clear idea how recursion works. In the following example, I will show you how to print all permutations of a given string. If the given string is "1234", then all possible permutations are:

1234
1243
1324
1342
1324
1342
1423
1432
 .
 .
 .
4321

 A total number of permutations are 24. ( 4! = 24 )

Wednesday, November 22, 2017

Eclipse Paho Java Client (MQTT client) integration with Spring Boot REST API

MQTT is an open, lightweight, simple client-server (publish / subscriber) messaging transport protocol. It is designed with a minimal protocol overhead. On the other hand Eclipse Paho is one of the most popular client library implementations. In the following example, I will show how to integrate Spring Boot with Eclipse Paho.

Tested with the following environment and technologies:

a) JDK 1.8
b) Eclipse
c) Maven
d) Spring Boot
e) Eclipse Paho as MQTT client library.
f) Postman as REST API client (Google Chrome extension)
g) MQTTLens as client tool for MQTT (Google Chrome extension)

Monday, November 20, 2017

Printing Pyramid Without Any Loop In Java

If you are asked to write a java program to print out the following pyramid, I am pretty sure that you will accept the challenge without any doubt.  Wait! Life is not as easy as you think. If  you are given the following restrictions, are you able to solve the problem?:

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Tuesday, November 14, 2017

Pascal Triangle In Java

Pascal Triangle is one of the most interesting number pattern which is a triangular array of the binomial coefficients. The following example shows how to generate this triangle in Java.



Sunday, November 12, 2017

Apache Maven installation in Window 7

Apache maven is a package manager and building tools for Java. In this tutorial, we are going to install maven in window 7. 

Tested With:
Apache maven 3.5.2
JDK 1.7
Windows 7

Note: You need to have JAVA_HOME environment setting to run maven.

If you have windows 10 and JDK 1.8,  you don’t need to anything extra, just follow the steps of configurations below as we are going to do with Windows 7 and JDK 1.7


How to Setup Java Environment in Windows 10

If you already have downloaded Java Development Kit (JDK), then you are very close to execute and run your java program. Your next step to setup java environment variable and in this tutorial we are going to configure this on Windows 10.

We tested this configure using:

a) Window 10 and Window 7
b) JDK 1.8

Saturday, October 28, 2017

How to stay motivated as a software developer: 5 Useful Tips

If there is something important in any activity we play, it is being motivated enough and enjoying what is done. And if it is paid, much better. The programming of computer applications does not escape this reality. The impulse of the technology itself is a motivating factor to improve every day and be at the forefront of the latest advances.

But there are moments in the life of any programmer where demotivation and self-deceived prey on anyone and makes things happen routinely or monotonously. Either the proper priority is not given to projects that are worthwhile, or projects of lower quality or value are taken. In short, there are many factors that conspire against a programmer, and are against those who have to fight not to fall into those vicious circles where sometimes it is difficult to leave.

Wednesday, October 25, 2017

5 tips for being a good Java programmer

The Java programming language is one of the most complete in the market since its inception in the mid-90s of the last century. Several features, such as its robustness, multipurpose, concurrency, object-oriented; among others, have defined this language entirely.

There are many applications and systems derived that currently use Java in the technology platforms deployed worldwide. And its programmers community is widely recognized in various fields of computing. But within the same, there exist as in other disciplines, those that stand out more about what is considered the average standard of performance. And here it is valid to ask: what highlights as good programmers over others?

The future of Artificial Intelligence

Every day the technological advances are greater, by leaps and bounds we see how our societies are gradually robotizing and cyber-transforming as in any dream embodied in those works of science fiction that we can appreciate in the movies and TV.

What until a few years ago were fantasies and even chimeras of crazy scientists, today are a reality. Mobile devices that connect us in the blink of an eye to cyberspace, virtual reality gadgets that take us to other worlds while being in the same place, intelligent sensors that alert us if someone wants to break into our home or just let us know climate or the latest news; these are only samples of such advances.

Sunday, October 22, 2017

4 Common Mistakes For Beginner Java Programmer

One of the most complete programming language available is Java. Among its most essential characteristics: it’s concurrent, object-oriented and multipurpose; and designed so that its code can run from any machine or device, and its syntax is derived directly from the C and C ++ languages.

Since its official appearance in 1995 by Sun Microsystems, it has had many derivations according to its usage environment, extending more recently to the mobile and web applications, serving its (although failed) philosophy of running on every possible device in a single unique interface as a boost for the Android platform.

4 signs of a good application programmer

Application programming is one of the most interesting and vital branches of computing. Since it is the one that allows the creation and update of software of various types and scopes of use. It is also a complex process that requires time and resources, and human development teams in some cases; however this is not limiting for such process, since the most important asset for that creative process is in the hands of a person or group of them, who is the programmer as such.