Category Archives: Java

Creating console based applications in Java

Writing a console based app might sound strange to some Java programmers but for some specific purposes writing a console based application is a necessity. For example let’s say I have write an application which needs to be monitored via SSH. In that either we have to come up with some elaborate command line arguments or special purpose log files. However another approach is write the application and give it a text based GUI which is accessible via textual console like putty, konsole, xterm, gnome-terminal etc. The closes thing that comes to mind is ncurses coming from the C world. We have something similar for Java also available and based on some reports I feel that they are stable enough to be used in any production environment which have need for a light weight, low bandwidth textual client.

  1. Lanterna – 100% Java solution. Very interesting.
  2. Blacken – Not a curses library an has it’s own renderer. The API is however curses-like.
  3. Java Curses Library – It’s built upon the Unix curses windowing system.
  4. Charva – A reliable tool that allows rapid building of UI using OOP approach. Existing UI programmers will definitely like it. It however uses JNI.

 

Production helper utility for Java team

I have been thinking about going through some of these tools to get more productive in deploying / delivering Java based web apps to the team:

Drop Jar is a helpful tool to share jar files.

Drop Wizard is a helpful tool for delivering production read jar files.

Spring Boot allows developers to create web apps easily using convention over configuration.

Shade Plugin allows a Maven based build to overcome duplicate / incompatible versions of libraries. If you have been bitten by incompatible log files you know what I mean.

Eclipse Maven – Download Sources and JavaDoc

Eclipse Maven integration has improved quite a bit and I find it somewhat comparable to the excellent Maven integration provided by Netbeans. I recently required to debug third party jars and I needed their sources for this purpose and as a general practice I always download the javadoc for any third party library I use. This is easily done in Eclipse using the following approach.

Do it per project

Eclipse Maven Context Menu for Project

Eclipse Maven Context Menu for Project

Do it for all projects

Eclipse Maven Properties Dialog

Eclipse Maven Properties Dialog

Problem found with GWT installation on Chrome

Problem found with GWT installation on Chrome

The idea with GWT is that you need to install a Google Web Tool Kit Plugin on Chrome to realistically debug GWT application in your browser. On Firefox browser the plugin is already outdated and probably discarded so Firefox is no longer an option. However on Chrome we still have a plugin and it should work ideally. However my efforts to debug my GWT apps hit a road bump when I encountered the following error when starting chrome.
At the time of starting chrome:
In the Extensions view:

At the moment I just re-dragged the GWT plugin into chrome and resumed my work but I have a haunch that this is not the end of the problem and it will come back to haunt me. I did some search on the internet and I found the following link where people have discussed this problem. The most potent solution which I have not tried yet is listed here for future reference.
Link #1:
https://code.google.com/p/google-web-toolkit/issues/detail?id=7569
Quick fix that might help:
1. Right click on the chrome icon>Properties>Shortcut
2. Add in target: –enable-easy-off-store-extension-install
3. Open chrome and navitage to extensions ( chrome://chrome/extensions/ )
4. Drag and drop on it the plugin (should be in your download folder if you tried to install it before and didn’t succeed)
Link #2:
http://stackoverflow.com/questions/11901915/installing-gwt-plugin-in-chrome
I think the easiest way to install the plugin is, to load the google chrome Browser with the flag –enable-easy-off-store-extension-install With this flag you disable this “feature”.
Link #3:
http://techie-buzz.com/browsers/chrome-blocking-extension-apps-scripts-chrome-web-store.html

Finally Solution:
I finally gave up after trying all the above approaches and none of them actually worked. I hit the following link:
https://www.google.com/chrome/browser/?platform=win&extra=devchannel
I downloaded the latest devchannel version of Chrome and re-installed the GWT Developer Plugin. This seems to have fixed the problem, however I am not really sure how this has affected my chrome installation’s stability but atleast GWT Dev Plugin works and it’s good enough for now.

Gradle the build and dependency management tool

I recently had a chance to evaluate and Gradle and I am impressed by the Groovy based scripting feature it provides. It is really possible to make sophisticated build scripts using scripting constructs like looping and if checks. The functionality to selectively disable parts of the build on the fly and make build decisions based on some condition really makes it a winner and a clear choice for Java based development. It has support for using Apache Maven and Apache Ant build scripts as well inside the Gradle build script which means current investment in Apache Ant and Apache Maven remains intact. I think I am going to give Gradle a serious try in my next project and if it performs as I hope for I am going to switch to Gradle for good.

I am die hard Apache Maven fan for all my Java based development and configuration need. In spite of all the criticism it has received over the years I have remained a staunch supporter of Maven. I delved in Apache Ant whenever I needed some extra punch in my Maven build scripts. The XML based configuration although at times felt very verbose but it did work and it was possible to write portable build scripts that worked everywhere. However if Gradle allows me to write Groovy based scripts inside my build script then I think its time to switch to Gradle.

JavaFX on the Horizon

When JavaFX was launched in 2007 I had thought that Sun had already lost the race of RIA and RCP platform to Silverlight and Adobe Flex. Plus the fact that JavaFX required the developer to learn a new scripting language was a big turn off. Although it’s not a big deal to learn something new but re-training an entire team on something new when a better replacement is available was simply a tough thing then. I could have designed some of my projects using JavaFX but I consistently used Swing as I felt it was the better framework.

Fast forward to 2011 JavaFX was re-launched and the need to learn a new scripting language is no longer there. It is possible to reuse developer’s Java knowledge and become productive in JavaFX. If I had to start a new Java Desktop based project I would definitely try JavaFX before delving in Swing. Agreed Swing is a proven and mature UI framework but there are limits to what Swing can do. Maybe JavaFX has a future now that Oracle is pushing JavaFX 8 later part of this year. JavaFX 2 to JavaFX 8 seems like a quantum leap in terms of version and maybe it might counter balance Swing in terms of performance and maturity, but again who knows the future 🙂

I personally think now that Silverlight is a stalled technology and it’s unbelievable that Microsoft was not able to push it to dominance. It is grimly evident with the news that Netflix ditched Silverlight in favor of HTML5. Adobe Flex looked like a clear winner 6-7 years ago but given the fact that now it is open source I think it is clear that Adobe is politely walking with away from Flex with some contributions from it’s end now and then from their ‘dedicated team’.

This brings us back to JavaFX and I must honestly say that I still find it unbelievable that it is still around and might become the UI framework of choice of Java based desktop application software. I don’t think JavaFX has a future inside browser but it might become a framework of choice for Java’s desktop requirements.

For browser based development nothing beats HTML5 I think. Love it or hate it I think it is bound to be around for considerable time to come. It however remains to be seen how well it is supported by different browser both on mobiles, tabs and desktop OS.