Scala, Java, Unix, MacOS tutorials (page 377)

If you're ever working on a Unix or Linux system, and need to email a file to someone else, it may be helpful to know that you can send your email message right from the Unix command line. You don't need to hop into mutt or any other Unix or Linux mail client to email the file.

Quite often when I’m asked to review a UML “Use Case” that someone else has written, I ask “Have you tested your Use Case with real data?” Sadly, the answer is usually “no.”

I don’t know why people don’t do this, but they don’t, and it seems like a very logical thing — essentially a unit test for Use Cases.

Here's a quick example that shows a complete method that I use in a Java servlet to forward to a JSP (JavaServer Page).

Just pass the method an HttpServletRequest, an HttpServletResponse, and a URL, and you're in business. Note that my JSP url string typically looks something like "/myPage.jsp".

Okay, I have to say up front that I don't currently have a Netflix subscription or a Roku digital video player (the Roku HD Player at Amazon

Java Swing FAQ: How do I create a Java tooltip (also known as balloon or bubble help text)?

Linux zgrep FAQ: How do I use the Linux zgrep command? (Or, How do I grep a GZ file?)

Linux users quickly learn how to use the Linux grep command on plain text files, but it takes a little longer to really you can grep gzip (gz) files as well. Here's how.

I've been using TextMate (a commercial, plain-text editor) for several years on the Mac platform, and while it's an okay text editor, it has never blown me away, and more often than not, it confounds me. That -- and not handling the new Mac Spaces features very well -- has made me start looking at other Mac OS X text editors over the last several weeks, specifically free Mac text editors.

I've been on vacation recently, and I'll be back to work Tuesday morning. I know I'm way behind on responding to your comments, but I promise I'll get to all of them as soon as possible. WiFi access here has been hit or miss, and I finally decided to give up until I get back.

PHP LAMP Mac FAQ: Can you recommend a good way to develop Mac PHP/LAMP applications on Mac OS X?

Here's a very simple Java JButton example that shows how to create and use a button group in Java using the ButtonGroup class. With this code, when the user selects one JButton in the group of buttons, the other JButton's will be de-selected.

I'm just getting started with image parsing in Java, but right away I need to do something that’s relatively hard: find a small image inside of a larger image. I’ve run into some initial problems so I’m writing small tests as I go along.

In this article I’ll share the results of a first test I’ve written to walk through all the pixels in an image (a Java BufferedImage) and print out their RGB (technically ARGB) values.

Using the Java Preferences API couldn’t be much easier. In a Swing application I was just working on I wanted to remember the last output directory a user accessed, and the following steps show all that I had to do:

Java file and directory FAQ: How do I get a list of all files in a directory that match a certain filename pattern?

For a recent Java project I needed to be able to get a list of files within a directory that matched a specific filename pattern. In this case, I needed a list of all files in a directory that began with the underscore character (_). This is relatively easy in Java; as usual it's just hard to find a good example.

Mac OS X Applescript FAQ: How do I execute Applescript code from a Java application?

Note: The solution shown in this article works for Java 6.

The solution for Java 7 or Java 8 is different. For that solution, see my new article, How to execute AppleScript commands from Java 7 on Mac OS X.

I'm often asked, "How do I center a JFrame on screen?", or, "Is there a method to center a JFrame?"

I always center my initial JFrame on screen using the setLocationRelativeTo method, and pass it a null reference. As the Javadoc for setLocationRelativeTo method states:

For the most part I try to avoid the rumor game when it comes to Apple, but when I read on All Things Digital that Apple is planning to increase their capital expenditures by 70% to $1.9 Billion in 2010, well, that's a little more than a rumor.

When you're writing Java web applications -- for example, an application like a discussion forum -- you end up writing Java servlets where you need to know if the user accessing your servlet has a valid Java servlet session established. If they have a valid servlet session established, you might do one thing in your servlet code, but if they don't have a valid servlet session, you might handle their request differently.

Free Perl editors FAQ: Can you recommend any good free Perl editors?

I had to get back into some Perl development for a recent project, and when I realized the project was going to take a few days to complete, I decided to look around to see if I could find a good free Perl editor.

Perl move file FAQ: How do I move a file in Perl?

Surprisingly, you can move a file in Perl with the File::Copy module. Yes, the Perl file copy module also handles file moving.

A Perl file move example

Here's a quick example:

Perl problem: When you don't use Perl every day, it's hard to remember the combination of the for loop syntax and how to deal with the special $_ variable to refer to each element within the body of the loop.

Solution: As I write this today, I still can't remember how to get this for loop and $_ syntax to work, at least not without pulling out a book, or looking it up on the internet. A much better solution is to just use Perl's foreach syntax, and never look back.