This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Can't find suncertify.properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Can Watch "Can New topic
Author

Can't find suncertify.properties file

Baris Dere
Ranch Hand

Joined: Mar 23, 2004
Posts: 31
Hi,

I searched for this topic but I couldn't find anything.

My directory structure is next:

c:\suncertify.properties
c:\client.policy
c:\server.policy
c:\Manifest.MF
c:\db.db
c:\suncertify\client\MainClass.class
c:\suncertify\db\dbclasses*.class
c:\suncertify\dbserver\dbserverclasses*.class

I make a jar as next:

jar -cvmf Manifest.MF runme.jar .

then I copy this jar to a other PC..

when I run... java -jar runme.jar server

he couldn't find the suncertify.properties...

I do set classpath=runme.jar
then stills not works...

to get the properties file is my code as next:

Properties p = new Properties();
p.load(new FileInputStream("suncertify.properties"));

Why is it not working???

Please help...

I have 7 days to submit my assignment

Regards.

Baris
Phil Harron
Greenhorn

Joined: Jun 21, 2002
Posts: 29
Hi,

Are you sure you can actually jar the properties file? If you can the JVM will be looking in its current working directory which could be

c:\documents and settings\local name\

and not where you put the jar file.

hope this is of some use..


SCJP 1.4<br />SCJD (Ongoing)
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Baris,
From which directory are you running your program(s) from?

I think the problem is with the code:


public FileInputStream(String name) throws FileNotFoundException

String name = is not just the name of the file to be opened, but is the pathname to the file that includes filename as well in the FileSystem.

I don't think loading any file in this way would succeed, even if the file is present in the classpath.(though ResourceBundle might work but it is used for a different purpose!).....You may have to write code to get the correct location of suncertify.properties file and then use it to create your FileInputStream() to open it with Properties class.

My instructions contain the foll. sentence.
All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.


I have not completed my coding yet, but my design goes something like this......I am not going to jar my suncertify.properties with the runme.jar file.I am assuming suncertify.properties file to be present in the current directory where the client/server is launched.If it does not find it, then the program launches the JFileDialog to prompt the CSR for settings, which I capture and store it in the suncertify.properties and start my client/server program(s) accordingly.
I want the CSR to understand that the JFileDialog box pops up if he tries to run the program from a different directory and the program does not find a suncertify.properties file.I am also documenting this in my design decisions.

The following link might be useful:
http://www.coderanch.com/t/183683/java-developer-SCJD/certification/NX-Contractor-silly-working-directory
This time...ignore Phil's comments in the above link

I have not yet made up my mind to use
System.getProperty("user.dir") to get the current directory.
At this moment, I am assuming that, if no directory or drive is specified as part of the filename, the jvm picks it up the file the current directory in windows. I don't know if the behaviour would be different in other OS.
[ May 13, 2004: Message edited by: Vishwa Kumba ]
Baris Dere
Ranch Hand

Joined: Mar 23, 2004
Posts: 31
You are right,

I thought I must store the properties files in the runme.jar

But must my db.db file be in the runme.jar so that I must call inside my jar file or would the examiner give the path of the db.db when testing my assignment? So when testing runme.jar will db.db file outside the jar file?

If it's inside runme.jar. How can I locate this db.db when reading data?



Thanks a lot

Regards

Baris Dere
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Originally posted by Baris Dere:
But must my db.db file be in the runme.jar so that I must call inside my jar file or would the examiner give the path of the db.db when testing my assignment? So when testing runme.jar will db.db file outside the jar file?

If it's inside runme.jar. How can I locate this db.db when reading data?

(Your instructions html file also may have something like this)
In my instructions for BS assignment, I have a separate section called packaging of submissions which says my submission should be a jar file consisting of 5 items.

1. runme.jar (our client/server program(s) in all modes)
2. dbx212.db file
3. code directory(with packages/subpackages inside them)
4. version.txt
5. docs directory (...)
It doesn't say that the dbx212.db file is inside the runme.jar.
The examiner is likely to extract the main jar file consisting of these 5 items and then run the runme.jar and go thru the docs file(s), so we can safely assume that he is going to pick up our extracted dbx212.db file or specify a different dbx212.db file with the same db format in a different location.
[ May 13, 2004: Message edited by: Vishwa Kumba ]
Baris Dere
Ranch Hand

Joined: Mar 23, 2004
Posts: 31
Hi vishwa,

You are right:-))


My english is not so good

SO I didn't understand the assignment so good.

But now is all clear.

Thank you

Baris
 
wood burning stoves
 
subject: Can't find suncertify.properties file
 
Similar Threads
jar files
manifest.mf and runme.jar
help with jar utility
suncertify.properties
URLyBird: runme.jar