🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.compiler
2 messages
2 total messages Started by Andrew Gray Mon, 13 Jun 2005 06:27
classpath configuration - adding a directory
#22
Author: Andrew Gray
Date: Mon, 13 Jun 2005 06:27
16 lines
2060 bytes
Could anyone help me with this. 

I have a requirement to add (the contents of) a directory to the java classpath. This directory is a 'resources' directory within a project, and exists alongside the 'class'es directory. 

Looking in the JBuilder (2005) interface - it looks as if the project output directory is automatically added to the cp, and you can also add other projects/libraries to the cp (Project Properties -> Paths), but I cannot see a way of adding another directory in the current project to the classpath.

I can use 'Configure Libraries' to assign multiple directories/archives to a given project, which I can then add to the cp of a different project, but presumably this does not help, as if I were to add the resource area in this way, and then make a project depend on itself, then the class archive would be added aswell.

The only way I can see at the moment is to define a seperate Library eg 'MyProject-Resources' alongside 'MyProject' in Configure Libraries - which just references the resources directory, and then add this to the path references of 'MyProject' - however, this looks like a nasty hack.

Is there a better way of doing this ?

Thanks in advance,

Dr Andrew Gray
Re: classpath configuration - adding a directory
#24
Author: Paul Furbacher [TeamB]
Date: Mon, 13 Jun 2005 16:10
63 lines
3315 bytes
Andrew Gray wrote:

> I have a requirement to add (the contents of) a directory to the
> java classpath. This directory is a 'resources' directory within a
> project, and exists alongside the 'class'es directory.
> 
> Looking in the JBuilder (2005) interface - it looks as if the
> project output directory is automatically added to the cp, and you
> can also add other projects/libraries to the cp (Project Properties
> -> Paths), but I cannot see a way of adding another directory in
> the current project to the classpath.

Assuming you have resources (images, properties files, etc.?)
in a directory structure other than "src", you could try the
following.

1. Add another source directory pointing to your resources dir
    in Project Properties > Paths.

    <project dir>
       /bak
       /doc
       /classes
       /src
       /resources <-- at same level as "src"

2. In Project Properties > Build > Resources, make sure that you
    change to "Copy" any file extension which must be copied from
    the /resources folder.

3. Compile and verify that your resources have been copied to
the /classes folder.


However, most often, resources such as images and properties
files should be located relative to the classes which refer
to them.  So, in most cases, these resource belong in the
appropriate directory in the "src" path of your project,
not in a separate path.  That is, if a class depends on a
properties file to lookup initial values, and uses

    URL resUrl = this.getClass().getResource("values.properties")/

the "value.properties" should be located in the same folder
as the source for this particular class.  JBuilder will automatically
copy .properties files to the class output directory, and you can
add to the resource filetypes to be copied as in Step #2 above.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://www.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads