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.IllegalArgumentE xception: Directory com/mycompany/dir1/dir2/my filename is invalid or not a directory name
myfilename.properties is in com/mycompany/dir1/dir2/
Full path is C:\mycompany1\myproject\my core\code\ com\mycomp any2\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?
It crashes at runtime, saying
StackTrace:
java.lang.IllegalArgumentE
myfilename.properties is in com/mycompany/dir1/dir2/
Full path is C:\mycompany1\myproject\my
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?
ASKER
PropertiesReader propertiesReader = new PropertiesReader(propertyF ile );
where propertyFile is the String "com/mycompany/dir1/dir2/m yfilename"
where propertyFile is the String "com/mycompany/dir1/dir2/m
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();
ASKER
Sorry, i forgot the PropertiesReader is a custom class.
Ultimately, this is the line that throws the exception:
PropertyResourceBundle resources = (PropertyResourceBundle) ResourceBundle.getBundle(p ropertyFil e);
Ultimately, this is the line that throws the exception:
PropertyResourceBundle resources = (PropertyResourceBundle) ResourceBundle.getBundle(p
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, doing a System.getProperty("java.c lass.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?
It is in the build path. How do I add it to the class path in eclipse?
ASKER
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
You don't want to add either - you need to add a directory
:-)
>>Directory com/mycompany/dir1/dir2/my
and trying to access it