peredur | 1 Apr 01:12 2012

properties files

I'm writing a simple swing application and I want to add a properties file.

Where should I place the properties file so that I can read it from my code.  I've tried every location I can
think of and every relative path I can think of in the call to load the file, but I just get a 'File not found' exception.

All help greatly appreciated.

Cheers

Peter

Chuck Davis | 1 Apr 04:17 2012
Picon

Re: properties files

You should probably put it in your home directory unless other users
will be using it in which case you want to put it in a public
directory.

Depends to a large extent on whether you are using windows or Linux.
Don't know about Mac but should be similar to Linux.  I use the system
properties to determine the user's home directory and place properties
files there.  That way it is OS independent.

On Sat, Mar 31, 2012 at 4:12 PM, peredur <p.bradley <at> dsl.pipex.com> wrote:
> I'm writing a simple swing application and I want to add a properties file.
>
> Where should I place the properties file so that I can read it from my code.  I've tried every location I can
think of and every relative path I can think of in the call to load the file, but I just get a 'File not found' exception.
>
> All help greatly appreciated.
>
> Cheers
>
>
> Peter
>
>
>
>

Chuck Davis | 1 Apr 04:24 2012
Picon

Re: Read in from file to array and sort

On Sat, Mar 31, 2012 at 9:53 AM, tuts73 <mikejames73 <at> hotmail.com> wrote:
> Hi all, im new to Java and just wondering if you could help out.....
>
> I have a list of names in a standard text file that need to be sorted. Im guessing the best way to do this is to
read the contents of the file and store in an array, then use a sorting algorithm to sort the contents.
>
> So far i have been able to read in the file - but now struggling to apply some code to store and
sort......would appriciate any help. Thanks :)
>
> The code i have so far.....
>
> public class MSL{
ArrayList<String> list = new ArrayList();
>
> public static void main(String[] args)throws IOException{
>  String contents;
>  File f = new File("MyList.txt");
>  FileReader fr = new FileReader(f);
>  BufferedReader br = new BufferedReader(fr);
>  while (br.ready()){
>  contents = br.readLine();
>  System.out.println(contents);
list.add(contents);
>  }
>  fr.close();

Collections.sort(list);
for(String s : list) {
System.out.println(s);
}
(Continue reading)

Thufir | 1 Apr 04:38 2012
Picon

faces-config

I'm still reading the docs on this, but one one page, I see that facelets 
says faces-config is no longer required, but all the examples I can find 
have that config file.

OTOH, Netbeans doesn't create that file by default.  However, the facelets 
example on the NB site does have it.  What's the scoop?

thanks,

Thufir

Brenden Towey | 1 Apr 05:01 2012
Picon
Picon

Re: faces-config

On 3/31/2012 7:38 PM, Thufir wrote:
> I'm still reading the docs on this, but one one page, I see that facelets
> says faces-config is no longer required, but all the examples I can find
> have that config file.
>
> OTOH, Netbeans doesn't create that file by default.  However, the facelets
> example on the NB site does have it.  What's the scoop?

If I recall correctly, JSF 2.0 doesn't require faces-config.xml, but 
older versions required it.

Would it kill you to actually read some documentation, rather than 
assuming the IDE is somehow responsible for providing you with 
training?  There's a JSF 2.0 tutorial by Oracle on the web.  For dead 
trees, I found this useful:

<http://horstmann.com/corejsf/>

Thufir | 1 Apr 05:33 2012
Picon

Re: properties files

On Sat, 31 Mar 2012 19:17:22 -0700, Chuck Davis wrote:

> You should probably put it in your home directory unless other users
> will be using it in which case you want to put it in a public directory.
> 
> Depends to a large extent on whether you are using windows or Linux.
> Don't know about Mac but should be similar to Linux.  I use the system
> properties to determine the user's home directory and place properties
> files there.  That way it is OS independent.
[...]

Ah, it doesn't matter what your OS is, it's in a JAR, that's the beauty 
of JAR's.  The property file goes in the JAR.  Presumably it's similar 
for resource bundles.

Let me show you an example:

thufir <at> dur:~$ 
thufir <at> dur:~$ jar -tf NetBeansProjects/gnuNNTP/dist/gnuNNTP.jar 
META-INF/
META-INF/MANIFEST.MF
nntp/
nntp/dur/
nntp/dur/bounceme/
nntp/dur/bounceme/net/
META-INF/persistence.xml
nntp.properties
nntp/dur/bounceme/net/Driver.class
nntp/dur/bounceme/net/Driver.java
nntp/dur/bounceme/net/JDBC.class
(Continue reading)

Thufir | 1 Apr 06:34 2012
Picon

Re: faces-config

On Sat, 31 Mar 2012 20:01:31 -0700, Brenden Towey wrote:

> If I recall correctly, JSF 2.0 doesn't require faces-config.xml, but
> older versions required it.
> 
> Would it kill you to actually read some documentation, rather than
> assuming the IDE is somehow responsible for providing you with training?
> There's a JSF 2.0 tutorial by Oracle on the web.  For dead trees, I
> found this useful:

I was looking at a few sources, including:

http://facelets.java.net/nonav/docs/dev/docbook.html#gettingstarted-setup-
faces

the above seems as official as you get, yet it specifies, to my reading, 
faces-config, which, as you confirm, is outdated.  Hence the question.  
Pardon to ruffle your feathers by not citing sufficiently, but thank you 
for confirming my understanding that faces-config isn't required anymore.

thanks,

Thufir

Geertjan Wielenga | 1 Apr 08:41 2012
Picon

Re: faces-config

On 04/01/2012 06:34 AM, Thufir wrote:
> On Sat, 31 Mar 2012 20:01:31 -0700, Brenden Towey wrote:
>
>
>> If I recall correctly, JSF 2.0 doesn't require faces-config.xml, but
>> older versions required it.
>>
>> Would it kill you to actually read some documentation, rather than
>> assuming the IDE is somehow responsible for providing you with training?
>> There's a JSF 2.0 tutorial by Oracle on the web.  For dead trees, I
>> found this useful:

Read these tutorials: http://netbeans.org/kb/trails/java-ee.html

Gj

> I was looking at a few sources, including:
>
> http://facelets.java.net/nonav/docs/dev/docbook.html#gettingstarted-setup-
> faces
>
> the above seems as official as you get, yet it specifies, to my reading,
> faces-config, which, as you confirm, is outdated.  Hence the question.
> Pardon to ruffle your feathers by not citing sufficiently, but thank you
> for confirming my understanding that faces-config isn't required anymore.
>
>
> thanks,
>
> Thufir
(Continue reading)

peredur | 1 Apr 14:14 2012

properties files


Chuck Davis wrote:
> You should probably put it in your home directory unless other users
> will be using it in which case you want to put it in a public
> directory.
> 
> Depends to a large extent on whether you are using windows or Linux.
> Don't know about Mac but should be similar to Linux.  I use the system
> properties to determine the user's home directory and place properties
> files there.  That way it is OS independent.
> 

Thanks.  I found the answer here:

http://viralpatel.net/blogs/2009/10/loading-java-properties-files.html

Cheers

Peter

Thufir | 1 Apr 18:13 2012
Picon

<at> ManagedBean versus <at> Named

On Sun, 01 Apr 2012 08:41:14 +0200, Geertjan Wielenga wrote:

> Read these tutorials: http://netbeans.org/kb/trails/java-ee.html

 <at> ManagedBean(name="UserNumberBean")
 <at> SessionScoped
public class UserNumberBean implements Serializable {
http://netbeans.org/kb/docs/web/jsf20-intro.html

However, when the IDE makes a managed bean from the wizard, it's as so:

 <at> Named(value = "foo")
 <at> SessionScoped
public class Foo implements Serializable {

and I was just curious about the discrepancy.

I downloaded the sample, edited my version, and had it working at one 
point.  However, when I tried again, seem to run into errors along the 
lines of:

/greeting.xhtml  <at> 28,108 value="#{guessNumber.userNumberBean.userNumber}": 
Target Unreachable, identifier 'guessNumber' resolved to null

after entering the number to guess.  I notice that the Foo bean is named 
"foo" and not "Foo" and have played with such variations, departing 
slightly from the example.

The sample uses sun-web.xml which, I think I recall reading, is 
outmoded.  Because I did have it running, I think that I have the IDE set-
(Continue reading)


Gmane