• Post Reply Bookmark Topic Watch Topic
  • New Topic

'propertyfile ' property  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 56610
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, I'm glad you figured that out. Thanks for coming back and letting us know!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!