Solved

project can't find a newly created properties file.

Posted on 2007-12-05
9
687 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Accepted Solution

by:
CEHJ earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now