Adding relative directory to java classpath and using ClassLoader().getResourceAsStream(“”)?

Maybe I'm misunderstanding what you're trying to do, but if you have a folder in your classpath, that means all the files underneath it should be in the classpath as well. If not, you can always pass each . Properties file on the class path.

Maybe I'm misunderstanding what you're trying to do, but if you have a folder in your classpath, that means all the files underneath it should be in the classpath as well. If not, you can always pass each . Properties file on the class path.

But either way, since the file/folder that contains the file is in the classpath, you should just be able to do: InputStream in = new FileInputStream("classpath:xyz. Properties") And since "foo/bar/plugh" is in the classpath, one of the places it will look for xyz. Properties is in "foo/bar/plugh".

For some reason this isn't working for me when my app runs via a batch file build by codehaus maven appassmebler. Absolute paths work but relative ones don't. – sal May 11 '09 at 19:01 2 The only thing I can think of is if the relative path you have in your classpath is being resolved based on where the program is run.

For example if I have the batch file in the C:\myapp\bin directory, the "base" path might be C:\myapp\bin, not C:\myapp. If that is the case, it would be trying to resolve "C:\myapp\bin\foo\bar\plugh\xyz. Properties".

– Alex Beardsley May 12 '09 at 19:55 It worked for me with the absolute path of the directory. But it is very strange because I tried before with the code: InputStream in = getClassLoader(). GetResourceAsStream("xyzzy.

Properties"); What is the difference between these two methods? Thanks. – David García González May 20 '09 at 12:19 Is there any way to get this properties with the method: ResourceBundle.

GetBundle("xyz"); Thanks. – David García González May 20 '09 at 12:27 @David I think as long as "xyz. Properties" is in your classpath, it should get picked up with getBundle() – Alex Beardsley May 22 '09 at 13:49.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions