project can't find a newly created properties file.

I can't get my project to find a newly created properties file.
It crashes at runtime, saying
StackTrace:
java.lang.IllegalArgumentException: Directory com/mycompany/dir1/dir2/myfilename is invalid or not a directory name

myfilename.properties is in com/mycompany/dir1/dir2/
Full path is C:\mycompany1\myproject\mycore\code\com\mycompany2\dir1\dir2
In addition to the properties file, dir2 contains java files, which compile correctly.

Using Eclipse, in Java Build path, it includes all directories in myproject\mycore\code

What else do I need to do?
LVL 1
allelopathAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Apply the same principle to it

http://java.sun.com/javase/6/docs/api/java/util/PropertyResourceBundle.html#PropertyResourceBundle(java.io.InputStream)

The parent directory of com needs to be in the classpath
0
 
CEHJCommented:
How are you creating the following:

>>Directory com/mycompany/dir1/dir2/myfilename is invalid or not a directory name

and trying to access it
0
 
allelopathAuthor Commented:
PropertiesReader propertiesReader = new PropertiesReader(propertyFile );
where propertyFile is the String "com/mycompany/dir1/dir2/myfilename"
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
CEHJCommented:
I don't know that class, butin normal circumstances  you could do



Properties p = new Properties();
InputStream in = getClass().getResourceAsStream("/com/mycompany/dir1/dir2/myfilename");
p.load();
p.close();

Open in new window

0
 
allelopathAuthor Commented:
Sorry, i forgot the PropertiesReader is a custom class.
Ultimately, this is the line that throws the exception:
PropertyResourceBundle resources = (PropertyResourceBundle) ResourceBundle.getBundle(propertyFile);

0
 
allelopathAuthor Commented:
ok, doing a System.getProperty("java.class.path"), I see that the parent directory is not in the classpath.
It is in the build path. How do I add it to the class path in eclipse?

0
 
allelopathAuthor Commented:
The classpath setting is in the Debug or Run dialog, though at the moment I don't see the ability to add a properties file (only jars)
0
 
CEHJCommented:
>>don't see the ability to add a properties file (only jars)

You don't want to add either - you need to add a directory
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.