Tuesday, 28 June 2016

Installing Java Application As a Windows Service

It sounds like something you’d never need, but sometimes, when you distribute end-user software, you may need to install a java program as a Windows service. I had to do it because I developed a tool for civil servants to automatically convert and push their Excel files to the opendata portal of my country. The tool has to run periodically, so it’s a prime candidate for a service (which would make the upload possible even if the civil servant forgets about this task altogether, and besides, repetitive manual upload is a waste of time).

Even though there are numerous posts and stackoverflow answers on the topic, it still took me a lot of time because of minor caveats and one important prerequisite that few people seemed to have – having a bundled JRE, so that nobody has to download and install a JRE (would complicate the installation process unnecessarily, and the target audience is not necessarily tech-savvy).

Sunday, 26 June 2016

Functor and monad examples in plain Java

However introduction to monads, albeit very much related to reactive programming, didn’t suit very well. So I decided to take it out and publish separately as a blog post. I am aware that “my very own, half correct and half complete explanation of monads” is the new “Hello, world” on programming blogs. Yet the article looks at functors and monads from a specific angle of Java data structures and libraries. Thus I thought it’s worthwhile sharing.

RxJava was designed and built on top of very fundamental concepts like functors , monoids and monads . Even though Rx was modeled initially for imperative C# language and we are learning about RxJava, working on top of similarly imperative language, the library has its roots in functional programming. You should not be surprised after you realize how compact RxJava API is. There are pretty much just a handful of core classes, typically immutable, and everything is composed using mostly pure functions.

Tuesday, 21 June 2016

Java Arrays Sort decoded

Sorting is one the first algorithm that we learn in computer science. Sorting is such an interesting area that it has around 20+ algorithm and it is always difficult to decided which one is best. Sorting algorithm efficiency is measured in terms of time taken & space required. Some time bubble sort is best because it has no space requirement and for device where space is constraint or random access of element is not possible then it can be good fit .

These days we tend to use library sort functions, most of language library sort function is adaptive and it uses best algorithm depending on size of data.

Friday, 10 June 2016

How to Remove Duplicate Characters from String in Java

Sometimes, a choice is restricted by putting additional constraint put by the interviewer, that's why it's better to know multiple ways to solve a problem. This not only helps in understanding the problem better but also on comparative analysis.

Solution 1 - Replacing duplicate with NULL character

Our first solution is coded in the method removeDuplicates(String word), it takes a String and returns another String without duplicates. This algorithm goes through each character of String to check if it's a duplicate of an already found character. It skips the duplicate character by inserting 0, which is later used to filter those characters and update the non-duplicate characters.

Tuesday, 7 June 2016

How to Master Your Java Memory (and Save Your Programming)

Solve App Problems 10x Faster with AppDynamics – Monitor production apps at code-level depth with minimal overhead.

You spent countless hours working out the bugs in your Java application and getting its performance where you need it. During the testing, you noticed the application getting progressively slower over time, outright crashing or exhibiting poor performance. You go through your code and make sure you haven’t missed anything else that could cause these problems. Ultimately, you admit that you’re dealing with a memory leak. Java’s garbage collector does what it can to help with these leaks, but there’s only so much it can do when you’re running into major issues. You need a way to identify what’s causing your memory leaks, ways to address the issue and understanding of the role Java garbage collection plays in your overall application performance.

Wednesday, 1 June 2016

Java Certification: To Cert or Not to Cert

Professional certification is always a bit of a controversial subject, with benefits vs. cost/time debated by those who are eligible.  With Oracle’s Java certifications, I hold the opinion that there are two primary audiences that stand to benefit:

  • Those who are starting a career in software. Solid work experience with demonstrable code is always going to be a top hiring consideration by potential employers.  However, in the absence of that, Java certifications are an objective way to demonstrate a base level of proficiency in a related skill.  With a junior programming position opportunity, where candidates have a limited work history, a certification could be the difference between staying in the resume pile and getting into the interview chair.  Similarly, if you have a solid work history, but are applying for a job that focuses on an API you haven’t used on a project, a certification could help bridge that gap in your resume.