lombok is not installing and opening. its showing error “The file ‘/home/ftuser/Downloads/lombok-1.16.18.jar’ is not marked as executable. If this was downloaded or copied from an untrusted source, it may be dangerous to run. For more details, read about the executable bit.”

Right click on the lombok-1.16.18.jar file and open as Oracle Java 8 Runtime then it will open the pop up window.please specify the ecplise location and update it.

How to create angularJs Application in eclipse

How to create angularJs Application in eclipse

          In this tutorial we are going to create simple AngularJs application with very basics features. As you progress you will see few built-in directives of AngularJs and how they acts on Model and Views.

Prerequisites

  1. Eclipse IDE with one of one of server plugins(Apache Tomcat/Jetty etc) installed.
  2. Any web browser (Chrome,Firefox etc..)
Steps

We build the entire application step by step. Each step is concentrated on a particular functionality.
OK, let’s start.

Step 1. Create a Dynamic Web project in eclipse
File->New->Dynamic web Project
Give the project name as “angularjs-demo” and click finish button.

Step 2. Create the first page index.html

Right click on WebContent folder ->New ->HTML File.
Change the name to index.html and click on finish.
Open index.html and change the <title> as you like. Here I am going to change it to “AngularJs Demo”.
<title>AngularJs Demo</title>
Keep rest everything as it is.


Step 3. Import AngularJs

We can include AngularJS library to our application using ‘script’ tag.
This can be done in two ways.

Step 4. Create module and controller for your application

To begin with AngularJs we need to create two things – Module and Controller.

    Controller : A controller is a JavaScript function where we write presentation logic to be applied on data and later this data is supplied to view.
Module: A module is a container for the different parts of your app (controller,services etc).

To put our module and controller code we are going to create a new js file specific to our application.
Create a folder ‘js‘ inside WebContent folder (Right click on WebContent and New->Folder).
Create the file angulardemo.js inside js folder.(Right click on js folder -> New->File).

Add the below code to angulardemo.js file.

var app = angular.module(“demoApp”, []);
    app.controller(“demoCtrl”, function($scope) {
        $scope.book = “The Alchemist”;
        $scope.author = “Paulo Coelho”;
    });
We just created a module “demoApp” and a controller for the module “demoCtrl“.
Import the angulardemo.js to index.html just like angular.min.js file.
http://js/angulardemo.js

Now all the files are created. Just to make sure everything is fine, below is folder structure of this application.

Step 5.  Bootstrapp the angularJs app  

    To inject the module into HTML DOM we use ng-app directive. (For now just keep in mind that directive is like an html attribute which does something special. ng-app is one of the many built in directives of AngularJs)
ng-app can be applied to any html element like <html>,<body>,

etc.

Above code indicates that all the contents inside this html tag will bind to the module “demoApp”.


Step 6.  Display the model data from Controller on View
If we look inside the controller code we will see two variables defined . ie $scope.book and $scope.author. $scope is like a global object which can be accessed by both View and Controller. All the elements in $scope (here the variables book and author) can be directly used in View.

Now are going to add some plain html code to display the model data in view – index.html.Add the below code inside body element. 


       


           


               


               


           


           


               


               


           


       

Book Name
Author


   

ng-controller is another built-in directive just like ng-app which indicates that model for this

element will be supplied and controlled by “demoCtrl” controller.
ng-bind is the directive wich the bind the content of enclosing html element with value of the scope variable.
Here table cell

will be filled with actual values (defined in controller) of model variables ‘book’ and ‘author’.

Step 7.  Run the application
Running the application is similar to running any other web application in eclipse.
Right click on project->Run As-> Run on Server.. (Hope you have installed Apache/Jetty or any other sever plugins in eclipse)

Hit the url : http://localhost:8080/angularjs-demo/ in your web browser.
If everything works well you will get the below output.

Complete source code

index.html




AngularJs Demo
http://lib/angular.min.js
http://js/angulardemo.js


 
Book Name
Author
</body> </html>

angulardemo.js

var app = angular.module("demoApp", []);

app.controller("demoCtrl", function($scope) {
 $scope.book = "The Alchemist";
 $scope.author = "Paulo Coelho";
});

What you’ve seen so far

  •     Directives

ng-app : Bootstrap and define angularJs in HTML DOM.
ng-controller : Define a controller for html element.
ng-bind : Bind html elements with model data.

  •     AngularJs function to create module – angular.module(….)
  •     AngularJs function to create controller – .controller(….)
  •     The bridge between controller functions and the HTML DOM  – $scope

This is just a beginning to AngularJs. There are many other dependent libraries and core components which are used for developing a fully functional website. Hope this is helpful in learning AngularJs. Feel free to share your comments and suggestions. Happy Learning!!

constructor and static block in java

You use a constructor to initialize one instance of a class, the static initialization block initializes static members at the time that the class is loaded.

 

static block does different thing than constructor . Basically there sre two different concepts.

static block initializes when class load into memory , it means when JVM read u’r byte code. Initialization can ne anything , it can be variable initialization or any thing else which should be shared by all objects of that class

whereas constructor initializes variable for that object only .

 

reference : https://beginnersbook.com/2013/04/java-static-class-block-methods-variables/