native

How to use @SerialVersionUID and other Scala annotations

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

Problem

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.

Solution

Use the Scala @SerialVersionUID annotation while also having your class extend the Serializable trait:

RoboVM - Java on iOS

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

Options to put your Java application name on the Mac menubar

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

A complete Java Ant MacOS Jarbundler build script

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.

Mac specific properties for Swing applications

I think I've mentioned parts of this in other blog entries, but as I was just digging through a Java Swing application that I wrote specifically for the Mac OS X platform, I ran across the following source code, which sets up all of my system properties for the Mac environment:

Mac Stickies (and easily saving content)

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.

Mac Java application - how to bundle a Java application on Mac OS X

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.

 

Mac Java - How to make a Java/Swing application look like a native Mac app

As I continue working on a text editor built for an audience of one (me) I've written a tutorial on how to make a Java/Swing application look like a native Mac OS X application.

My goal is to take this as far as I can, trying to make a complicated Java application look and feel like a Mac Cocoa application, but, I want to do this without severely compromising the cross-platform benefits of Java.