javaizpack

file not found exception loading properties file in izpack


I am trying to load the properties file with my custom panel using IZpack 4.3.5. i have placed all the properties and images related to my isntaller in bin folder of izpack and created install.jar.when i tried to run it it is working fine .

But when i run the same jar in the some other folder/mechine i am getting file not found exception of .properties file in my custompanel.java class. Could you tell me how to give the relativepath/path to load the properties file using my custompanel?

i added following in install.xml

<resources>
<res id='template.properties" src="template.properties>
<resources>

<panel classname="custompanel"/>

<packs>
<pack name="Base" required="yes">
<file src="template.properties" targetDir="$INSTALL_PATH"/>
<parseble targetfile="template.properties" type="prop" parse="yes"/>
<pack>
</packs>

in my custom class

inputstream in=new FileinputStream("template.properties"); -------------------------------exception coming here (file not found template.properties)

Can you please let me know how to solve this in IZpack 4.3.5 or how to provide/get the relative path of the template.properties file?


Solution

  • Once you create the install.jar, the file is not available in the file system. It is part of the jar. Use getClass().getResourceAsStream("template.properties") to access the file.