title: How to load hibernate.cfg.xml from different location
body: <p>I am creating a jar using hibernate. I have encountered a situation where I need to change a setting (url) often, so I would like to load the <code>hibernate.cfg.xml</code> like this</p>
  
  <pre><code>SessionFactory sessionFactory = new Configuration()
                                       .configure("D:\\fax\\hibernate.cfg.xml")
                                       .buildSessionFactory();
  </code></pre>
  
  <p>But then running the project I am getting this exception</p>
  
  <pre><code>org.hibernate.HibernateException: D:\fax\hibernate.cfg.xml not found
      at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
      at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1287)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1309)
      at hibernate.LabOrderHelper.getDatabaseSesssion(LabOrderHelper.java:55)
      at hibernate.Test.main(Test.java:42)
  </code></pre>
  
  <p>How can I load <code>hibernate.cfg.xml</code> from a different location than the class path?</p>