example

Debug Ant build problems with echo statements

Ant FAQ: How to use echo commands to debug Ant build scripts.

I've been moving back and forth between a ton of different computers lately -- Mac, Linux, and Windows computers -- and I had some problems with an Ant build script. This particular Ant script is complex, and I kept making mistakes, and needed a good way to debug the build process as I set up my application on these different systems.

A shell script to search multiple jar files for a Java class or pattern

I've found that there are several times when I need to be able to find a Java class inside of a jar file. Usually this happens when something isn't working, and I get something like a Java ClassNotFoundException. In the process of debugging this problem -- especially if I'm using a jar library that I haven't used before -- I list the contents of one or more jar files to debug the problem.

The beginning of a MySQL database script

Here is some code that I use at the beginning of a MySQL database script to (a) create a database, (b) create a local user to access that database ('foo_user'@'localhost'), (c) create a remote user that can access the database ('foo_user'@'%'), and (d) then use that database (which I need to do before starting a bunch of CREATE TABLE statements):

How to use the Commons IO project to create, delete, and move files and directories

I wrote the following Java class today that is a "helper" class for a project I'm working on to create a web interface for Nagios. The Nagios part isn't too relevant, because mostly what I'm trying to show here is how to use the Apache Commons IO project to make it easier to interact with files and directories from Java code.

In short, the following Java class shows how to use the Commons IO project to accomplish the following tasks. Without any further delay, here is the complete source code for my class:

When a Java method call requires a Class reference

Today I was working with a class that extended the Spring class NamedParameterJdbcDaoSupport, and when I went to use the getNamedParameterJdbcTemplate().queryForObject() method, the third parameter of the method required a Class reference.

How to perform a case-insensitive database query

Database FAQ: How do I do a case-insensitive database search?

Answer: When performing a database search using MySQL, PostgreSQl, SQL Server, Oracle, etc., I convert the results of the query to uppercase using the UPPER function, and make sure my search parameters are also in uppercase. Here's an example of how I do this when searching on the first_name field of an Employees database table:

Ant WAR task - A sample Ant build script that builds a WAR file

You'll probably have to know a little bit about Java, Ant, and build files for this sample build.xml file to be any use to you, but if you're looking for a sample Ant build script that can be used to create a war file, or one that simple uses a war task, this example might work for you.

I'm not going to provide any explanation of any of this right now, but if I have time in the future I'll come back here and add a few comments about how this build script works.

Syndicate content