Tuesday, December 29, 2015

Resolving Unsupported major.minor version 51.0 error

Have came across this error on number of occasions.

Unsupported major.minor version 51.0 error

The reported major numbers are:
J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45
(Source: http://en.wikipedia.org/wiki/Java_class_file)



This java error comes, if you are compiling your code in java 1.7 and running it in JRE of lower version. To fix this, either you run the java class in a higher version (1.7 in this case) or instruct the compiler to create a 1.6 complaint byte code.

So, major number's represent the compiler version of the compiled bytecode here. And, may be, minor means, the JRE version you are trying to execute it in. (That's my analogy, I may not precise here, but it works for me, to recall.)
 
Fixing it in Ecplise project:
This can be done in eclipse , by right click the on the Project folder => Properties. Then choose compiler option => choose 1.6.

Fixing it in ItelliJIdea project:
File => Settings->Compiler => Java Compiler => Choose 1.6 under the Project byte code version drop down

There is a interesting story behind the convention of these numbers. If you are interested to read about it, you can find it here : James Gosling private communication to Bill Bumgarner (Source Wikipedia)





Thursday, December 24, 2015

Considering migration to cloud? Here are some tips and lesson learnt.

Recently, I was involved in migration to Openshift based cloud environment (enterprise version). We were migrating some of the apps based on the tech stack Java/JEE and back-end as oracle.

Though my organization has facilitated a dedicate infra support team, such migrations are still never easy to deal with.

Here are some of the lessons learned and point to consider if you are planning to place your apps into the cloud or, for that matter a new infra.

Do not show off and become the first one ever to do it in your company. You can be applauded, but might as well have to spend quite a few sleepless night depending upon number of switches you are turning on in the production environment.

Get a free ride or just walk in park. Get your feet wet by writing a simple app or a few servlets in a trial or evaluation server. Or, just watch someone help video/help manuals.

Talk to people who are doing the same thing in your company and as and when situation arise help them to get thru some technical issue or problem. The reward comes when you get stuck. :)

Housekeeping time. Remember, this is best time to get rid of your technical debts or any refactoring or code cleanup plans you had been keeping in the back burner  due to schedule crunch.


Analyze the impacts properly while committing yourself for the migration. You might not be knowing all the small little dependency. Following are some of the important stuff to lookout for:
  • DB Connection pooling code
  • Legacy code
  • Utilities like sending mails
  • Codes that reads a file like image or properties, from the codebase or the file system
  • Logging mechanism
  • LDAP Connections
  • Any 3rd party https calls that needs to be white-listed or needs to be added into 
  • Any other code that are based on the environment (for example, server provided API/tool etc.)
  • And last but not the least, static URLs which refers to your application 

Keep moving. When you are stuck on one particular issue, don't keep working on the same for long. Move ahead, solve the other small hanging ones. At the same time, keep following up with the support or any kind of help you can seek from a larger community. Usually, these are some small screws, which we some times just don't realize ourselves until may be, the very next morning. So, don't worry. Stay calm.

I think, these are some basic yet very relevant points I can tell from my experience. In case, you have some story or comment related with this, please do leave a comment.

Good luck in case you are into a migration phase and stumbled on this blog post. :)

Wednesday, September 2, 2015

Facade Design Pattern - A brief note

What is Facade Design Pattern?


Facade, pronounced as fuh-sahd, originated from french façade and italian facciata, meaning the face of a building, esp the main front or a front or outer appearance.

Lets see what it means in the world of design patterns.There are two important part of the problem it addresses:
a) The subsystems within a system 
b) Interaction between subsystems of two different systems. 

Sometimes the interaction becomes so complex, that we need to create a layer abstraction which can help in achieving simplicity by introducing simple interface to communicate.


Definition

Now lets see the official GoF definition, Facade Pattern: a single class that provides a unified interface to an entire subsystem.

Use case or example of Facade


There are many use case if we look through the interactions between various systems and their components. One such example is the interaction that happens between various components in Supply Chain Domain. The below image explain one such interaction. Although this is not exact interaction but this pretty much explains the crux of Facade.

Prototype

Prototype is another creation pattern. Intent:  - Intent is to create objects by cloning existing instance  - Specify the kinds of obj...