Quick question (I think...Ihope)
I'm trying to do something I thought was simple, but apparently it's not simple enough.
I'm on linux and I'm trying to write files to the current user's /home directory? Anyone know how I can do this? I was looking into System.getProperties.. but I'm not getting anywhere. Any tip would be greatly appreciated. Thanks --Chris
[344 byte] By [
javverjaw] at [2007-9-30 23:27:30]

Thank you sir.That doesn't seem to be working for me...am I missing something here?The following doesn't print anything:
import java.util.*;
public class ShowProps {
public void ShowProps() {
System.out.println(System.getProperty("user.home"));
}
public static void main(String[] args) {
ShowProps thisProps = new ShowProps();
}
}
From the API for "System.getProperties()"
The current set of system properties for use by the getProperty(String) method is returned as a Properties object. If there is no current set of system properties, a set of system properties is first created and initialized. This set of system properties always includes values for the following keys: Key Description of Associated Value
java.versionJava Runtime Environment version
java.vendorJava Runtime Environment vendor
java.vendor.urlJava vendor URL
...
user.homeUser's home directory
The problem is what you think is a constructor is not. Having "void" makes it just a method that has the same name as the class. Constructors don't have a return type. So you've just got the implicit default constructor, which does nothing. Get rid of "void".
jverd at 2007-7-7 14:03:15 >

> The problem is what you think is a constructor is
> not. Having "void" makes it just a method that has
> the same name as the class. Constructors don't have a
> return type. So you've just got the implicit default
> constructor, which does nothing. Get rid of "void".
On the ShowProps method/constructor-wannabe that is, not on main.
jverd at 2007-7-7 14:03:15 >

I was scratching my head for a while too. :-)It's a pretty common mistake though. I actually wish Java didn't allow regular methods to have the same name as the class. There's no good reason to do so, and it just leads to confusion with ctors.
jverd at 2007-7-7 14:03:15 >
