GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Current Working Directory? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Current Working Directory?" Watch "Current Working Directory?" New topic
Author

Current Working Directory?

Liang Anmian
Ranch Hand

Joined: Jun 25, 2004
Posts: 119
suncertify.properties must be located in the current working directory. I will like to confirm it it means the location where runme.jar is located.


Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)
Eric Chang
Ranch Hand

Joined: Jan 27, 2004
Posts: 113
You are incorrect. It means whatever directory you run the runme.jar file from...which doesn't have to be the directory where it's located (for example. if you have it in your CLASSPATH, you can run it from anywhere).
Liang Anmian
Ranch Hand

Joined: Jun 25, 2004
Posts: 119
But how will you know where the user is running the JAR file? Supposed I use a File object. Do you mean that this alone will suffice?

Eric Chang
Ranch Hand

Joined: Jan 27, 2004
Posts: 113
I used a FileReader and FileWriter to read and write my properties file.
Liang Anmian
Ranch Hand

Joined: Jun 25, 2004
Posts: 119
So that means the path is correct?
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
The way I read this requirement is:

The suncertify.properties file must be in the current working directory, which is available as a system parameter called user.dir. If the file does not exist, create it.


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Liang Anmian
Ranch Hand

Joined: Jun 25, 2004
Posts: 119
I wonder if I'm doing anything wrong. I created a sample JAR file, and set the directory which contains that JAR file in the classpath. I tried running the JAR file somewhere else, but it doesn't work. It's called "runme.jar", and I placed it in my root folder (C:\). I place "C:\" in the classpath, then I tried running the JAR file somewhere else with:

java -jar runme.jar

It doesn't work. I tried putting "C:\runme.jar" in the classpath too, but it doesn't work too.

By the way thanks for the "user.dir" solution. I've forgotten that such a property exists.
David Abramowicz
Ranch Hand

Joined: Dec 10, 2004
Posts: 56
Hi...

I did not see any musts regarding creating a new config file if it doesn't exist.

Did you guys read it like that?

If the config file is put where the runme.jar is located, and an error message if the file can't be found (saying suncertify.properties is not in the current directory) should suffice, surely?

Opinions?

Cheers /Dave
David Abramowicz
Ranch Hand

Joined: Dec 10, 2004
Posts: 56
Hmm... This thread:

http://www.coderanch.com/t/185901/java-developer-SCJD/certification/They-faild-me-don-know

is certainly contradictory to my theory. Seems some poor lass failed due to not auto-creating a suncertify.properties...

/Dave
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by David Abramowicz:
Hi...

I did not see any musts regarding creating a new config file if it doesn't exist.

Did you guys read it like that? ...


Yes, I read the configuration and packaging requirements to require that the program must be able to start in its default mode using what is specified in the packaging, which does not include a properties file.
 
Consider Paul's rocket mass heater.
 
subject: Current Working Directory?