Java

Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers.

Spring Logo

Spring Framework

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Hibernate Logo

Hibernate Framework

Hibernate ORM is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database.

Sunday, November 10, 2013

Developing a Sample HelloWorld Java Program by using Maven

Step1: Create a HelloWorld java project by using mvn command.

[ranga@ranga Documents]$ mvn archetype:generate -DgroupId=com.ranga -DartifactId=HelloWorld -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Project Structure looks like

HelloWorld
├── pom.xml
└── src
    ├── main
    │   └── java
    │       └── com
    │           └── ranga
    │               └── App.java
    └── test
        └── java
            └── com
                └── ranga
                    └── AppTest.java

9 directories, 3 files

Step2:

edit the pom.xml and add the following line to run a application  

<build>
    <plugins>
        <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
                <source>1.6</source>
                <target>1.6</target>
        </configuration>
     </plugin>
        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <configuration>
             <mainClass>com.ranga.App</mainClass>
        </configuration>
        </plugin>
    </plugins>
   </build>
 
Step3: Run the following command to compile and run. 

[ranga@ranga HelloWorld]$ mvn compile exec:java

Hello World!






Saturday, November 9, 2013

Developing a Simple HelloWorld Java Program by using gradle


Step 1: Create the following package Structure.

Java
    └──src
        ├── main
        │   ├── java       
        │   └── resources
        └── test
            ├── java
            └── resources

Step2: Inside src/main/java create a HelloWorld.java with the fowlloing package.

HelloWorld.java

package com.ranga;

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

Now strutctue look likes

└── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── ranga
    │   │           └── HelloWorld.java
    │   └── resources
    └── test
        ├── java
        └── resources

Step3: Inside Java folder, create a new file called build.gradle parellel to src. 

Java
├── build.gradle
└── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── ranga
    │   │           └── HelloWorld.java
    │   └── resources
    └── test
        ├── java
        └── resources 


Step4: Add the plugin as 'java' and specify the main the class in the build.gradle file.

build.gradle
 
apply plugin: 'java'

task runHelloWorld(dependsOn: 'classes', type: JavaExec) {
    main = 'com.ranga.HelloWorld'
    classpath = sourceSets.main.runtimeClasspath
}

defaultTasks 'runHelloWorld'

Step5: In terminal enter the following command to run the Simple HelloWorld program.

[ranga@ranga java]$ gradle -q runHelloWorld
Hello, Ranga!


Another way is,


edit the build.gradle and the following line

apply plugin: 'application'

mainClassName = "com.ranga.HelloWorld"


Then run the following command in the terminal

[ranga@ranga java1]$ gradle -q run
Hello, Ranga!


Thats it............