Posts

Showing posts from 2017

Create a web application in 5 minutes using Spring Boot and Maven

Image
Create a simple web application using Maven and Spring Boot Sometime to do an R&D, we all need a sample web application to experiment and play around.  Below are the steps which will help to create a web application quickly using Spring Boot and Maven. Create a maven project from your IDE in this case I am using Eclipse IDE. Go to File > New > Project and then select Maven > Maven Project                                  Add spring boot dependencies into the pom as shown pom.xml Add Controller and View (index.html) is the shown project structure Add SimpleWebController.java, Application.java and index.html as shown below              Build the project and run it use the command to run it  mvn spring-boot:run Once the application is launch successfully within the Embedded tomcat. Browse the application using  http://localhost:8080                                                                            

Memory Management in Java - Stack and Heap

Image
Memory Management in Java - Stack and Heap  Memory management is a mechanism to allocate memory when new objects are created and free it when no longer needed. In Java, the memory is divided into 2 segments: STACK HEAP STACK The stack is the place where any local variables and methods are stored. The lifetime of variables on the stack is governed by the scope of the code . The scope is usually defined by an area of code in curly brackets, such as a method call, or for or while loop. Once the execution has left that scope, those variables declared in the scope are removed from the stack. When the stack memory fills up, and eventually any more method calls will not be able to allocate their necessary variables. This results in a StackOverflowError . HEAP The heap is the place where objects, instance variables and static variables are stored. The new keyword allocates memory on the Java heap. The heap is the main pool of memory, accessible to t