Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

project can't find a newly created properties file.

Posted on 2007-12-05
9
Medium Priority
?
693 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
Suggested Courses

610 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