Today, while trying to use Docker Machine to create a local docker host on my macbook I was greeted with an exception as shown below.
$ docker-machine create -d virtualbox dev
Creating CA: /Users/abc/.docker/machine/certs/ca.pem
Creating client certificate: /Users/abc/.docker/machine/certs/cert.pem
Image cache does not exist, creating it at /Users/abc/.docker/machine/cache...
No default boot2docker iso found locally, downloading the latest release...No default boot2docker iso found locally, downloading the latest release...
Error creating machine: Get https://api.github.com/repos/boot2docker/boot2docker/releases: dial tcp: i/o timeout
You will want to check the provider to make sure the machine and associated resources were properly removed.
I tried to clear the local docker cache by deleting
~/.docker directory but each time I got the same exception. After a bit of trial and error I found out that it is because of the non-resolvable DNS server in the network settings. You can view your DNS server by going to System Preference > Network > Your internet connection > DNS. Make sure you are using a valid DNS server name. In case you don’t know a valid DNS server then you can use Google
s **220.127.116.11** server. Now, next time you will usedocker-machine create` command you will be able to successfully create a machine.
We all understand that we should code to interfaces. Interfaces give client a contract which they should use without relying on the implementation details(i.e. classes). Hence, promoting loose coupling. Designing clean interfaces is one of the most important aspect of API design. One of the SOLID principle Interface segregation talks about designing smaller client-specific interfaces instead of designing one general purpose interface. Interface design is the key to clean and effective API’s for your libraries and applications. Continue reading Day 5 — Default and static interface methods in Java 8
Every Java developer whether beginner, novice, or seasoned has in his/her lifetime experienced
NullPointerException. This is a true fact that no Java developer can deny. We all have wasted or spent many hours trying to fix bugs caused by
NullPointerException. According to
NullPointerException JavaDoc, NullPointerException is thrown when an application attempts to use null in a case where an object is required.. This means if we invoke a method or try to access a property on null reference then our code will explode and
NullPointerException is thrown. You can follow the 7 Days with Java 8 series at http://shekhargulati.com/7-days-with-java-8/ Continue reading Day 4 — Let’s write Null free Java code
On day 2, you learned that Stream API can help you work with collections in a declarative manner. We looked at the
collect method, which is a terminal operation that collects the result set of a stream pipeline in a
collect method is a reduction operation that reduces a stream to a collection. The
collect method takes a
Collector which let us implement functionalities like group by, partitioning, very easily. Continue reading Day 3: Let’s collect data using Stream API
On day 1, we learnt how lambdas can help us write clean concise code by allowing us to pass behavior without the need to create a class. Lambdas is a very simple language construct that helps developer express their intent on the fly by using functional interfaces. The real power of lambdas can be experienced when an API is designed keeping lambdas in mind i.e. a fluent API that makes use of Functional interfaces(we discussed them on day 1). Continue reading Day 2 — Let’s learn about Streams
From today, I am kicking off 7 Days with Java 8 blog series with first blog on Lambdas. One of the most important features in Java 8 is the introduction of Lambda expressions. They make your code concise and allows you to pass behaviour around. For some time now, Java is criticised for being verbose and for lacking functional programming capabilities. With functional programming becoming more popular and relevant, Java is forced to embrace the functional style of programming. Else, Java would become irrelevant.
Java 8 is a big step forward in making the world’s most popular language adopt the functional style of programming. To support functional programming style, a language needs to support functions as first class citizen. Prior to Java 8, writing a clean functional style code was not possible without the use of an anonymous inner class boilerplate. With the introduction of Lambda expressions, functions have become first class citizen and they can be passed around just like any other variable. Continue reading Day 1 — Let’s learn about lambdas
Today I decided to play with Android and build a simple app. I downloaded the latest version of Android Studio for Mac from the official website http://developer.android.com/sdk/index.html. As soon as I tried to install the Android Studio on my Mac book (OSX YoseMite 10.10.2) I was greeted with a weird error message as shown below.
Internal error. Please report to https://code.google.com/p/android/issues
java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.SunJCE_b
You get this error because you need to have Java 6 installed on your Mac. To get rid of this error, just download the Java from this link https://support.apple.com/kb/DL1572?locale=en_US. Once Java 6 is installed, open the Android Studio app again and you will be able to work with Android Studio :)