title: JAVA .properties file
body: <p>having a lil issue, i have create a properties file :</p>
  
  <p>config.properties located in ../resource/config.properties</p>
  
  <p>this is the file currently :</p>
  
  <pre><code>destinationPDF=D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/
  destination="D:/Documents/NetBeansProjects/printing~subversion/fileupload/Uploaded/
  fileList =D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/Directory Files/directoryFiles.txt
  </code></pre>
  
  <p>have i done the properties file ok ?</p>
  
  <p>also i want to access this file and load the variables into a class </p>
  
  <p>i have tried </p>
  
  <pre><code>public void loadProp() {
      try {
          prop.load(new FileInputStream("../resources/config.properties"));
          System.out.println(prop.getProperty("destinationPDF"));
          System.out.println(prop.getProperty("destination"));
          System.out.println(prop.getProperty("fileList"));
  
      } catch (IOException ex) {
          ex.printStackTrace();
      }
  }
  </code></pre>
  
  <p>but now the class will not compile becuase it can not find variable destination for example, so how do i load the variables from the file, and do i still need to declear the variable in the class ? </p>
  
  <p>sorry if these are silly questions, first time using properties !</p>
  
  <p>i do not get this error if i put in the variables normally like</p>
  
  <pre><code>private String destinationPDF = "D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/"; //USE ON TORNADO//"D:/My Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/";//USE ON PREDATOR    
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>have now </p>
  
  <pre><code>private Properties configProp = new Properties();
  
  public void loadProps() {
      InputStream in = this.getClass().getClassLoader().getResourceAsStream("../resources/config.properties");
      try {
          configProp.load(in);
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>EDIT 2:</p>
  
  <pre><code>public void loadProp() {
      InputStream in = this.getClass().getClassLoader().getResourceAsStream("../resources/config.properties");
      try {
          prop.load(in);
          System.out.println(prop.getProperty("destinationPDF"));
          System.out.println(prop.getProperty("destination"));
          System.out.println(prop.getProperty("fileList"));
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  Properties prop = new Properties();
  private String destinationPDF = prop.getProperty("destinationPDF");
  public String destination = prop.getProperty("destination");
  </code></pre>
  
  <p>it is working, no erors etc but destination and destinationPDF are passing null values</p>