Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free

"java" posts

  • By Matthew Gilliard
    How to Send Email in Java using Twilio SendGrid How to Send Email in Java using Twilio SendGrid

    If you’re writing a Java app and you need to programmatically send some emails, the Twilio SendGrid API is just the thing you need.

    You’ll need to sign up for a free Twilio SendGrid account and create an API key. Then you can get started with a few lines of code.

    In this post I’ll go through each step to get you up and emailing in no time.

    Starting Out

    You’ll need:

    The first thing you should do is to create a SendGrid account. The free tier will work just fine for this tutorial. Once you are signed up and logged in, create an API key. You can choose any name you like, but make sure to save the key before moving on.

    A screenshot of the "Create API Key" dialog on the SendGrid  console, showing 3 options, of which I have selected "Full Access" and called my key "my-api-key"

    Choose “Create & View” …

    Read More
  • By Matthew Gilliard
    Wake up to Useful Daily Messages with Java and Azure Functions Wake up to Useful Daily Messages with Java and Azure Functions

    I wake up slowly. I often need a few minutes to remember where I am and what day it is. I usually have my phone handy - it’s my alarm clock, too. But then I decide to check the weather, and before I know it I’ve got carried away on Twitter, Reddit, email and so on. It takes me ages to start getting ready for the day. I decided to build a small app which would send me an SMS every morning. I can see what the day has in store without getting involved in anything online.

    I decided to use Azure Functions with a TimerTrigger to run some Java code every morning. The code pulls data from wttr.in and affirmations.dev, formats it into a dense (read: emoji-laden) message and sends it to me:

    An SMS in my messaging app: Good morning (weather: rain showers, temp +10 Celsius), Today is Monday, October 7. Remember you are a capable human being. Have a great day (rainbows and sparkles)

    In this post I’ll walk you through how to create this and customise it …

    Read More
  • By Matthew Gilliard
    Working with HTML on the Web Using Java and jsoup Working with HTML on the Web Using Java and jsoup

    So, you need to parse HTML in your Java application. Perhaps you are extracting data from a website that doesn’t have an API, or allowing users to put arbitrary HTML into your app and you need to check that they haven’t tried to do anything nasty?

    Have you tried using regular expressions?  It won’t end well. The author of that now-infamous text managed to recover from their distress enough to suggest using an XML parser (before, presumably, collapsing into the void). The problem with this is that an awful lot of the HTML in the world is not valid XML. People open tags without closing them, they nest tags wrongly, and generally commit all kinds of XML faux pas. Some non-XML constructs are perfectly valid HTML and admirably, browsers just cope with it.

    To adopt the flexible and stylish attitude of web browsers, you really need a dedicated …

    Read More
  • By Matthew Gilliard
    Getting Started with JavaFX Getting Started with JavaFX

    JavaFX is a Java toolkit for making GUI applications which run on Windows, MacOS or Linux and mobile. It is the successor to the old Swing and the older AWT toolkits.

    Since the release of Java 11 in 2018 JavaFX has been part of the OpenJDK project, so it is open-source and is developed by many people from many different companies. If you are interested in creating a desktop application today then I would recommend starting with JavaFX and not using Swing or AWT, but it can be hard to know how to get started.

    This post will walk you through creating a JavaFX desktop application from scratch - the application will use JavaFX’s controls module to draw a label with some text, then we’ll move on to creating an interactive app that can send SMS messages.

    What do I need in order to make a JavaFX Application?

    Read More
  • By Matthew Gilliard
    Getting Started with the Java Streams API Blog Header: Getting Started with the Java Streams API by Matthew Gilliard, Developer Evangelist

    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 for loop.

    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 are gathered …

    Read More
  • By Matthew Gilliard
    How to read and understand a Java Stacktrace Copy of Photo blog Header 2-2.png

    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 …

    Read More
  • By Matthew Gilliard
    Coding Twilio Webhooks in Java with Spring Boot OaO_XJW_jNspphskhagxUqwgYna48fdsintjxgUZxg8PQ2Y8D7jBnmUa_g4kwpliEvf3ZB8QaajTv0LZ5Y6QltTsbY3WrscGMWuWw61bS7XvOQO4sglr5cF1xGGFxib6Zomr9J1g

    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”.

    Requirements

    Creating a Spring Boot App

    The Spring folks have created the Spring Initializr for quickly creating a new project. Head over to https://start.spring.io …

    Read More
  • By Maciej Treder
    Implementing Eureka and Zuul for Service Discovery and Dynamic Routing in JavaScript Microservices Running on Node.js Gw87W418humMuagmwCQwtUyO2SOfwrWPG7TdI2vz7z_y86RFhQPQorXMBTcuPGWz1qCgkzBfvzX51Lgf1K1y493wa4Apwoq-y0zQf8Sig9UDXo5XaZi-y_YdGYoecOCIvX4Jfawz

    Building your JavaScript applications as a collection of microservices give you a number of advantages. Your applications can be more modular, uniform, and testable as you build them and they can be more robust, scalable, and available when you deploy them to the production environment. Including a service discovery registry and dynamic routing capabilities will help you achieve scalability and availability in the production.

    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 URLs …

    Read More
  • By Matthew Gilliard
    Using WhatsApp, Twilio and Azure to Generate Photo Alt-text in Java People programming together

    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

    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 …

    Read More
  • By Matthew Gilliard
    Introducing Developer Evangelist Matthew Gilliard young_gilliard_horiz_crop.jpg

    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 …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.