Classpath issue from standalone app

Discussion in 'Java' started by laredotornado, Oct 27, 2010.

  1. Hi,

    I'm using Java 1.6 and am writing a stand alone java app. I have a
    file on my system ...

    /Users/davea/projects/app/app/ant/build.properties

    I included the parent directory of this file, "/Users/davea/projects/
    app/app", in my classpath that I pass to the java command that runs a
    stand alone app. However, I'm not able to load the build.properties
    file from my app using

    InputStream
    stream=this.getClass().getClassLoader().getResourceAsStream("build.properties");

    The "stream" field is null. Any ideas what I'm doing wrong and why
    I'm not able to access this file? Thanks, - Dave
     
    laredotornado, Oct 27, 2010
    #1
    1. Advertising

  2. laredotornado

    Jim Gibson Guest

    In article
    <>,
    laredotornado <> wrote:

    > Hi,
    >
    > I'm using Java 1.6 and am writing a stand alone java app. I have a
    > file on my system ...
    >
    > /Users/davea/projects/app/app/ant/build.properties
    >
    > I included the parent directory of this file, "/Users/davea/projects/
    > app/app", in my classpath that I pass to the java command that runs a
    > stand alone app. However, I'm not able to load the build.properties
    > file from my app using
    >
    > InputStream
    >
    > stream=this.getClass().getClassLoader().getResourceAsStream("build.properties")
    > ;
    >
    > The "stream" field is null. Any ideas what I'm doing wrong and why
    > I'm not able to access this file? Thanks, - Dave


    I am working with a program (not my own) that does pretty much the same
    thing. I add the directory itself to the classpath, not the parent of
    the directory. Try that.

    --
    Jim Gibson
     
    Jim Gibson, Oct 27, 2010
    #2
    1. Advertising

  3. laredotornado

    Aeris Guest

    laredotornado wrote:

    > Hi,
    >
    > I'm using Java 1.6 and am writing a stand alone java app. I have a
    > file on my system ...
    >
    > /Users/davea/projects/app/app/ant/build.properties
    >
    > I included the parent directory of this file, "/Users/davea/projects/
    > app/app", in my classpath that I pass to the java command that runs a
    > stand alone app. However, I'm not able to load the build.properties
    > file from my app using
    >
    > InputStream
    >

    stream=this.getClass().getClassLoader().getResourceAsStream("build.properties");
    >
    > The "stream" field is null. Any ideas what I'm doing wrong and why
    > I'm not able to access this file? Thanks, - Dave


    If you include /Users/davea/projects/app/app in your classpath, path of the
    build.properties is "/ant/build.properties" and not "build.properties".

    Try instead:
    InputStream
    stream=this.getClass().getResourceAsStream("/ant/build.properties");
     
    Aeris, Oct 28, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip
    Replies:
    3
    Views:
    7,339
    Tony Morris
    Feb 9, 2004
  2. Gabe
    Replies:
    3
    Views:
    1,093
  3. Replies:
    2
    Views:
    774
  4. Replies:
    2
    Views:
    1,126
    Mike Schilling
    Mar 2, 2008
  5. learnerplates
    Replies:
    8
    Views:
    446
    John Bokma
    Jun 8, 2005
Loading...

Share This Page