Archive

Posts Tagged ‘java’

Google launches contract for Java

February 9th, 2011 No comments

Contracts for Java is a new open source tool from Google that makes it easier to implement contracts in Java. According to Google’s announcement, this new tool is based on Modern Jass by Johannes Rieken and inspired by the programming language Eiffel. It was created by two Google engineers – David Morgan, Andreas Leitner – using their 20% time, and was expanded as part of an internship by Nhat Minh Le.

These guys are trying to solve one basic fundamental problem in software programming i.e How do you enforce the contract of any class or method ?

Contracts for Java enables you to write annotate your code with contracts in the form of preconditions, postconditions and invariants.

These contract annotations are

  • easy to write and read,
  • and checked at runtime.

Annotating code with contracts helps you:

Categories: Programming / tutorials Tags: ,

Creating your first REST service using Jersey

December 29th, 2010 2 comments

In the last post , we had talked about SOAP being retired in favor of REST based service. in which we discussed advantages of REST over SOAP.

This post will be a short tutorial on creating your first REST based service.

What is REST  and how are they accesses ?

From Sun(oracle) docs

RESTful web services are built to work best on the Web. Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs), typically links on the Web. The resources are acted upon by using a set of simple, well-defined operations. The REST architectural style constrains an architecture to a client/server architecture and is designed to use a stateless communication protocol, typically HTTP. In the REST architecture style, clients and servers exchange representations of resources by using a standardized interface and protocol.

Why use  JERSEY ?

Java defines standard REST support via JAX-RS (The Java API for RESTful Web Services) in JSR 311. Jersey is the open source, production quality, JAX-RS (JSR 311) Reference Implementation for building RESTful Web services

Here is the objective of our tutorial

  • Set up development environment and infrastructure to build first REST full app using JERSEY
  • Create the sample application
  • Deploy and run in tomcat Read more…
Categories: Programming / tutorials Tags: , ,

Core Java Interview Questions

December 11th, 2010 3 comments

Java is one of the most popular  programming languages as of now and even with introduction of hibernate , Spring, employers do expect you to be aware of core java concepts.

Here is  Core Java Interview questions to test your knowledge.

Some of the questions like

What is WeakHasmap

Jdk1.5 has introduced class data sharing which reduces the start up time for java applications and to reduce the memory footprint, True or false

What characteristics of garbage collection have changed in jdk 5.0

you will definitely find interesting.

Some other Java interview questions and Java interview quiz on skill-Guru are

Java interview questions

Java interview questions 1

Categories: Interview questions Tags:

Apache resigns for Java Executive Committee

December 10th, 2010 No comments

In another blow in trying to bring Java Open source , Apache has resigned from Java SE/EE executive committee.

Why Apache took this step ?

The recent Java SE 7 vote was the last chance for the JCP EC to demonstrate that the EC has any intent to defend the JCP as an open specification process, and demonstrate that the letter and spirit of the law matter.   To sum up the issues at stake in the vote, we believe that while continuing to fail to uphold their responsibilities under the JSPA, Oracle provided the EC with a Java SE 7 specification request and license that are self-contradictory, severely restrict distribution of independent implementations of the spec, and most importantly, prohibit the distribution of independent open source implementations of the spec.  Oracle has refused to answer any reasonable and responsible questions from the EC regarding these problem

The Apache Software Foundation concludes that that JCP is not an open specification process – that Java specifications are proprietary technology that must be licensed directly from the spec lead under whatever terms the spec lead chooses; that the commercial concerns of a single entity, Oracle, will continue to seriously interfere with and bias the transparent governance of the ecosystem;  that it is impossible to distribute independent implementations of JSRs under open source licenses such that users are protected from IP litigation by expert group members or the spec lead; and finally, the EC is unwilling or unable to assert the basic power of their role in the JCP governance process

This is very big step and it will again raise questions , Can java be open sourced or Oracle will try to control all aspects of Java and its licensing.

Is Java on path to lose its stature as open source programming language ? Although Java was not clearly open sourced but it was also not under so much control as Oracle is trying to exert on it.

Categories: Tech news Tags:

Switching to python

December 3rd, 2010 No comments

I am a java programmer and although my wife has switched to grails, I am yet to find the motivation to move on something better. If you are looking for any reasons to switch to Python, here are two excellent posts which would help you decide why Python should be your next language of choice

An excellent post by Dharmesh

Why PHP Is Fun and Easy But Python Is Marriage Material

A very informative post

Ruby is beautiful but I am moving to phython

Categories: Programming / tutorials Tags: ,

Parsing a date with SimpleDateFormat in java

November 29th, 2010 No comments

A small code sample on how can you format java.util.date or any date into a desired format

java.util.Date todayDate = new java.util.Date()

or preferably

Date todayDate = Calendar.getInstance().getTime();
// this is the format 2010-11-25 8:30:24
SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss “);

String outcome = dateFormat.format(todayDate);

System.out.println(outcome);

Categories: Programming / tutorials Tags:

Java Interview questions

November 18th, 2010 1 comment

Java is the most popular programming language and even with onset of all new languages like Ruby, Scala, the popularity of java has only grown . Java/J2EE is the preferred enterprise solution for the business user.

So when it comes to number of jobs, no doubt java has the most most jobs. But you should also be prepared when going for interview and here is a series of tests and quiz to help you prepare for Java inerview

A free quiz to test your knowledge of core java and collections

Take java Interview questions.

This test would test you on your basic concepts of java like

What is result Set ? (A class or interface)

When I say this “is the inclusion of behavior (i.e. methods) and state (i.e. variables) of a base class in a derived class so that they are accessible in that derived class”, what I am talking about  ?

How many JVM could be run on an operating system ?

Another Java Interview questions test. This test covers more on hands on programming  and inner classes

Categories: Interview questions Tags:

How many JVM can be run on an operating system (OS) ?

November 15th, 2010 No comments

You can have one JVM per process. Since an OS supports many processes, you can have many JVMs running.

When ever we start a new java process by invoking java.exe (i.e. java [class-name] ) a new instance of JVM is created. Each java process executes in its separate JVM environment – we can specify different JVM parameter for each process.

So you can open as many as command prompt your machine allows and run as many JVM as possible. It also means you can run different versions of JVM.

Categories: Programming / tutorials Tags: ,