Getting Started with the Java Streams API
The Streams API was added in 2014 with the release of Java 8 so you’ve almost certainly got it available today. It is used to pass a series of objects through a chain of operations, so we can program in a more functional style than plain iteration allows. Still, when working with collections many developers still reach for the classic
In this post, I’ll introduce the terms used when talking about Streams, show some examples of each term and how they can be used together to create compact and descriptive code. Then I’ll show a real-world example of Streams code I wrote recently to pick winners in a raffle.
What’s a Stream?
A Stream is a (possibly never-ending) series of Objects. A Stream starts from a Source. The objects in a Stream flow through Intermediate Operations, each of which results in another stream, and ...
How to read and understand a Java Stacktrace
When things go wrong in a running Java application, often the first sign you will have is lines printed to the screen that look like this:
Exception in thread "main" java.lang.RuntimeException: Something has gone wrong, aborting! at com.myproject.module.MyProject.badMethod(MyProject.java:22) at com.myproject.module.MyProject.oneMoreMethod(MyProject.java:18) at com.myproject.module.MyProject.anotherMethod(MyProject.java:14) at com.myproject.module.MyProject.someMethod(MyProject.java:10) at com.myproject.module.MyProject.main(MyProject.java:6)
This is a Stacktrace, and in this post I'll explain what they are, how they are made and how to read and understand them. If that looks painful to you then read on...
Anatomy of a Stacktrace
Coding Twilio Webhooks in Java with Spring Boot
Twilio’s APIs enable communication in a whole host of ways: by phone, WhatsApp, Facebook, SMS and more. Usually when events such as incoming messages or calls happen Twilio will make an HTTP request to a server the user provides to discover what it should do - these are called webhooks. HTTP servers can be written with any technology to respond to these webhooks, and for Java developers the most popular framework is Spring Boot.
In this post we’ll create a Spring Boot app which can respond to incoming phone calls by playing callers a short message followed by the marvellous Rogers and Hammerstein song “It Might As Well Be Spring”.
Creating a Spring Boot App
This post will show you how to integrate service discovery and intelligent routing into a Node.js application built with a microservices architecture. You'll see how you can do this with two Netflix open source projects, Eureka and Zuul, that run in the Java SE Runtime Environment.
The Netflix Eureka server provides service discovery. This gives your application's services the ability to find other services without knowing where they are hosted or the full URL required to reach them, so you don't have to provide complete ...
Using WhatsApp, Twilio and Azure to Generate Photo Alt-text in Java
AI services like Computer Vision (CV) are getting easier and easier to play with, and we can have some fun by making them available to use from our cellphones. In this post, we will use Java to connect the Twilio API for WhatsApp with Azure’s CV APIs to create a bot that can describe photos. It would be neat to use this for generating alt-text to help make your images more accessible online, for example.
We will need the following to get started with this post
- Java 8 or higher
- A Twilio Account
- An Azure account and Cognitive Services subscription key
Overview of our app
How it works
When Twilio receives a WhatsApp message it will send an HTTP request to a URL we provide.
Our mission is to create an app in Java which can handle those requests. The app will take the URL of any ...
Introducing Developer Evangelist Matthew Gilliard
When I was a young kid we used to take family holidays from the UK to France. I remember meeting other kids on holiday with their families for a week at a time, spending time playing with them and having loads of fun.
These other kids were from exotic-sounding places like Germany and France. Despite enjoying the same kinds of games and having loads of fun together we didn’t speak the same language and could never have a conversation. As children we had a lot in common but our lives and toys and everything were so different.
Since that time I always wanted to travel - to meet people and see what life is like in different places - how it is similar and how it is different.
Living and Working Abroad
I was very shy of public speaking when I was young. After two years of working as a programmer ...
How to Send WhatsApp Messages from Java Applications with Twilio
WhatsApp is a global messaging service that helps billions of people communicate with each other. Applications can now also programmatically interact with people on the service using the Twilio Messaging API and Twilio's Java Helper Library. Let's learn how to quickly send messages to people from a new or existing Java application.
Our local development environment needs the following dependencies to properly send WhatsApp messages from Java.
- Java SE version 7 or higher
- A free Twilio account with an activated WhatsApp Sandbox
- The Twilio Java Helper Library
First, install Java on your development machine if you do not already have it. You can also read this detailed tutorial on setting up your Java development environment if you are having trouble.
Take note of your Account SID and Auth Token when you log ...
How to Call the Twilio API from Java Programs on the Commandline
If you you need to do a quick Twilio test, or compile and run programs on a remote computer without any GUI, or run test programs on your own computer and you don’t want to use a full blown IDE development environment, this is the article for you.
Check Java Installation
Confirm that you have a Java runtime environment (JRE) on your computer for running Java class files:
$ java -version java version "1.8.0_131"<br/>Java(TM) SE Runtime Environment (build 1.8.0_131-b11)<br/>Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode) Check that you have the Java compiler on your computer: $ javac Usage: javac <options> <source files> ...
If you don’t have both, please go to Oracle’s Java SE page and download the Java JDK.
The Java Standard Edition (Java SE) is what you need for developing ...
Cloud Orchestration, Lazarus and Interning at Twilio
There are a few technical interview strategies everyone knows: communicate your thoughts, give yourself time to think, and keep calm. Absent among these, of course, is coming up entirely blank for a question. So when in the interview for an engineering internship my manager asked, “What experience do you have with distributed systems?” I took a deep breath and, cringing a little, replied, “None, yet. But I’m smart and I learn fast, and I’m interested to learn by working in one.” This was true. I’d been curious about the subject for a while, and figuring it wouldn’t hurt to try, had worked up the courage to apply to a role for which I didn’t hit every “ideal qualification” checkbox. (Take that, tech gender gap!) And to my surprise and relief, I moved forward – all the way to San Francisco, to a spot on Twilio’s ...
Round up: Libraries for checking Pwned Passwords in your 7 favorite languages
Earlier this year Troy Hunt released version 2 of his popular Pwned Passwords API service. The new version comes with even more compromised passwords and a more secure way to query the password API that doesn’t require sending plain text passwords over the network.
The API update comes at a good time. When NIST updated its password guidelines in 2016, it included a new recommendation to check “memorized secret verifiers”, or passwords, against known data breaches:
When processing requests to establish and change memorized secrets, verifiers SHALL compare the prospective secrets against a list that contains values known to be commonly-used, expected, or compromised. For example, the list MAY include, but is not limited to passwords obtained from previous breach corpuses.
Since the API release, the community has created API wrappers in many of our favorite programming languages. In this post, I round up the libraries in 7 languages ...