• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

'propertyfile ' property

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm completely new to Java and got a script which I need to improve and make work. I can't contact original author of the code but the question itself seems to be easy for a person who has a bit experience with Java.

Here is the a line of code



as a result propFileName is NULL.

And that's my actual problem. I've tried to search in the google what is propertyfile or how to set up. I see conf folder with properties within projects folder.

I don't know how to deal with it. I can use custom path to point that config but I want to make the current code to work. At least I need to understand what's going on there.

I'll appreciate any help.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John, welcome to Java Ranch!

There are several possible ways to set System properties. The easiest way is just to call setProperty() somewhere early in your application, like say the first line on the main() method.



You can also use command flags to set properties, which has the advantage of not having to modify the Java code at all:
> java MyApplicaiton -DpropertyFile="config/props.txt"
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Try this:-… and you will not find a system property called propertyfile. You cannot get that file like that. It may be possible to read the file and put additional properties in the system properties object from that file, but that requires you to read the file first.

Note the getProperties method is old and uses very old‑fashioned design, returning an Enumeration.
 
John Stephens
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greg is right. It turned out that the property is supposed to be passed using a command line.

Thanks guys for explaining the process.
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great, I'm glad you figured that out. Thanks for coming back and letting us know!
 
reply
    Bookmark Topic Watch Topic
  • New Topic