Link to home
Start Free TrialLog in
Avatar of allelopath
allelopath

asked on

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?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

How are you creating the following:

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

and trying to access it
Avatar of allelopath
allelopath

ASKER

PropertiesReader propertiesReader = new PropertiesReader(propertyFile );
where propertyFile is the String "com/mycompany/dir1/dir2/myfilename"
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

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

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?

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)
>>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
:-)