Classpath issue from standalone app

L

laredotornado

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
 
J

Jim Gibson

laredotornado said:
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.
 
A

Aeris

laredotornado said:
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");
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top