Entries Tagged as 'java'

Wednesday, May 13th, 2009

Capturing Uncaught Java Exceptions in a Bash Shell Script

I was burned one to many times by chaining dependent java programs together in a bash script.
By default the java executable will return zero if the program exited manually, and 1 if there was an uncaught RuntimeException.
Let's say test.sh runs a java program, we want to run it 3 times, but if it fails during [...]

Wednesday, January 14th, 2009

Writing Portable Groovy Scripts with A Magic Runnable Jar

I've found myself using Java as a "scripting" language lately due to the necessity of working in mixed *nix and windows environments where I can't count on a standard scripting language being installed like python,perl, or ruby. What's more I either don't have the rights to install a binary of said scripting languages or don't [...]

Monday, December 29th, 2008

Regular Expression to Replace System.out.println with Log4j

This is nothing fancy, but may help some of you log4j newbies.
I found myself replacing a project's hideous System.out.println statements with log4j log calls.
Just do a File Search in eclipse , tick the regular expression box and do a Replace:

Find: System\.out\.println\("(.+?)"\);
Replace: log.info("\1");

Now you just have to go in and add your imports and your log [...]

Wednesday, August 27th, 2008

Eclipselink in J2SE RCP Applications

In this article I'll go over integrating EclipseLink into an RCP application. I will not explain every detail of the JPA specification however. The source code this article is partially based off of is currently pending IP Review for inclusion in the official EclipseLink project, however you may download it now from here. You can [...]

Friday, April 11th, 2008

Automatically Add JavaDoc Comments in Eclipse

Recently while preparing to contribute some code to Eclipse I had to add a copyright comment to the top of every class. Enter JAutodoc it will go through and add Javadoc comments and other automated comments, the update site is:
http://jautodoc.sourceforge.net/update/
Screenshot:

Bookmark to:

Friday, February 15th, 2008

Limiting log4j SMTPAppender

I wanted to set a maximum amount of e-mails that SMTPAppender would send after filling up a mailbox with 30,000 damn e-mails.
Turns out it was pretty damn easy, I set up my appender in a java class, and the SMTP appender has a method called setEvaluator that takes an instance of TriggeringEventEvaluator, so I just [...]

Sunday, July 22nd, 2007

Java App Empty Window under Compz-Fusion / Beryl

This weekend I was playing around with Ubuntu 7.04 and Compiz-Fusion, I didn't have any major problems until I tried to get Oracle SQL Developer and Aqua Data Studio to work, they would start up but no interface would be drawn.
Well the problem is that they were trying to figure out the Window Manager for [...]

Thursday, July 12th, 2007

Java Regular Expression Tester

This tool seriously rules, it allows you to test your java regex and automatically escapes it, saving tons of time. The only downside is it's an applet? Yea, an applet remember those?
Regular Expression Tester
Bookmark to:

Tuesday, June 19th, 2007

So Elite it Hurts

Great post over at coderspiel that explains how to use scala to do some Java heavy lifting easily -- writing a wicket and hibernate app in scala. For those who don't know ,scala is one of the new breed of JVM based programming languages that can integrate with Java libs. Cool stuff.
Bookmark to:

Thursday, June 7th, 2007

Java Date Validation is Annoying (Regexes too)

*EDIT* Thanks for the tips in the comments.
Today I had a user complain that they could enter 2 digit years in their app. Hmm I took a look at the code and I didn't see how that was possible. Here was my date validation method, more after the jump.
Bookmark to:

Wednesday, May 16th, 2007

Using Protototype AJAX & JSON with J2EE and Struts

We don't always get to use the latest greatest web framework, but just because you're using a crusty old dinosaur J2EE XML framework from the pits of hell, doesn't mean you can't make girls cry with your AJAX/JSON skills.
This tutorial will show how to use prototype to return JSON data to your jsp.
Bookmark to:

Monday, November 13th, 2006

There was an error opening this document. This file cannot be found.

This error sucks. Acrobat Reader 7 throws it when trying to read an inline PDF in IE.
Here's how you fix it (in java, though you could do this in another language, point is you have to set your headers like so).

response.setHeader("Pragma", "public");
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0");
response.setHeader("Cache-Control","public");
response.setHeader("Content-Description","File Transfer");

Bookmark to: