Category Archives: Web

Spring Boot App on Google App Engine Standard Environment

This blog represents tips and techniques on how to deploy a Spring Boot app on Google App Engine standard environment. Create a Google AppEngine (GAE) Project Login into Google Cloud Console and create an AppEngine project. Configure GCloud Setup In order to upload GAE project from command prompt, the GCLoud setup needs to be configured. Execute following command from the command prompt to start configuring your appengine project: Do some of the following while configuring the setup: Select a new configuration; Enter the configuration name Login into your cloud account Successful login will list down existing Google Appengine (GAE) project. Pick the one which you created from the cloud console. …

Continue reading

Posted in Google Cloud, Java, Web. Tagged with , , .

Angular – How to Create Your First Angular App

This blog represents concepts and commands which would help you setup development environment to build Angular apps. Introduction to Angular CLI Angular CLI is a command line interface for Angular. With Angular CLI commands, the following are some of the key functionality which can be achieved using Angular CLI commands: Create an application that follows best practices recommended by Angular. ng new command is used. Test the app locally as you develop. ng serve is used. Greater details can be found on this page, Angular CLI. The documentation in relation with Angular CLI can be found on this page, Angular CLI Documentation. Install the Angular CLI The following command can …

Continue reading

Posted in Javascript, Web. Tagged with , , , .

Setup Environment for Google AppEngine Java Project

This blog presents tips and techniques on how to set up environment for deploying Java web app on Google AppEngine using GCloud SDK. Same environment can as well be used for deploying Spring boot web app. Following steps are described later: Install Google Cloud SDK Install Cloud SDK Appengine Java component Create Appengine project in Google Cloud Console Authorize GCloud Configure Appengine project using GCloud Install Google Cloud SDK Download and install Google Cloud SDK. The instructions for downloading and installing Google Cloud SDK can be found on Installing Cloud SDK page. Unzip or Untar the downloaded file and go to the google-cloud-sdk folder. Execute install.sh or install.bat appropriately from …

Continue reading

Posted in Cloud, Google Cloud, Java, Web. Tagged with , , .

Spring Boot with JSP Pages – Code Example

Following needs to be done to setup Spring boot web app with JSP pages Create a Spring Starter Project Create a Spring Starter Project by selecting “Web” as one of the dependencies. This will create a Springboot project. POM.xml Entries Place following entries in pom.xml for processing JSP pages Configuration in application.properties Place following configuration in application.properties Create Controller class Create a sample controller class such as following: Create JSP pages Create a folder src/main/webapp/WEB-INF/views Create a file index.jsp. Place the content such as following: Run Project as Spring Boot App Access URL such as http://localhost:8080/ in browser. Following would be displayed.

Posted in Java, Web. Tagged with , , .

Springboot MongoDB Repository – Code Example

This blog represents code required to create a Spring boot application that uses Spring Data MongoRepository interface to connect with MongoDB database. Step 1: Create a Springboot Maven project Create a new Spring Starter Project using Eclipse IDE. This would create a class annotated with @SpringBootAnnotation. Step 2: Include Spring Data Mongo support in pom.xml Step 3: Configure Mongoclient for database connectivity Create a Configuration class which is used to instantiate a MongoClient for connecting with MongoDB database. Step 3: Define MongoDB details in application.properties Step 4: Invoke MongoRepository instance Place following code in SpringBootAnnotation class for invoking MongoRepository instance (UserDAO in the code given below). In ideal scenario, you would want …

Continue reading

Posted in Java, MongoDB, NoSQL. Tagged with , , .

Angular – Reactive or Template-driven Forms?

This article represents quick introduction to two different kind of forms which can be created in Angular 2 or Angular 4. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points discussed later in this article: Template-driven forms Reactive forms Template-driven forms Template-driven forms are the most trivial type of form that can be quickly created in Angular 2. Following are key aspects of creating template-driven form. These forms are asynchronous in nature. These forms require inclusion/import of FormsModule in the root module, AppModule which is placed in the root folder of the app. Following …

Continue reading

Posted in AngularJS, Web. Tagged with , , .

Top 5 Performance So-called Concerns of Meteor JS

Many working with Meteor JS wonders about performance concerns associated with Meteor JS. This blog points some of those concerns and represents my opinion on why they are invalid concerns. Database as a Bottleneck Inability to handle heavy read-write loads, especially, write load/performance; However, with latest releases of MongoDB, MongoDB is good enough to easily handle very large data requirements of read/write. Following are related details: MongoDB supports different techniques to scale out appropriately based on the read-write requirements. They are as following: Secondary reads (reads from slaves, writes from primary/master). Sharding techniques MongoDB (3.0+) has come up with new storage engine, WiredTiger, which supports document-level concurrency control for write …

Continue reading

Posted in Javascript, Mobility, Performance Engineering, Web. Tagged with , .

Spring Boot Web Application with Eclipse in 5 Clicks

This article represents tips and code samples to get you started quickly with Spring web application within few clicks. Please feel free to comment/suggest if I missed mentioning one or more important points. Also, sorry for the typos. Steps to get started with Spring Boot Web Application Go to Help > Eclipse Marketplace… and search type “spring sts” in Find text field under Search tab. Install the entry with the title such as “Spring Tool Suite (STS) for Eclipse Release”. Once installed, you would be asked to restart the Eclipse. Go ahead and restart the eclipse. Open the new Project selector window using shortcut, CTRL + N. Type “Spring Starter” …

Continue reading

Posted in Java, Web. Tagged with .

AngularJS, Angular-UI Router Hello World Starter App – Code Sample

This article represents code samples to get started with an AngularJS app with Angular UI-Router and Bootstrap. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Code Example – AngularJS 1, Angular UI-Router, Bootstrap Pay attention to some of the following in the code given below: Angular-UI router state information is used to associate links with templates Angular-UI code with within tag element “ui-view” to load specific views <!DOCTYPE html> <head> <title>My AngularJS App</title> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css” integrity=”sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u” crossorigin=”anonymous”> </head> <body ng-app=”myApp” class=”container”> <div class=”page-header”> <h1>Angular 1 – Angular UI Router</h1> </div> <div class=”container-fluid”> <div class=”row”> <div class=”col-sm-3 col-lg-2″> …

Continue reading

Posted in AngularJS, Javascript, Web. Tagged with , .

Java – How to Fix java.lang.NoClassDefFoundError?

This article represents tips on How to Fix java.lang.NoClassDefFoundError when compiling a particular Java file. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: How to reproduce java.lang.NoClassDefFoundError? Why does the java.lang.NoClassDefFoundError occur in the first place? How to Fix the Error? How to reproduce java.lang.NoClassDefFoundError? Take a look at following Class file. package com.test; public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello World! How are you?”); } } Following are steps to reproduce the java.lang.NoClassDefFoundError. Save the above file as HelloWorld.java within any folder. Compile …

Continue reading

Posted in Java. Tagged with .

Java – How to Fix java.lang.UnsupportedClassVersionError Error?

This article represents tips on how to fix Java error such as UnsupportedClassVersionError. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. How to Reproduce the Error? Set the JAVA_HOME with one version of Java. And, include “bin” of different Java version in PATH variable. Compile the class, say, HelloWorld.java with “javac” command Start the JVM with following class: “java HelloWorld” With above, you could see error such as following: java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor ver sion 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) …

Continue reading

Posted in Java. Tagged with , .

Java – How to Calculate Size of Objects & Arrays

This article represents a list of web pages which can help one understand the memory usage of Java objects and arrays along with examples. Please feel free to comment/suggest any other cool pages. Also, sorry for the typos. The in-memory size of the object depends on the architecture, mainly on whether the VM is 32 or 64-bit. The actual VM implementation also matters. How to calculate memory usage of a Java object?: Very simplified explanation of how one could calculate a memory of any Java object. For example, lets say, you want to calculate the memory of a Java object which holds two int variables, one boolean variable, one Long object, …

Continue reading

Posted in Java, Web. Tagged with .

How to Dockerize Springboot Web App

This blog represents instructions and code samples on how to Dockerize a Springboot Web app. The source code be found from this git repository. Following are key aspects of this blog: Dockerfile & image Install the image Run the container and access the app Dockerfile & Image Download the code from this page and put them all in a folder. Before we go one to create the image, lets know a little more about the Dockerfile. Following points need to be noted in the Dockerfile: The image created is a Centos6 image The Java is installed in a predefined path “/opt/jdk” Then, Maven is installed and JAVA_HOME is set. The source …

Continue reading

Posted in Dockers, Java. Tagged with , .

Java Code Sample to Access Firebase Data

This article represents Java code sample which can be used to access Firebase database. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Pre-requisite for Firebase Database Access It is recommended to not allow anyone to access Firebase database without any kind of authentication. The minimum that could be done is enable “Anonymous Authentication” by logging in Firebase console. Java Code Sample for Firebase Database Access In the code below, note some of the following: Code for anonymous authentication Code for accessing a user object based on a given userId Firebase firebase = new Firebase(“https://dbname.firebaseio.com/”); firebase.authAnonymously(new Firebase.AuthResultHandler() { @Override …

Continue reading

Posted in Java, Web. Tagged with , .

Liskov Substitution Principle with Java Code Examples

This article describes what is Liskov Substitution Principle along with code examples in Java. Please feel free to comment/suggest if I missed mentioning one or more important points. Also, sorry for the typos. In this post, you will learn some of the following: What is Liskov Substitution Principle (LSP)? Code Samples to Illustrate LSP What is code quality characteristic that represents by LSP? You may also want to check another code quality principle such as Single Responsibility Principle explained with Java Examples. What is Liskov Substitution Principle (LSP)? Take a look at this paper on Liskov Substitution Principle which provides great details on Liskov Substitution Principle. As per LSP, functions …

Continue reading

Posted in Java, Programming, Software Quality. Tagged with , .

Springboot Web Hello World with a Java & Pom.xml file

This blog presents instructions on how to quickly get started with Springboot Hello World with just one Java file and a Pom.xml. Before getting set up with files, make sure you have installed and configured following Java; Setup Java_Home as it is required by maven Maven; Maven would be used to package our app.   Java Code Sample Following is the code for Java file. Make sure to create hello/HelloController.java file within src/main/java. This is required for maven to package it correctly. package hello; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; import org.springframework.web.bind.annotation.*; @RestController @SpringBootApplication public class HelloController { @RequestMapping(“/”) String home() { return “Hello World!”; } public static …

Continue reading

Posted in Java, Web. Tagged with .