Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...What you have done for people like me is immeasurably helpful."

Geography

Where in the world do Tek-Tips members come from?
DoraC (Programmer)
31 Jul 03 13:49
Hi,

I'm following a fairly standard path of using ant to build my jsp/servlet web app.  However, I've run into an issue I can't seem to resolve (and can't locate suitable documentation on, either).

I would like to include a java package in the compile classpath, but I'm not sure where or how to list this in the build.xml file.  There seem to be provisions for .jar files, but not .class files contained in packages.  I've tried the (stunningly naive, I'm sure) approach of:


    <property name="my.source" value="C:\myPackage"/>

...

    <pathelement location="$my.source"/>
    <fileset dir="$my.source">
      <include name="*.class"/>
    </fileset>


but, (not surprisingly), after rebuilding when I go to load my page it errors out with a "package does not exist" error,
so evidently it's not finding it...
my build.xml file works fine otherwise, for "vanilla" builds.

Any help very appreciated,
Thanks -
Dora




BugBlatter (Programmer)
1 Aug 03 1:14
Hi Dora,
Are you talking about making classes available inside a deployed web application, or making them available when you compile classes using the build file before deploying the web app?

Is your web application deployed as a WAR file?

If you want to add java classes to a classpath in Ant you have to specify the location of the root of the package hierarchy, not the directory that contains the class file (unless the class file is not in a package, in which case the root of the package hierarchy is the directory that contains the class file).

So if you have a class com.myCompany.MyClass stored in the build/classes directory (relative to the basedir of the build.xml file), you add them to a classpath like this:

<property name="build.dir" value="build"/>

<path id="project.classpath">
  <pathelement location="${build.dir}/classes"/>
</path>

You can then refer to the project.classpath by its id.

<javac srcdir="${src.dir}" destdir="${build.dir}/classes">
  <classpath refid="project.classpath"/>
</javac>

        
DoraC (Programmer)
1 Aug 03 15:02
Thank you for your response....

1) I'm not deploying my application as a WAR file
2) I guess the answer would be that I'm trying to make my
classes available inside a deployed web application.  

THe reason I say this is because they are referred to in a .jsp file, and that's where the error occurs (not the ant compile step).  WHen I try to load the .jsp file, I get a
package doesn't exist error - resulting from the
<%@ page import="mypackage1.*, mypackage2.*"%>
step.

I think my attempts before were a little misguided, in that they were probably influencing the actual compile time classpath.  So please forgive my very basic question, but how can I then influence the runtime classpath?  Is there a setting in ant for this?

THanks a lot for the help, it's really apprecaited!
Dora


BugBlatter (Programmer)
3 Aug 03 18:47
You probably have to check the documentation for the application server you're using to find out how to set the classpath. For instance, Weblogic has a WLCLASSPATH variable that can be set as part of the server start up process.

I reckon you should have a look at deploying as a WAR file. It makes it a lot easier to deploy an application and it gives you more control over things like security, initial context parameters and what goes in the classpath. Everything you put in the WEB-INF/classes directory of the WAR file is automatically added to the classpath. Ant has a task which makes it easy to package up a WAR file.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close