Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Perhaps the FileInputStream isn't able to honor the properties "file" which is inside your jar file. Change your:</p> <pre><code>this.runController = new Properties(); this.propertiesLocation = this.getClass().getClassLoader().getResource(this.PROPERTIESFILELOCATION); FileInputStream propsInput = new FileInputStream(this.propertiesLocation.getFile()); this.runController.load(propsInput); </code></pre> <p>to:</p> <pre><code>this.runController = new Properties(); this.runController.load(this.getClass().getClassLoader().getResourceAsStream(this.PROPERTIESFILELOCATION)); </code></pre> <p>EDIT: I created a test class, and it shows that when running from the filesystem OR from a JAR file, that "props/main.properties" works but "/props/main.properties" does not:</p> <pre><code>[rtb@rtblinux props]$ cat org/dashrb/test/main.java package org.dashrb.test; import java.util.Properties; import java.io.IOException; public class main { public static void main(String args[]) { main myMain = new main(); myMain.testProps("props/main.properties"); myMain.testProps("/props/main.properties"); } public main() { } public void testProps(String p) { try { System.out.println("==============================="); Properties props = new Properties(); System.out.println("Trying to load properties as " + p); props.load(getClass().getClassLoader().getResourceAsStream(p)); System.out.println("Loaded properties as " + p); System.out.println("Property x is: " + props.getProperty("x")); } catch (IOException ioe) { ioe.printStackTrace(); } System.out.println("==============================="); } } [rtb@rtblinux props]$ cat props/main.properties x = This is the property value of x [rtb@rtblinux props]$ java -cp . org.dashrb.test.main =============================== Trying to load properties as props/main.properties Loaded properties as props/main.properties Property x is: This is the property value of x =============================== =============================== Trying to load properties as /props/main.properties Exception in thread "main" java.lang.NullPointerException at java.util.Properties$LineReader.readLine(Properties.java:434) at java.util.Properties.load0(Properties.java:353) at java.util.Properties.load(Properties.java:341) at org.dashrb.test.main.testProps(main.java:25) at org.dashrb.test.main.main(main.java:11) [rtb@rtblinux props]$ jar cvf main.jar org props added manifest adding: org/(in = 0) (out= 0)(stored 0%) adding: org/dashrb/(in = 0) (out= 0)(stored 0%) adding: org/dashrb/test/(in = 0) (out= 0)(stored 0%) adding: org/dashrb/test/main.class(in = 1218) (out= 679)(deflated 44%) adding: org/dashrb/test/main.java(in = 594) (out= 287)(deflated 51%) adding: props/(in = 0) (out= 0)(stored 0%) adding: props/main.properties(in = 36) (out= 36)(deflated 0%) [rtb@rtblinux props]$ jar tvf main.jar 0 Fri Jan 11 17:29:40 EST 2013 META-INF/ 68 Fri Jan 11 17:29:40 EST 2013 META-INF/MANIFEST.MF 0 Fri Jan 11 17:26:00 EST 2013 org/ 0 Fri Jan 11 17:26:00 EST 2013 org/dashrb/ 0 Fri Jan 11 17:29:24 EST 2013 org/dashrb/test/ 1218 Fri Jan 11 17:28:52 EST 2013 org/dashrb/test/main.class 594 Fri Jan 11 17:29:24 EST 2013 org/dashrb/test/main.java 0 Fri Jan 11 17:26:40 EST 2013 props/ 36 Fri Jan 11 17:26:40 EST 2013 props/main.properties [rtb@rtblinux props]$ cd / [rtb@rtblinux /]$ java -cp ~/misc/src/java/props/main.jar org.dashrb.test.main =============================== Trying to load properties as props/main.properties Loaded properties as props/main.properties Property x is: This is the property value of x =============================== =============================== Trying to load properties as /props/main.properties Exception in thread "main" java.lang.NullPointerException at java.util.Properties$LineReader.readLine(Properties.java:434) at java.util.Properties.load0(Properties.java:353) at java.util.Properties.load(Properties.java:341) at org.dashrb.test.main.testProps(main.java:25) at org.dashrb.test.main.main(main.java:11) </code></pre> <p>There must be something different in your situation which is preventing your success.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload