Saturday, July 30, 2011

JAVA 7 Released

Java 7 has been  launched on   July 7, 2011 . This release puts Java back on the tracks with a host of new features and improvements, moving Java 7 forward for developers, the industry, and the ecosystem.
So,All of you are wondering what’s new in JAVA 7 ,Ya I’ll discuss some code spinets in this article which will tell how JAVA 7 differ from last release.Here we go
                                       Java 7: Features & Enhancements

1)    Strings in switch
switch (database) {
case “oracle”:
case “sqlserver”:
break;
case “postgres”:
break;
case “mysql”:
break;
default:
}
Note:Now we can compare the string in switch case earlier all the data types were possible except string.So,they made it for string also,Which acc to me is best.

2)    try-with-resources statement
try (InputStream is = new FileInputStream(new File(“data.txt”))) {
// read file
// …
}
catch (IOException ex) {
// handle this error
-       try can now have multiple statements in the parenthesis and each statement should create an object which implements the new java.lang.AutoClosable interface. The AutoClosable interface consists of just one method.
void close() throws Exception {}
3)    Throw statement precisely
public void display(String[] args) throws IOException {
try {
loadFileToDb();
} catch (final Exception ex) {
System.err.print(ex.getMessage());
throw ex;
}

4)    Multiple catch statement
try {
doSomething();
} catch (Exception1 | Exception2 ex) {
printException1();
} catch (Exception3 | Exception4 ex) {
printException2();
5)    Binary integral literals
-          We can create numerical literals by adding binary notation prefix “0b”
int no = 0b1010;
System.out.println(“no = ” + no);
Output
no = 10
6)    Underscores in numeric literals
-          We  can include underscores in numeric literals to make them more readable. The underscore is only present in the representation of the literal in Java code, and will not show up when you print the value.
int tenMillion = 10_999_999_0;
System.out.println(“Amount is “ + tenMillion);
Output
109999990
7)    Improved type interface for generic instance creation
-          Java 7 tries to get rid of this redundancy by introducing a left to right type inference. You can now rewrite the same statement by using the <> construct.
Map> retVal = new HashMap<>();
8)    Advanced new I/O API
- This addition is also known as New I/O API (NIO).
See http://download.java.net/jdk7/docs/api/java/nio/file/Files.html
9)    Watch Service
-          It provides an API that lets you “listen” to a certain type of file system events. Your code gets called automatically when those events occur.
SO,These are some New Features of Java 7,keep reading :)

Difference Between OCPJP and SCJP

Yes! You are right both are JAVA certifications but the difference is SCJP keyword was used when Java was owned by Sun but when it is overtaken by ORACLE they introduced the term OCPJP which is Oracle Certified Professional Java  Programmer.
OCPJP is an entry level Java exam that is a prerequisite to a number of higher level Java-related certifications such as Oracle Certified Master, Java SE 6 Developer, Oracle Certified Professional, Java EE 5 Web Component Developer, Oracle Certified Professional, Java ME 1 Mobile Application Developer, OCP, Java EE 5 Web Services Developer, etc. After achieving OCPJP you have the opportunity to pursue any of these advanced Java certifications depending on your career plan and expected work roles.
Do you want to leave your legacy in the world of Java? Interested in starting with OCPJP? Get to understand the Java certification exam process. Invest in Java certification books, study guides and training to learn, practice and build Java concepts. It’s critical to have a working knowledge of Java technology before taking the exam. Visit forums to post questions and discuss the OCPJP certification exam preparation. And most importantly, get exposure to OCPJP certification questions through constant practice.
Hope you can seen that achieving Java certification can be exciting and challenging. GO AND START BUILDING YOUR LEGACY!.

What language should I learn?

What language should I learn?
This Very Important Article for Programming Beginners, Please Complete The Reading Of This Article
This question has been asked time and again here: What language should I learn? There are many different languages out there and it can be hard for somebody who has never programmed before to choose a new language. Every programmer has their own response to the question and it is usually their favorite language and they will give you the reasons why it is their favorite language to program with.
Before answering this question however, the person you are asking this question to should ask you a very important question. What is it that you want to program? Your answer to that question should effect their answer. So what do you want to program?
Your answer:
I want to develop desktop applications for Windows.
My Answer:
In that case you would be best learning a .NET language. The .NET languages have excellent support for creating GUI applications. They all have drag and drop features for dragging controls onto a form and coding the events that go with them. You could go with VB.NET, C# or C++.NET would work for this category of program. C++.NET is a good alternative and it would help you if you ever wanted to create native C++ applications, applications that do not require the .NET framework.
Your answer:
I want to write programs for Linux or Unix.
My answer:
In this case forget about learning a .NET language. There is the Mono port for developing C# programs in Linux but if you are serious about developing programs for Linux or Unix forget about .NET languages. The reason is they require the .NET framework and it is a Microsoft proprietary thing not supported outside of Windows. Look at C, C++ or Java. C or C++ because they have standards applied to them and they are the same on all platforms. Knowing how to write a C/C++ program on Linux is much the same as knowing how to write a program in Windows. Linux and Windows do have different libraries for many things, such as creating GUI applications, but the core of the languages is the same. Java is also a good because it can be run on any platform that has the JVM. A Java program in Linux is the exact same as a Java program in Windows.
Your Answer:
I want to write cross platform programs.
My Answer:
In that case definitely Java. Like I mentioned in the previous answer Java can be run on any platform that supports the JVM. The code is the exact same on any platform. If you write a Java program on one platform it will run the exact same way on another. You could also learn C/C++ for this. You would have to recompile the code to run on different platforms but C/C++ have standards applied to them and can usually be written to be run on different platforms with minimal changes.
Your Answer:
I want to write games.
My Answer:
In this case you would be best learning just regular C first and then moving up to C++ if you would like. Reason is that C is probably the fastest compiled language and is closest to the operating system. If you were ever to get a job as a game programmer you would more than likely use C or C++ in the work place. Learning them now would save you from having to learn them later. If you wanted to develop games for a console, C or C++ is again the way to go. I know you can create games for the Xbox 360 using C# and XNA. That is one exception to the rule and the reason is that the Xbox 360 is a Microsoft product and so are C# and XNA so the support is in the hardware. If you just want to develop Windows game it wouldn’t hurt to learn C# after C/C+++. It is not the perfect solution for developing games but it is a good framework and will more than likely continue to develop in the future. You can create many games using C# and XNA but there are times where you will need all of the processing power that you can muster. In those cases it is always better to code with C/C++.
Your Answer:
I want to create web applications.
My Answer:
Well, then you would probably want to start with simple HTML and CSS to learn how to create web pages. You could move on to things like Javascript and jQuery to add cool effects to your pages. Then you would want to go server side to develop persistent applications. For server side there are a few options. PHP, Perl, Python and ASP.NET would all be good for this. Some of this would depend on your hosting choice for the applications. ASP.NET is a Microsoft framework and the host would have to offer ASP.NET support with IIS. PHP can run on both servers: Linux and Windows. You can also create web applications using Java applets. There are many sites on the web that use Java applets. Pogo is popular site that hosts many games that were written in Java.
I’m sure that there are many other answers that a person might give to my question but those are some of the main ones and good, unbiased answers as to what you could concentrate on to accomplish those goals. There are also many other languages out there and new ones are being developed all the time. These are some of the languages that are used most often and the reasons that you would probably want to choose them.

.Net vs. Java {Five Factors to Consider}

The following are some points that IT managers should consider when weighing the choice of .Net vs. Java:
  1. Weigh the importance of application portability to your company.Java may not have entirely lived up to its “write once, run anywhere” promise. But Heffner says J2EE portability tends to be good for core components such as business rules, Java Server Pages and Enterprise JavaBeans.That, in turn, gives corporate users the negotiating leverage to present “a credible threat” that they’ll move an application to another vendor’s platform, something they can’t do with Microsoft, because the .Net framework runs only on Windows, he says.Microsoft submitted a portion of its .Net framework to a standards body, but Heffner estimates it amounts to only 10%, or “just enough for an application on some other platform to connect to a Microsoft server environment.” Although there are open-source efforts to get .Net to run on other platforms, none are credible yet, he adds. Portability has never been a concern for Microsoft, which advocates writing applications optimized to run on Windows for higher performance. Claiming that interoperability is more important than portability, Microsoft now tells users that .Net-based applications can share information with applications running on other platforms through Web services, in which XML-based messages are sent via the Simple Object Access Protocol.
    Bob Dutile, a senior vice president of enterprise architecture at Cleveland-based KeyCorp, says he’s interested in Microsoft’s approach, but he wants the option of selecting a best-of-breed server. “One of the reasons we are a Java shop is because Microsoft was too proprietary,” he says. “We like to have the opportunity not to be locked into one vendor all the time.”
  2. Take stock of your existing developer skills and infrastructure.Training developers and ripping out existing infrastructure can be costly, so an IT shop may favor sticking with the development environment that best fits its current situation.Pacific Life Insurance Co., for instance, didn’t hesitate to adopt .Net technology. Brad Sewell, an assistant vice president in IT at Newport Beach, Calif.-based Pacific Life, says his life insurance division didn’t consider Java because the division is “pretty heavily invested in Microsoft infrastructure.”The Home Depot Inc. in Atlanta, in contrast, is primarily a Unix shop and made a significant commitment to Java early on. But the decision wasn’t based solely on its Unix focus. “Java ran equally well on all of our hardware,” says senior IT manager Curtis Chambers, noting that his company also uses Windows, MVS and z/OS. “The end goal was a common development platform for all of our developers.” Because of .Net’s Windows-only limitation, Thomas Murphy, an analyst at Stamford, Conn.-based Meta Group Inc., says that for Unix shops, “the decision’s made for you.”
    “If you’re a mixed shop, you have to look at how you are mixed,” he adds.
    Murphy says IT managers should ask questions such as: Is Unix just the database platform, or does it have a role beyond that? How are you going to attach to legacy resources? Or are you going to try to develop new business logic on the legacy platform?
    Microsoft’s .Net environment allows developers to program in more than 20 languages, including Cobol, which could appeal to programmers who have worked in legacy environments. But since their .Net applications would need to run on Microsoft’s Common Language Runtime, they must weigh the infrastructure consequences.
    Developers skilled in using Microsoft’s Visual Basic tools for building less complex applications will find a similar learning curve whether they shift to Visual Studio .Net or J2EE, if they’re taking on full distributed computing and object-oriented programming, warns Frank Gillett, an analyst at Forrester Research Inc. in Cambridge, Mass.
    Whatever switch is made, it costs money. Gartner analyst Joseph Feiman says a Cobol-to-Java move, for instance, can cost an average of $57,000 per developer, once training costs, time, initial lost productivity and risk are factored into the equation. But he notes the costs can vary significantly, depending on programmers’ skills and the type of change they’re making
  3. Assess the complexity of the applications you will be building.Microsoft tools have an edge over Java for building applications that require rich graphical user interfaces and that deliver content to Web browsers, analysts say. Although Java tools are improving, Microsoft’s tools are generally considered easier to use.Heffner says there are “more knobs to turn” in a J2EE environment. But for complex, high-volume applications with lots of business rules, “that’s just the sort of knob-turning you need available,” he says. Those types of applications need to be more highly architected, and J2EE has more features to offer for session management, fail-over and load balancing than the Microsoft architecture does, Heffner says.For now, analysts say, J2EE may continue to be the preferred choice for highly scalable, mission-critical applications, and .Net may make more sense for applications that need a low-cost, quick turnaround. Natis says Gartner is advising clients to wait for .Net’s next release before they consider using it to build an application that will go beyond 1,000 concurrent users
  4. Investigate outside vendor support.Murphy says that users who buy major packaged applications will probably be driven to gain some Java skills, since enterprise software vendors such as SAP AG and Oracle Corp. lean toward Java.Another consideration may be the tendencies of the independent software vendors that develop applications for a particular vertical industry. Heffner says one insurance company chose J2EE because five of its six peers did.Analysts also note that tools and components may be more readily available for Java now, since .Net is so new. However, Microsoft, has already put out a thick binder entitled “.Net in the Real World,” featuring early adopters.
  5. Compute costs with care.On a straight cost basis, Microsoft presents an appealing option. Its Windows server operating system ships with a built-in application server, while pricing for the most popular Java-based application servers starts at $8,000 to $10,000 per CPU.There are other options. Hewlett-Packard Co., for instance, ships a free application server with its operating system, and JBoss is an open-source alternative, analysts say. But the top two choices, by far, have been San Jose-based BEA Systems Inc.’s WebLogic or IBM’s WebSphere.Rather than simply looking at the costs of application servers, Heffner advises clients to use a total economic impact model that takes into account costs, benefits and flexibility for future options. “In this case, you’re making a strategic platform decision that will affect not only this one application; it will affect the stream of application delivery that you’re going to pursue as a company over the coming years,” he says

Preparation tips for OCPJP- Oracle Certified Professional Java Programmer

OCPJP is the same as SCJP ,just the name change after Oracle overtake the Sun.
  • Which Is the book to be referred? I would say SCJP Guide By Kathy Sierra and Bert Bates is the best for OCPJP- Covers all the concepts required. There’s one more book by Khalid Mughal, which covers lot of concepts and has too much of information for the exam. Its Generics and collections chapters are exhaustive.
  • Try to focus on Generics as there can be some really tricky questions from there and also dont leave any concept unclear. Questions will test multiple areas
  • There will be few drag and drop questions on the exam which are pretty easy. One can go through the exercises given in Head First Java to get a feel of them.
  • Dumps are of no use- They may be able to get you higher percentage, but it will not add to your practical knowledge and will not clear your concepts.
  • Best place to hangout- JavaRanch- The best place for SCJP preparation.
  • Myth- SCJP Will get u a job- I would say proper preparation for OCPJP and a good score will increase your Java skills => Will higher your chances of getting a job .:)

So,What to choose Java or Net


This is my first blog entry and I decided to share my thoughts on a vague question: what to choose Java or Net ??


This question seems to be unanswered as both the languages are doing well.There are some points on which we can differentiate and can select which language to choose.So,Here we go


  • I won't go into a comparison of specific features, because to me Java and .NET are roughly equivalent in technical features. However, I will address some other not so technical issues. I will start from the most important: freedom.Freedomis the power to choose, the existence of alternatives. Some people think this is not good and they can argue on that. Some others, like me, think it is really good and, believe me, I can argue on this.Java is all about freedom, alternatives, open source. In Java you have to choose almost everything: the IDE (Integrated Development Environment), the application server, the operating system, the web framework, the persistence framework, and now even the language itself, and many other things. For every item in the previous list there are many, many options to choose and most of them are open source!

    On the other hand, .NET is very restrictive in choices. Officially it runs only on Microsoft windows operating system, it has only one IDE (Visual Studio which is very good), only one application server (Windows Server), only one web framework, only one persistence framework, but supports many languages! I admit that there are some alternatives (like Spring .NET and Hibernate .NET which are ports from Java) but they are used by very few people and to many are not even considered an option. The good thing is that all of the above are very good and will help you write awsome piece of software.


    So if .NET is such a complete solution without alternatives (or to be exact few of not so good quality), what's so wrong about it? Actually most .NET programmers find nothing wrong with it, probably because they don't have and have not used any alternatives. They all bring up the same argument: If you have two many choices how do you choose which one is better? In contrast, if you only have one choice and everyone believes it is very good, then you follow this choice and you are sure that you won't regret in the future. What is more is that you learn something today that you can use it everywhere you work. You can invest reading on .NET without being afread that you might read something else in the future.
  • Java unfortunately has many alternatives, and if you choose one you may have to learn another one or more in the future. So the bottom line is that Java requires a lot of reading which is not so good if your goal is to make money from writing software.The good thing with alternatives and especially open source alternatives is that by studying different solutions of the same problem you become a better and more mature programmer. You also save a lot of money because most of the alternatives in Java are open source. Ask a .NET programmer if they have licences for all the .NET features they use for every developer. Ask them when they deploy the application to multiple servers if they buy proper licences? In Java you can deploy an application to thousand of servers and not pay a penny. You can set up a development environment for a large team of developers and not pay a penny also.A professional Java programmer should have evaluated and used more than one alternative because on different projects some alternatives apply better. A .NET programmer does not have any alternatives and relies on Microsoft to provide him with better solutions to his problem.

    Most Java open source alternatives are of highest quality and outer perform .NET in some issues. Take Spring framework for example. Spring is one of the most amazing frameworks ever conceived. It was not conceived by Sun architects but by Rod Johnson and this shows that although Sun, an advanced high tech company, invented such a powerfull language as Java they did not bother to create a simple and powerfull framework like Spring (Sun J2EE is highly complex). In .NET there is no alternative application framework from Microsoft. However thanks to Spring team a port was made to .NET delivering Spring features to the .NET community. But how many people use Spring.NET? Very few because most of them they learned to rely on Microsoft for the framework. This is a closed minded approach.


    Consider another thing, many people on Java community might thought that after Oracle bought out Sun, Java's openess is questionable. But this is not true simply because Java is such an established technology that Oracle would not dare to destroy this golden egg trying to make money by putting an end to Java openess. Java wide acceptance is based on two things: it's very good design and performance, and a vast open source community constantly expanding Java.


    On the other hand, if something similar happened to Microsoft (!!!) what would happen to .NET. Well .NET is already closed so there would be no problem at all. So people using .NET tend to feel more secure in terms of vendor support whereas Sun did not go well because it made litle money out of Java due to its openess. Regarding this, the future will show the truth but I am confident that Java will never die because of Sun. There are so many communities willing to take over Java from Sun.


    To put an end to this article, the moral about Java vs .NET is: open or closed minded? Which one do you choose? Fortunately things in .NET begin to change but still .NET is years behing when compared to Java in terms of openess. However, the existence of .NET is a very good thing. You should know why: it gives another alternative to choose from, it makes you more mature by studying different solutions to the same problem (some of them are better conceived in .NET).