?
Solved

project can't find a newly created properties file.

Posted on 2007-12-05
9
Medium Priority
?
695 Views
Last Modified: 2013-12-15
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?
0
Comment
Question by:allelopath
  • 5
  • 4
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 20411593
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
 
LVL 1

Author Comment

by:allelopath
ID: 20411688
PropertiesReader propertiesReader = new PropertiesReader(propertyFile );
where propertyFile is the String "com/mycompany/dir1/dir2/myfilename"
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20411748
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:allelopath
ID: 20411822
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 20411864
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
 
LVL 1

Author Comment

by:allelopath
ID: 20412031
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
 
LVL 1

Author Comment

by:allelopath
ID: 20412152
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 20412178
>>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
 
LVL 86

Expert Comment

by:CEHJ
ID: 20412487
:-)
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question