Archive

Archive for the ‘Software Development’ Category

Simplest Way to Encode Base64 in Java

February 3rd, 2014 4 comments

Base64 is a straight forward encoding for binary data into readable characters (RFC 4648 and RFC 2045). Although you can do it by yourself, more often than not you would like use an existing library, for example, Apache common. If you just need the Base64 encoding but have to import the whole library, it’s not a good idea. There is actually a better way without introducing extra dependency, which is to hack Java standard library 1.6.

Securing Thrift Traffic: Uncommon But Important Use Case

January 22nd, 2014 No comments

Thrift is mostly used for distributed systems which run mostly in house. There is no strong demand for securing the traffic on the wire. There are however use cases in which the Thrift services are exposed as a public service. In these use cases, the Thrift traffic should be secured with SSL/TLS. It comes with a price which more work on client and server on encryption and decryption. This is not a big deal for light load server, but for heavy load server it could be a problem. It can be mitigated with hardware acceleration on load balance servers between which and the client can be SSL, but not after that to the Thrift server.

Categories: Software Development Tags: ,

Thrift Client in Python: Hello World Sample

January 20th, 2014 No comments

As mentioned in my last post, Thrift is a cross-language and cross platform RPC framework. We’ve seen how a Java based Thrift server and client work there. Let’s take a look how to write a quick python script that connects to the Java Thrift server. It’s all possibe to write a Python based Thrift server, but probably not what most people want to do due to performance and scalability.

Announcing vijavaNG: Much Lighter and Faster with Commercial License and Support

January 8th, 2014 17 comments

Since I left VCE four months ago, I have been working intensively on a commercial version of the open source vijava API supporting all versions of vSphere APIs (5.5 is the latest). If you have used the open source API, you know the vijava is much faster than other alternatives. Since its debut, it has been used in many commercial products from companies like Cisco, EMC, HP, etc.

Parsing XML in Python: A Quick Working Sample

December 22nd, 2013 No comments

In my recent consulting projects, I used Python on various projects including the VMware pyVmomi () for managing vSphere. Because XML is ubiqutous these days, I had to use XML for configuration, passing information, etc. Parsing XML is a very basic part of using XML. The following sample code can achieve the same thing (print out may be different) as the C# sample that parses XML I wrote before.

Categories: Software Development Tags: , ,

SSH in Python: A Quick Working Sample

November 14th, 2013 4 comments

In one of my recent consulting projects, I had to use SSH from Python. After a little research, I ended up with using the paramiko package as library.

Installing Libraries

To download the paramiko package, just check out this link. What I downloaded was paramiko-1.12.0.tar.gz. After it’s uncompressed with 7-Zip to a temparary directory, just issue the following command and the needed library got installed into the site-packages directory.

c4296bd2326c4ea0026d2b21cd79641d010

How to Monitor New Changes of Log File with Java

October 30th, 2013 1 comment

If you have a log file that you want to monitor the incremental changes, you can use the following simple code. Whatever new log entries written to the log will be quickly picked up and printed out to console. It does not interfere with the application that writes the log file. To test the code, you can use any text editor to append more entries to the end of log file (don’t forget to save it).

Categories: Software Development Tags: ,

How to Run Maven Based Java Application From Command Line

October 28th, 2013 2 comments

It’s pretty straight forward to run Maven based projects in NetBeans IDE. For some projects that involve console related capabilities, you have to run it from OS console. One example is projects that use the JANSI APIs for colorful console output (see my last post for a sample). If you run the code within IDE, you won’t see the colors as would in a console.

Categories: Software Development Tags: , , ,

Writing Colorful Console Output in Java

October 20th, 2013 No comments

Almost all of the Java console application I had seen were boring black background and white fonts on Windows. This can be changed using a small Java library called Jansi which is open sourced under Apache 2.0. The download link can be found at its project home. The source code is also available on Github here.

Categories: Software Development Tags: ,

Parsing Command Line in Java

October 10th, 2013 2 comments

If you develop a command line tool, you would probably need to parse options and arguments. In Java, you can use Apache Commons CLI to handle the parsing. Since I don’t write much command line program, I don’t need these tools. While reading vCO API sample, I found one command line tool called args4j which is written by Kohsuke Kawaguchi who had created the famous Hudson/Jenkins server.

How to Add Copyright Notice in JavaDoc

October 8th, 2013 1 comment

While using Netbeans IDE to generate Javadoc for a Maven project, I noticed the generated pages has a default copyright notice at the bottom of every page, say “Copyright 2013. All Rights Reserved.” Because it’s default, it does not show the name of copyright owner. To change it, I found it’s not really straight-forward, therefore it may be worthwhile to share it.

GUI Libraries for Angular Javascript Framework

September 16th, 2013 2 comments

Angular is a fantastic JavaScript framework that simplifies the MVC for Web applications. Like jQuery, it does not come with a library of GUI widgets and CSS themes – it just does what it’s supposed to do and does it well. If you are a developer, you would most likely need a GUI library to build a modern and interactive Web GUI. That is why I spent a bit time to research on this.

Angular JavaScript Framework: Interacting with Java Servlet Backend

September 10th, 2013 30 comments

In my last article, I introduced the Angular JavaScript framework with working samples. Among all these JavaScript frameworks, I think Angular is the first one that does it right (I can be wrong on this as my exposure of JavaScript is limited). If your project needs Web GUI for example vSphere Web Client plug-ins, it’s definitely a good choice to consider.

Angular JavaScript Framework: MVC Simplified in HTML5

September 8th, 2013 3 comments

At VMworld 2013, I bumped into my former colleagues at VMware who work on the new vSphere Web Client. Faster than I thought, the new vSphere Web Client started to support HTML5 partially with Angular JavaScript Framework. I haven’t looked into the details but that is something the community should be excited about.

Securing REST APIs or Web Application With Basic Authentication

September 5th, 2013 No comments

If you implement REST Web Services, you want to secure them. The simplest approach is to use the basic authentication () with user name and password. To protect all the resources behind the REST APIs, you can simply implement filter as introduced in Java Servlet 2.3 ().

REST API Service Made Easy with Jersey Framework in Java

August 25th, 2013 16 comments

Because REST APIs are easy to get started with, I see more products are adopting it for remote management APIs. To implement the REST on the server side, you can use different programming lanaguages and frameworks. In Java, you can use the Jersey framework which is a reference implementation of the JAX-RS (JSR 311 & JSR 339).

Parsing XML in C#: A Quick Working Sample

August 9th, 2013 16 comments

Just started to work on hacking the Web application of vCAC and REST APIs in C#. As expected, the XML processing is an indispensable part for that purpose. I have worked on C# on and off in the past, but never as consistently as on Java. To get myself familiar with the related C# APIs for parsing, I coded the following sample code.

c4296bd2326c4ea0026d2b21cd79641d040

Categories: Software Development Tags: , ,

Unit Testing with JUnit 4 in Java: Quick Introduction and Simple Samples

August 5th, 2013 1 comment

Unit testing is an important part of software development because it helps capture bugs before it moves on to QA or even customers. However, it’s not part of the end product therefore whatever you invest in unit testing will not yield any direct result but indirect result in better quality of your product. So at one side, you want to do it more for better quality; on the other side, you want to minimize it for less investment. It’s therefore a tricky trade off for best ROI. For more discussion, see here.

Java Native Access: What, How, and Performance Comparison

July 1st, 2013 No comments

While trying the libvirt Java binding, I came to know Java Native Access (JNA) which is a great alternative to Java Native Interface (JNI). As it’s said, no one can claim to know all about Java after 1.5. It’s now 1.7 (although majority of us are still with 1.6) and it’s even less likely. I am no exception.

Tip For Tech Bloggers: Easy Way to Document Command History

June 10th, 2013 1 comment

While writing technical blogs, it’s always nice to include commands and scripts that readers can try on their own. I find it a bit challenging to accurately document these in steps while intensively testing or debugging something by myself.

There are actually commands that faithfully list all the commands you typed. You can then clean them up for your posts. In the following, I introduce how to do these on Linux, Windows.

Linux

Categories: Software Development Tags: ,