Back when I was writing Functional Programming, Simplified I started to write a little Scala/FP “To-Do List” application that you can run from the command line. For reasons I don’t remember, I decided not to include it in the book, and forgot about it until I recently started using GraalVM (what I call Graal).
Graal includes a native image feature lets you compile JVM classes and JAR files into native executables, so as I thought about things I can make faster, I was reminded of the To-Do List app and thought about how cool it would be if it started instantaneously. So I found the old project, blew the dust off of it (updated all of its dependencies), and made a few additions so I could create (a) a single, executable JAR file with sbt-assembly, and (b) a native executable with Graal.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 17.3, “How to use @SerialVersionUID and other Scala annotations.”
You want to specify that a class is serializable, and set the
serialVersionUID. More generally, you want to know the syntax for using annotations in your Scala code, and know which annotations are available.
Use the Scala
@SerialVersionUID annotation while also having your class extend the
RoboVM is a software tool written to let you run Java applications on the iOS platform. From the docs, “RoboVM translates Java bytecode into native ARM or x86 code. Apps run fast directly on the CPU. No interpreter involved. RoboVM includes a Java to Objective-C bridge that makes it possible to call into the native iOS CocoaTouch APIs.”
If you ever wanted to get access to global operating system keystrokes from a Java or Scala Swing application, you can do it with the jnativehook library. Here’s a short demo:
Here’s the full Scala source code for the demo. I put a few comments in the code to highlight the important areas:
If you don't do anything to your Java application on a Mac OS X system, your Java class name will appear in the Mac menubar. Of course, this isn't a good thing. There are a couple of things you can do to get the name of your Java application on the Mac menu bar, and I'll share all of the ways I know how to do this. I've listed these techniques in order here from "easiest" to "best".
Java Mac application FAQ: Can you share a Java/Mac Ant build script that uses the Jarbundler task to make my Java application look like a native Mac OS X application?
NOTE: This solution is for Mac OS X systems running versions of Java prior to Java 7. If I remember right, it only works on those systems, and therefore only on Mac OS X systems 10.6 and earlier. I'm working on new tutorials for Java 7 and Mac OS X 10.7, 10.8, 10.9, and newer.
I just learned about Mac Stickies, and they're pretty cool. If you're in a Cocoa application (like Safari, TextMate, and others) you can select text and/or graphics, and then easily save the content to a sticky note on your Mac desktop. To save the content you can either (a) remember the [Command][Shift][Y] keystroke, or else (b) click the application menu item (i.e., the "Safari" menu item if you're using Safari), then Services, then Make New Sticky Note.
The picture below shows what a Mac sticky note looks like when it's created on the desktop.
I just posted a new tutorial titled How to bundle a Mac Java application on Mac OS X using Xcode's Jar Bundler. This tutorial demonstrates how to use the Mac OS X Jar Bundler utility to configure a Java application to install like a native Mac application, and look right in the Finder, the Dock, and the Get Info window. It also starts to look at using an Ant task to automate the bundling process.