SiteMesh 2.1: The only way to fly :) Tim Henmen… er I mean Wimbledon: The Movie
Aug 04

Making sure classes are in your project CLASSPATH via ant

Tech Add comments

javap is one of those nice command line tools that you can use to print out info on a given class.

I sometimes run into problems in a project where the right jars may not all be in my lib directories (see last post ;).

I use a simple ant task to give me a sanity check (outside of my IDE of course, as that may be setup differently).

I run:

% ant find-class -Dclass.name=java.lang.String

and the simple task is…

<!-- =================================================================== -->
<!-- Find the class in the classpath                                     -->
<!-- =================================================================== -->
<target name="find-class" description="Find the class in the classpath">
<fail unless="class.name"
message="You must pass a class name in via -Dclass.name=package.class"/>

<echo message="Finding class: ${class.name}"/>

<exec executable="javap">
<arg line="-classpath ${project.classpath} ${class.name}"/>
</exec>
</target>

I am always surprised that I can’t find a <javap> ant task too.

One Response to “Making sure classes are in your project CLASSPATH via ant”

  1. botanical skin care Says:

    big thank

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: Type in the word 'cricket'