Tag Archives: java

Azure Service Management APIs: The Old APIs That Works

After the initial bad experience with the new Azure Resource Management APIs, I took a different approach – try the old Service Management APIs. While transitioning from old system to new system, the old one may still be the best for an unexpected long period of time. Like VMware vSphere Client, VMware has declared end of life many times, but it’s still the favorite for most customers, while the future Web Client remains “future” since 2011.

Posted in Cloud Computing, Software Development | Also tagged , , | 3 Responses

Amazon Web Service Java SDK Tutorial: List All Networks

In my previous posts, I showed samples on virtual machine creation, virtual machine instances listing, storage volume listing. This sample shows how to list all the networks that you have.

With the information about your networks, you can get all the private and public IP addresses.

To run the following sample, you can check out the previous post for the pom.xml file and how to get AWS credentials from AWS console.

83793b6779908aa409055cfa2354a382012

Posted in Cloud Computing, Software Development | Also tagged , , | 1 Response

Amazon Web Service Java SDK Tutorial: List All Volumes

In my previous posts, I showed samples on how to create a new virtual machine instance, and how to list all the virtual machine instances you own. This sample shows how to list all the disk volumes that you have.

To run the following sample, you can check out the previous posts for the pom.xml file and how to get AWS credentials from AWS console.

package org.doublecloud.awssample;
 
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.DescribeVolumesResult;
import com.amazonaws.services.ec2.model.Volume;
 
public class AwsEc2ListVolumes
{
  public static void main(String[] args) throws Exception
  {
    AWSCredentials credentials = new PropertiesCredentials(AwsEc2ListVolumes.class.getResourceAsStream("/AwsCredentials.properties"));
    AmazonEC2 ec2 = new AmazonEC2Client(credentials);
 
    DescribeVolumesResult volReq = ec2.describeVolumes();
 
    int count = 1;
    for (Volume vol : volReq.getVolumes())
    {
      System.out.println("Volume " + count   + "\n Details: " + vol);
      count++;
    }
  }
}

The output will be something as follows:

Posted in Cloud Computing, Software Development | Also tagged , , | 3 Responses

Amazon Web Service Java SDK Tutorial: Create New Virtual Machine

In my previous post, I showed a sample on how to list virtual machine instances. While that is helpful, maybe even more so is to create a new virtual machine. Here comes another sample that creates new virtual machine instance using the Amazon Java SDK.

Posted in Cloud Computing, Software Development | Also tagged , , | Leave a comment

Amazon Web Service Java SDK Tutorial: Simplest Hello World

I looked at Amazon Web Services SDK a while back and started to work with it recently. While searching it the Internet, I got all the results on the first two pages on Google pointing back to Amazon, which is great. After reading these documents, however, I got headaches. Why? For one thing, they are pretty long and sometimes run over different Web pages. Do you want to read for an hour to get your first program running? Or you are like me who would like to get my first program like Hello World to run in 5 minutes or even shorter. We should then read more if we don’t understand some parts. If you have gone through the Amazon documents, you’d know it’s impossible.

Posted in Cloud Computing, Software Development | Also tagged , , | 1 Response

Authenticating with LDAP Server in Enterprise Java Apps

Creating a new user with password is easy for application developers, but not so convenient for the users. Increasingly we have more passwords to remember than we should. It’s now a common practice to authenticate users with LDAP or ActiveDirectory. If a user changes her password in LDAP server, she doesn’t need to do anything in the app.

Posted in Applications & Tools | Also tagged | 1 Response

How to Print out Http Request Headers in Java Servlet

While developing a new project, I need to check a request header from client side AJAX call in Javascript. This is not a difficult problem at all, but I found it’s pretty helpful with the headers printed in the log file, especially while debugging. The following code snippet iterates through all the headers and add their values into the string buffer, and further into logger of the Servlet. Notice that the value of a header is not a primitive value, therefore the inner loop is needed to go over each element.

Posted in Software Development | Also tagged , | 1 Response

How to Pretty Print JSON with Gson and Jackson

In my last article, I compared two leading JSON APIs in Java: Jackson and Gson. If you have tried the samples there, you may have noticed that the two samples print the JSON string into one line. While it’s pretty efficient for machine, it may not easy for human consumption when the Json string is long. Sometimes I have to copy a long Json string into an editor to find out what are there.

Posted in Software Development | Also tagged | Leave a comment

Tricks and Tips on Paypal Integration

After releasing the DoubleClou ICE, I finally got some time to write what I had experienced with Paypal as a user and developer. Because the DoubleCloud ICE is productivity tool that sells within $100, I want people to buy it online quickly and easily. Given Paypal’s #1 position in online payment, I turned to Paypal without much thinking. After that I had gone through all the integration process from initial research to bring the site to production.

Posted in Software Development | Also tagged , , , | 1 Response

Gson vs Jackson: Which to Use for JSON in Java

There are many JSON libraries for Java. While it’s nice to have many options, it can also be frustrating to decide which one to use. If you do an online search, you will find many opinions and all these libraries are used somewhere. When in doubt, the best thing to do is: stop searching and start coding. It doesn’t take long to get the ultimate answer for you.

Posted in Uncategorized | Also tagged , , | 6 Responses

Rotating Log Files with Logback

Just fixed an issue related to configuration of Logback recently. You may be wondering why the Logback is used given that it’s much less known than Log4j and Java Logging. Very good question. This page from Logback may provide you some insights. I haven’t tested the performance, but it’s said to be 10 times faster than others. There is also an independent version of comparison on StackOverflow. After browsing it, I didn’t have an impression that I have to use one over the other.

Posted in Software Development | Also tagged , | 1 Response

OAuth For HTTP and REST API Authentication

Authentication is to verify users are really whom they claim they are. Since its inception, HTTP(s) has used different approaches like BASIC authentication, Form based authentication. Both require passing the user name and password from the client to the server. It’s definitely not good idea to use HTTP because the password is passed as it is or with very limited encoding like BASE64 – very easy to intercept the IP packets and extract out the password. When HTTPs is used, it’s much harder to get the password as all the traffic are encrypted. Still it’s subject to attacks like man-in-the-middle.

Posted in Software Development | Also tagged , , | Leave a comment

Gradle for Building Java Applications

Building software is a very important part of software development cycle. In the C/C++ age, we used make and continue to use it today. When it came to Java age, two important build tools emerged: Ant and Maven. The former is very similar to make, but instead of script it uses XML. Both make and Ant describe HOW to build software in steps. The Maven takes a quite different approach – it describes WHAT the built software is using XML, and leaves the how to the Maven and its plugins.

Posted in Software Development | Also tagged , | 1 Response

Parsing, Modifying, and Generating Java Source Code With Javaparser

It’s not common to do something with Java source code programmatically, but I find the javaparser project is very handy if such a use case comes up. It’s a Java 1.5 parser with AST generation and visitor support. With the API, you can access various elements in the source code like class, methods, statements, javadoc, comments, etc.

Posted in Software Development | Also tagged , , | 3 Responses

Java 8 New Features: JavaFX

The JavaFX is not really a new feature, but it’s the first time for it to make into a major Java release. JavaFX has a pretty long history as the next big thing for building cross platform GUI applications. Initially it has its own scripting language and hasn’t made its way in the Java community. The reason is simple: although the JavaFX has richer features on graphics, it does not seem worth learning a new language for it. For a long time, I was wonder why Sun didn’t use the investment to improve its Swing library which has much bigger audience than JavaFX.

Posted in Software Development | Also tagged , | 2 Responses

Java 8 New Features: Nashorn JavaScript Engine

When JavaScript was created, it had not much to do with Java. It’s named as such maybe due to the popularity of Java language at that time. But over the years, JavaScript has gained its own popularity and dominated the client side of Web applications. There are even some work for JavaScript to extend its reach to the server side, for example, Node.js.

Posted in Software Development | Also tagged , , | Leave a comment

Accessing Database in Java with JDO

I haven’t written Java code to access relational database for a while. Over the years there have been lots of progresses, especially with various Object Relational Mapping (ORM) frameworks. With these frameworks, accessing relational databases becomes pretty easy. In some cases, you don’t have to know SQL at all. Of course understanding SQL is always an advantage.

Posted in Software Development | Also tagged , , , | Leave a comment

Java 8 New Features: Map Reduce Made Easy With Stream APIs

In my article, I introduced the new Stream API. With the new stream APIs, you can apply many different operations on the stream, including the map-reduce functions.

One of the most famous framework to support map-reduce for large scale data processing, a.k.a. BigData, is Hadoop as I introduced almost two years ago here. Data processing wise, the Java 8 stream API can do pretty much the same. Here is a quick sample that shows how it count number of words in string. There are significant differences in how they are implemented and the cases in which they should be used. Let’s discuss them after the sample.

Posted in Big Data, Software Development | Also tagged , , | Leave a comment

Java 8 New Features: Stream API

Java Collections APIs consists of well designed classes and interfaces for managing all sorts of data structures. With Java 8, there is a new enhancement called Stream API related to the Collection APIs (see What’s New in JDK 8). I spent some time to study the new feature last week as part of my effort to bring myself up to date with Java 8.

Posted in Software Development | Also tagged , , | 1 Response

Java 8 New Features: Method Reference

Coming with lambda feature in Java 8 is the method reference feature. It allows programmers to use methods as variables, and parameters to other methods. It works for class constructors too, where the method name is unanimously “new.’

There are four types of method references per Oracle documentation. Syntax wise, they all look similar with double colons as shown in the following sample code.

Posted in Software Development | Also tagged , , | 2 Responses
  • NEED HELP?


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.