Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Setting CLASSPATH in ANT?

  • 04-02-2002 12:18pm
    #1
    Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭


    Ok I'm going to write a way around it, but I was just wondering how do you add a directory of uncompressed java files to the classpath?

    So I have something like this...
     <classpath>
          <pathelement location="${jar}/dir1"/>  
          <pathelement location="${jar}/dir2"/>  
          <pathelement location="${jar}/dir3"/>   
        </classpath>
    

    dir 1,2 and 3 are expanded jar files with the class files removed (only java files+resources).

    For some reason it ignores the directories. Is this because there are no class files? :)


Comments

  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    They're gonna have to be compiled if you want to use them in your classpath.
    Why are you putting source files in there?


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Sorry for the confusion. I wanted to create one jar at a time but it had to see a load of other jars (which I hadn't built yet) in order to compile.

    I was thinking of dumping the lot into a directory and just compile the whole tree but the manifest method of generating jars I've found to be very buggy.

    This is the answer (figured it out)

    You would do something like this.
    <!-- Compile only dir1 stuff -->
    <javac srcdir="${jar}/dir1:${jar}/dir2:${jar}/dir3">
        <include name="package/dir1/**"/>
    </javac>
    

    This would treat the sources as to be referenced when compiling but the include statement will only tell it to compile the package relating to what you are currently compiling.

    Still not great (as I have to know my package paths) but at least it works now.


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Cool! Wasn't aware of that feature.

    I think you could also call different buildfiles for each one.


  • Registered Users, Registered Users 2 Posts: 19,550 ✭✭✭✭Krusty_Clown


    While we're on the subject (kinda), if I have a compiled resource bundle in a JAR, can I extract it out of the jar (removing it from the JAR) and still have it recognised by the Java App?

    Hmm.. Bit confusing here...

    What I want to be able to do is debug the resourcebundle (by compiling new versions of it, and dropping it into the same folder as the original parent Jar, without having to rebuild the Jar each time?

    Am I making any sense at all?!
    Does the compiled resource bundle have to be in the original Jar in order to be referenced, or can I simply add it to the classpath?


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    afaik you have to add the base point of the path to the classpath, but I could be wrong.

    So if your file goes into

    com\whatever\mystuff

    you would have to make that directory structure and point to the base directory in your classpath.

    Btw Enygma, thanks now that I think of it I will probably create a build file for each jar and call them.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 19,550 ✭✭✭✭Krusty_Clown


    That sounds about right.
    Thanks Hobbes.

    I'll try it out and let you know.


Advertisement