Installing OpenJDK 11 on MacOS

If you download the .tar.gz for OpenJDK 11 direct from http://jdk.java.net/11/, there’s no obvious install instructions (at least that I can find) either on the OpenJDK website on in the .gz file. If you’ve done any fiddling with different JDK versions on MacOS before, you’ve probably come across the ‘/usr/libexec/java_home’ utility (see here for my previous article about this utility, and answers to this StackOverflow post which includes one of the most extensive and useful guides to running different JDK versions on MacOS that I’ve seen) which does a number of useful things relating to which JDK you’re currently using in your PATH:

/usr/libexec/java_home : shows you were the current JDK home is, eg:

/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home

/usr/libexec/java_home -V : lists all installed JDKs, e.g.:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
10, x86_64: "Java SE 10" /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home
1.8.0_151, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

To switch between JDKs, use /usr/libexec/java_home -v version (e.g. 10):

$ /usr/libexec/java_home -v 1.8.0_151
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

Knowing that your available JDKs are installed to /Library/Java/JavaVirtualMachines/ by default, moving the contents of the downloaded OpenJDK 11 dir from inside the .gz file to the same location would make sense.

Once you’ve moved it there, java_home -V now shows the new JDK in place:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
11, x86_64: "OpenJDK 11" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
10, x86_64: "Java SE 10" /Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home
1.8.0_151, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

Updating my aliases to quickly switch versions in my .bash_profile, I now have:

alias j11="export JAVA_HOME='/usr/libexec/java_home -v 11'; java -version"
alias j10="export JAVA_HOME=`/usr/libexec/java_home -v 10`; java -version"
alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"

Sourcing the .bash_profile (source .bash_profile) and then running each alias, now I’ve got OpenJDK 11 set up and ready to go!

$ j11
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

Building bots on Twitter with AWS Lambdas (and other stuff)

I’ve built a few different bots on Twitter and written several articles describing how I built them. Some of these were a few months back – once they’re up and running it’s easy to forget they’re up and running (thanks to the free tier on AWS Lambda which means you can run scheduled Tweets well within the free tier limits). This is a summary of the bots I’ve developed so far.

Looking at where I got started, my first bot was to build an integration between Amateur Radio 2m Packet, retweeting packets received locally to Twitter. This was my first experience working with the Twitter REST apis and the OAUTH authentication, so I lot of what I learned here I reapplied to the following bots too:

For my next project, I was inspired by articles by researcher Janelle Shane who has been training ML models to produce some hilarious results, such as weird recipes, college course names and many others. I was curious what content a ML model would generate if I extracted all of my past 4000+ Tweets from Twitter and trained a model with the content. I had many questions, such as would the content be similar in style, and is 4000 Tweets enough text to train a model? You can follow my progress in these posts:

This then led to repeating the experiment with over 10 years of my blog articles and posts collected here, which you can follow in these posts:

Next, what would it take to train my model in the cloud using AWS Sagemaker, and run using AWS Lambdas?

You can follow this bot on Twitter here: @kevinhookebot

I had fun developing @kevinhookebot – it evolved over time to support a few features, not just to retweet content from the trained ML model. Additional features added:

  • an additional Lambda that consumes the Twitter API ‘mentions’ timeline and replies with one of a number of canned responses (not generated, they’re just hard coded phrases). If you reply to any of it’s tweets or Tweet @ the bot it will reply to you every 5 minutes when it sees a new tweet in the mentions timeline
  • another Lambda that responds to @ mentions to the bot as if it is a text-base adventure game. Tweet ‘@kevinhookebot go north’ (or east/west/south) and the bot will respond with some generated text in the style of an adventure game. There’s no actual game to play and it doesn’t track your state, but each response is generated using @GalaxyKate ‘s Tracery library to generate the text using a simple grammar that defines the structure of each reply.

After having fun with the adventure text reply generator, I also used the Tracey library for another AWS Lambda bot that generates product/project names and tweets every 6 hours. I think it’s rather amusing, you can check it out here: @ProductNameBot

@ProductNameBot

My most recent creation I upped the ante slightly and wondered what it would take to develop a Twitter bot that playeda card game. This introduced some interesting problems that I hadn’t thought about yet, like how to track the game state for each player. I captured the development in these posts here:

I have some other ideas for something I might put together soon. Stay posted for more details 🙂

MacOS Mojave spaces gestures stopped working after taking screenshot with Grab

I just took a screenshot with the updated Grab app in MacOS Mojave and my 4-finger swipe to switch Spaces desktops stopped working. I found this post which talks about something similar with multitouch gestures which sounds like it’s a randomly occurring issue with multitouch gestures. A reboot fixed it for me, but it was surprising how much I rely on gestures to switch desktops/apps, and when it’s not working how to you switch?! (Ctrl-Left/Right is also works as a keyboard shortcut).

Building Redis from source on Ubuntu server 18.04

After downloading redis source and attempting to make on Ubuntu server 28.04, it looks like I’ve got some dependencies missing:

kev@ubuntu18-redis1:~/redis/redis-4.0.11$ make
cd src && make all
make[1]: Entering directory '/home/kev/redis/redis-4.0.11/src'
    CC Makefile.dep
    CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I found an identical post about this issue, with not building the dependencies. To fix:

cd deps
make hiredis jemalloc linenoise lua geohash-int
cd ..
make
sudo make install

That resulted in a clean install, ready to start redis-server !