0

I have done java program that I'm trying to install to linux machine. Unfortunately my program doesn't sees property file and gets default values. What is the way of telling java where is property file placed?

Program is placed in:
/opt/myProg

Properties are placed in:
/opt/myProg/config.ini


external jar:
/opt/myProg/lib

classes in packeges:
/opt/myProg/Prog


Command I'm trying to run my program:
java -cp /opt/myProg/lib/log4j.jar:/opt/myProg/Prog:/opt/myProg/. startpkg.runme

This command also does't helps:

java -cp /opt/myProg/lib/log4j.jar:/opt/myProg/Prog:/opt/myProg/. startpkg.runme -Dconfig.ini=/opt/myProg/config.ini 

code that is trying to load props looks like:

p.load(new FileInputStream("config.ini"));
vico
  • 17,051
  • 45
  • 159
  • 315

1 Answers1

0

Use maven directory structure. Put all properties in src/main/resources and load them with

Properties prop = new Properties();
prop.load(PropertiesUtil.class.getClassLoader().getResourceAsStream("application.properties"));
Marcin Szymczak
  • 11,199
  • 5
  • 55
  • 63