Adding external .properties files to a MANIFEST classpath

Hi all;
I want to package my application as an executable jar (let's call it app.jar), but leave the config (.properties) file outside of it, so it can easily be edited after deployment. The config file should be added to the classpath, so that it can be loaded with ClassLoader.getResourceAsStream().
However, even though I add the directory where the config file lives to the classpath in the manifest of app.jar, it is not found by getResourceAsStream(). But if I package the config file in a separate jar (config.jar), and adds config.jar to the classpath of app.jar's manifest, it works.
Could someone explain why the config file is not picked up when not in a jar?

This external classpath thing for jars is quite frustrating.
But actually you can reference external directory, it does not have be in the exact same folder as the jar.
Lets say in the folder you have:
app.jar
lib/WrapperFramework.jar
config/config.properties
You can load the properties from a folder by:
- in code, use "class.getResourceAsStream("/config.properties");", the initial "/" is important, otherwise some package string is prepended.
- in manifest, use "Class-Path: lib/WrapperFramework.jar config/", the last "/" is important, otherwise it doesnt work. Super confusing since "." works fine.
Note that the folder in classpath is considered to be relative to the folder in which the original jar file is located. Hence if you execute jar from a random folder, the classpath is not broken (that's fortunate).
Edited by: AJG on Nov 15, 2007 5:33 PM

Similar Messages

  • Help need in Adding External jar files.

    Hi all,
    Iam developing ADF application using JDEV 11.1.1.3.0.
    I need to move files from one directory to another so i have used external jar "commons-io-1.4.jar" file.
    i did this by going to the project properties -->Libraries and Classpath -->Add Library
    added the jat file.
    In java class i have used the function
    File.copyFileToDirectory(reQueueFile, TargetLocation,false);
    it was working fine when i tried in IntegratedWeblogic server but when i deploy in Standalone Weblogic server its not getting the jar file.
    Its throwing me the exception
    javax.el.ELException: java.lang.NoSuchMethodError: org/apache/commons/io/FileUtils.moveFileToDirectory(Ljava/io/File;Ljava/io/File;Z)V
    at com.sun.el.parser.AstValue.invoke(AstValue.java:161)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1303)
    Please let me know is there a way of adding the lib to the project.
    Regards,
    Suresh kumar.k

    First you should check that the library has the checkbox 'Deploy by default' is checked for your library.
    The you open the project properties of the view controller project, select Deployments, edit the deployment descriptor. Select the Node 'File Groups'->'WEB-INF/lib'->'Contributors'. this should give you a list of libraries your project uses. Check if your library has the checkbox checked (is selected fro deployment). If it's not checked, set it.
    This should include the library.
    Timo

  • Exception while adding External Jar files in NWDS

    Dear Friends,
                            Actually i am adding an external Jar file in my EJB Module in NWDS.I am using this jar file for converting XML to flat file and i am calling this module from Receiver ommunication channel.For this process, i am importing dom4j.jar file in the EJB Module.
                          Now i have created an external Library project for the cause that i have used the external jar file, and i have made following code in the provider.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE provider-descriptor SYSTEM "library.provider.dtd">
    <provider-descriptor>
         <display-name>
          XML2EDI_Library
        </display-name>
         <component-name>
          XML2EDI_Library
        </component-name>
         <major-version>6</major-version>
         <minor-version>40</minor-version>
         <micro-version>0</micro-version>
         <provider-name>
          dom4j.org
        </provider-name>
         <references>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.Document</reference>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.DocumentException</reference>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.Element</reference>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.io.SAXReader</reference>
         </references>
         <jars>
              <jar-name>EDI_Module.jar</jar-name>
         </jars>
    </provider-descriptor>
    I have included 4 references because i have imported following in my ejb module.
    import org.dom4j.Document;
    import org.dom4j.DocumentException;
    import org.dom4j.Element;
    import org.dom4j.io.SAXReader;
    I am not sure of wht to include in reference target and provider name, I am getting the following exceptions in Message monitoring:
    1. AO: Document Exception: org.dom4j.DocumentException: E:\usr\sap\BWS\DVEBMGS00\j2ee\cluster\server0\
    2. Nested exception: E:\usr\sap\BWS\DVEBMGS00\j2ee\cluster\server0\
    Help me in this issue..
    Thanks in advance
    N.Jayanth Kumar

    thanks for you help sidharth.
    i have now jar files in the server and the application  referring to the jar files. everything is deployed fine. however, when i start the application..i get the error -"package jcifs.smb does not exist". the jar i am using is jcifs-1.2.7.jar. in my web module when i expand the jar i see the package and the .class files inside. what am i missing?
    Also, i din't define a SharingReference to usermanagement in portalapp.xml as i am working towards a pure j2ee enterprise application. the web module (DC) referes to the jar files. is there any step similar to defining the sharing reference for the web module DC?
    please help. thanks - sowmiyar

  • Adding External Jar files

    Hello,
    I have successfully created and deployed a portal application project (par file) that required adding as an external jar the file com.sap.portal.usermanagementapi.jar. Now I am re-doing the project as a development component in NWDI and I can add the external jar file fine and the source code shows no errors. However as soon as I build the DC I get a  source error that says the import to com.sap.ip.portal.service.ume.IUserManagementEngine can not be resolved. If I go back to the java build path the usermanagementapi.jar is no longer there.
    Do I have to handle the adding of external jar files in a different way for a DC as opposed to a par project?
    Thanks,
    Bert

    thanks for you help sidharth.
    i have now jar files in the server and the application  referring to the jar files. everything is deployed fine. however, when i start the application..i get the error -"package jcifs.smb does not exist". the jar i am using is jcifs-1.2.7.jar. in my web module when i expand the jar i see the package and the .class files inside. what am i missing?
    Also, i din't define a SharingReference to usermanagement in portalapp.xml as i am working towards a pure j2ee enterprise application. the web module (DC) referes to the jar files. is there any step similar to defining the sharing reference for the web module DC?
    please help. thanks - sowmiyar

  • JRE 6u19 - security warning   external properties file

    Hi,
    I have an applet with several jars files, all jars are signed.
    Since JRE 6u19, when launching my applet, I have the message "Java has discovered application components that could indicate a security problem".
    6u19 has a new security approach for application/applet mixing Signed and Unsigned Code.
    http://java.sun.com/javase/6/docs/technotes/guides/jweb/mixed_code.html
    Nevertheless, in my case, all jars are signed and I still have the warning message.
    I analyzed the code and noticed that the warning comes from the use of a properties file and a 'cacerts' file.
    The property file is used through the common class: java.util.Properties
    I think also that we have security warnings when using the following methods to get resources :
    this.getClass().getClassLoader().getResourceAsStream(fileName)
    or java.util.ResourceBundle.getBundle
    JRE 6u19 is supposed to verify if the jars are signed (and all my jars are signed) but I don' t understand why I have a security warning when using a properties file.
    I would appreciate to get help. thanks.
    Regards,
    Cédric

    I read your reply as: It should work to use the context classloader to load resources from unsigned jars without getting the warning. Is that correct?
    Unfortunately, I cannot attach context, so I am going to provide a small sample consisting of a handful of files, that produces a warning for me.
    To run the example:
    - Correct the codebase in the two jnlp-files
    - Compile the java-file, jar it to a jar called webstart.jar and sign the jar.
    - Jar the text file to a jar called resource.jar.
    - Run the webstart.jnlp.
    Main.java:
    package com.virtubuild;
    import java.io.*;
    import java.net.*;
    public class Main {
      public static void main(String[] args) throws IOException {
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        URL url = contextClassLoader.getResource("resource.txt");
        if(url==null) {
          System.err.println("Could not find external resource");
          return;
        readAndPrint(url);
      private static void readAndPrint(URL url) throws IOException {
        BufferedReader in = openFile(url);
        String inputLine = null;
        while ((inputLine = in.readLine()) != null) {
          System.out.println(inputLine);
        in.close();
      public static BufferedReader openFile(URL url) throws IOException{
        InputStream input = url.openStream();
        InputStreamReader ireader = new InputStreamReader(input,"UTF8");
        return new BufferedReader(ireader);
    webstart.jnlp:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="6.0+" codebase="file:///C:/TEMP/webstart/" href="webstart.jnlp">
      <information>
        <title>Webstart</title>
      </information>
      <security>
        <all-permissions/>
      </security>
      <update check="always" policy="prompt-update"/>
      <resources>
        <java version="1.6+"/>
              <jar href="webstart.jar" main="true"/>
      </resources>
      <resources>
           <extension href="resource.jnlp"/>
      </resources>
      <application-desc/>
    </jnlp>
    resource.txt:
    Test
    Testing
    Tested
    resource.jnlp:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="6.0+" codebase="file:///C:/TEMP/webstart/" href="resource.jnlp">
      <information>
        <title>Resource</title>
      </information>
    <update check="always" policy="prompt-update"/>
    <resources>
      <jar href="resource.jar"/>
    </resources>
    <component-desc/>
    </jnlp>The better way you mention is not really an option for us right now, but we will keep it in mind if we create another product deployed through webstart.

  • Adding resource.properties files to air package.

    I'm struggling adding my locale-de_DE-resource.properties and other files to my AIR
    They got ommitted from resulting AIR file and tehrefore my app doesnt work.
    locale folder attached like source folder in my project.
    Please advise.

    Im using Flash builder 4.01.
    Interesting thing is that flash builder include other files, if I rename file to resource.propertiesXX it includes it into package. What is so special with resource.properties files that they ommited from package?

  • Jserv properties file are reflecting in classpath

    Hi All,
    I'm facing some issue related with jserv.properties file
    we mentined some path for custom soap.jar in jser properties file and bounced apache but when I check the class path from front end(about this page>java properties>java class path) it is not reflecting in class path. this on Oracle apps 11i and multinode server, I have Jserv properties file from both the nodes and it contains the entries.
    Please let me know if someone has faced the same issue.
    Regards,
    Reetesh Sharma

    Hi Reetesh
    Check the link if it helps you out..
    Add few lines in jserv.properties file automatically
    Thanks
    AJ

  • Adding a properties file into SapDictionaryTypesRuntime.jar

    Hi,
    I would like to add a properties file to SapDictionaryTypesRuntime.jar located in plugins\com.sap.dictionary.runtime\lib.
    Could you please help me how i can do  that ?.I tried using WinZip to add a file ,didnt help.

    This jar-file is part of the framework so you should not add anything to it.
    For testing purposes, you can extract the jar-file in its directory, add the property file to some folder and recreate the jar file using the jar-utility.
    Armin

  • Adding External jar file in webdynpro in CE 7.1 EHP 1

    Hi,
    How to add external jar file in webdynpro component. I am using CE 7.1 EHP 1 SP04 .Public part of external library is used in the webdynpro dc.  I created Enterprise Application and used that in runtime in the wybdynpro dc also.
    I am not getting any error at the time of deploy but at the time of activating getting the following error.
    ERROR: E:\usr\sap\CED\J10\j2ee\cluster\server0\temp\CBS\1\.B\354\t\65FFED04CAA1231EE16A570686EC24D6\gen_wdp\packages\com\sap\home\ovsuser\ovsuserapp\comp\OvsUserComp.java:23: package com.sap.security.api does not exist
         [javac] ERROR: import com.sap.security.api.ISearchAttribute;
         [javac] ERROR:                             ^
         [javac] ERROR: E:\usr\sap\CED\J10\j2ee\cluster\server0\temp\CBS\1\.B\354\t\65FFED04CAA1231EE16A570686EC24D6\gen_wdp\packages\com\sap\home\ovsuser\ovsuserapp\comp\OvsUserComp.java:24: package com.sap.security.api does not exist
         [javac] ERROR: import com.sap.security.api.ISearchResult;
    Please help.
    Raktim

    Hello Raktim
    com.sap.security.api should be available within NWDS plugins and should work fine if you add sap-jee DC as used dc.
    For external jars check this link
    [http://wiki.sdn.sap.com/wiki/display/Java/Externaljarfileerrorand+Solution]
    works fine in netwever 7.01 .
    Regards

  • Question about Adding External Storage/File Management

    I am using LR5.2 on mid-2011 MBA. Before long I will run out of space on the HD. I have one catalog of about 16K photos. I would like to purchase external hard drive for additional storage. I use Time Machine for backup. What is the best way to manage the additional storage and keep the catalog intact?
    1) I currently have photos organized by date? i.e., Pictures/2013/2013-10-10/ etc. Should I keep this file organization as it is and then when importing new photos, select 'copy' from SD card and select 'Location' as new external drive?
    OR
    2) Should I move all photos to new backup drive to keep all files stored together? Would this be better for long term file management?
    Any recommendations for best practices? Or is there a better to organize photos for current and future use?
    Also, does the catalog stay in the same location under either 1) or 2)
    Thanks in advance

    I would suggest creating a root folder on the EHD. You will need to keep your EHD connected when working with Lightroom. It will show up like your Mac HD with the green light in the left hand panel.
    Leave everything where it is for the time being but you may want to drag older folders to the EHD over time, as importing new photos, generating previews and using the develop module will usually be faster on the main flash drive of the MBA.
    Don’t use Finder to move files/folders around. Always use the Lightroom Library and the database of files and your develop settings (catalog) will not get corrupted.
    See this video:
    http://www.youtube.com/watch?v=4trWRAeOsuA

  • Custom properties files in enterprise project

    Hi,
    I created a enterprise application containing 3 projects:
    - EAR project
    - EJB project
    - Web project
    And I added a properties file in :
    -EAR project/EarContent/APP-INF/afile.properties
    The content of this file is :
    Host=<path to host>
    Port=389
    And I have a .jar file that uses this properties file that is located in :
    -EAR project/EarContent/APP-INF/lib/afile.jar
    Then I add .jar file, through EAR project --> Right click --> Properties --> Deployment Assembly --> Add --> Archives from workspace
    It is then shown under EAR porject - Deployment Descriptor - Bundled Libraries - Library Directory
    When running the application, the JAR file executes as it should, but it cant find the properties file.
    In the .jar file I have a java file that locates the properties file and elements like this :
    private static final String BROKER_PROPERTY_NAME = "afile";
    brokerResources = PropertyResourceBundle.getBundle(BROKER_PROPERTY_NAME);
    String host = brokerResources.getString("host");
    int port = Integer.parseInt(brokerResources.getString("port"));
    Anyone know where to put the properties file to be able to get this to work?
    Regards, reZer

    Hi, thanks, it works :)
    After Clean, and Publish, and restart , remove, add it runs :)
    Is the Classes directory available when deploying to an production environment? So that I can change the content without the need for å redeployment?
    I could figure out where Weblogic stores deploymentfiles in my domain, EAR, WAR, EJB files, and lib and classes dir.
    -regards reZer

  • Accessing properties files in jspx page in ADF Generic application

    Hi All
    I have created an genric application .I have jdevloper 11.1.1.3.I need to add the .properties file in my application and access that properties file in my .jspx page.
    so i have created the Resources folder and added the properties file in that folder and now i am trying to access that contents of that properties file in my jspx page using below code
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
              <f:loadBundle basename="Resources.sampleproperty" var="props"/>
               <af:panelGroupLayout id="pgl1">
                 <af:outputText value="testing"  id="ot1" />
                  <af:outputText value="#{props['sample.label.text1']} " />
                  <af:outputText value="#{pageFlowScope.UserId}" />
              </af:panelGroupLayout>
    </jsp:root>but iam not able to access the propert and blank page is only displayed
    so what more steps i need to do to access it?
    Note:-previously i created the application of type Fusion Web Application ,where it added the folder named view and we used to add the .property file in it and accessed the contents of the .property file using above code and tthe above code was running fine.
    Thanks and Regards
    Bipin Patil

    Hi All
    I solved this issue
    by adding the following code in faces config.xml
    <application>
    <resource-bundle>
         <base-name>com.property.sampleproperty</base-name>
          <var>props</var>
        </resource-bundle>
    </application>note :The sampleproperty.properties should be present in java package com.property.sampleproperty
    please visit below link for more details.
    http://www.laliluna.de/articles/posts/jsf-2-evaluation-test.html

  • Adding External Jars in Module development

    Dear Friends,
                            Actually i am adding an external Jar file in my EJB Module in NWDS.I am using this jar file for converting XML to flat file and i am calling this module from Receiver ommunication channel.For this process, i am importing dom4j.jar file in the EJB Module.I have created a jar file for that module,
                          Now i have created an external Library project for the cause that i have used the external jar file, and i have made following code in the provider.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE provider-descriptor SYSTEM "library.provider.dtd">
    <provider-descriptor>
         <display-name>
          XML2EDI_Library
        </display-name>
         <component-name>
          XML2EDI_Library
        </component-name>
         <major-version>6</major-version>
         <minor-version>40</minor-version>
         <micro-version>0</micro-version>
         <provider-name>
          dom4j.org
        </provider-name>
         <references>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.Document</reference>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.DocumentException</reference>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.Element</reference>
              <reference
                   provider-name="dom4j.org"
                   strength="weak"
                   type="library">org.dom4j.io.SAXReader</reference>
         </references>
         <jars>
              <jar-name>EDI_Module.jar</jar-name>
         </jars>
    </provider-descriptor>
    I have included 4 references because i have imported following in my ejb module.
    import org.dom4j.Document;
    import org.dom4j.DocumentException;
    import org.dom4j.Element;
    import org.dom4j.io.SAXReader;
    I am not sure of wht to include in reference target and provider name, I am getting the following exceptions in Message monitoring:
    1. AO: Document Exception: org.dom4j.DocumentException: E:\usr\sap\BWS\DVEBMGS00\j2ee\cluster\server0\
    2. Nested exception: E:\usr\sap\BWS\DVEBMGS00\j2ee\cluster\server0\
    Help me in this issue..
    Thanks in advance
    N.Jayanth Kumar

    Dear Stefan,
                        I will explain my problem here..in brief
    1. I have created an EJB Module and adding an external jar dom4j.jar
    2. I have the my jndi name as XmltoText
    3. In my application-j2ee-engine.xml in my EAR file...i have included :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application-j2ee-engine SYSTEM "application-j2ee-engine.dtd">
    <application-j2ee-engine>
    <reference
         reference-type="weak">
         <reference-target
           provider-name="dom4j.org"
           target-type="application">TEST_LIBRARY
          </reference- target>
    </reference>     
    <fail-over-enable mode="disable"/>
    </application-j2ee-engine>
               TEXT_LIBRARY is name of my Library Project.Please tell me corrections in the above code...i have doubt regarding provider name.
    4. As i have added external jar file in my ejb module..._i have created a Library project and in that project in provider.xml_ file i have included the following code...
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE provider-descriptor SYSTEM "library.provider.dtd">
    <provider-descriptor>
         <display-name>TEXT_LIBRARY</display-name>
         <component-name>TEXT_LIBRARY</component-name>
         <major-version>6</major-version>
         <minor-version>40</minor-version>
         <micro-version>0</micro-version>
         <provider-name>****</provider-name>
    <references>
    <reference
         provider-name="****"
         strength="weak"
         type="library">****</reference>
    </references>
    <jars>
             <jar-name>EJBModule.jar</jar-name> (This is my EJB Module jar file)
    </jars>
    </provider-descriptor>
    Now what should i include in the places of **** in the references above??
    Thanks and Regards,
    N.Jayanth Kumar

  • Can't find properties file

    Hi, guys. I've been working all day trying to get my little app to find a properties file that I have. It's in both my source directory, and in the classes directory. I try to get it like:
    InputStream in = ClassLoader.getSystemResourceAsStream("user.properties");Since that file is where the .class file is, what am I missing when my code can't find that property file?
    Thanks!
    Jonathan

    Is this a desktop or a Web app?
    Web apps use a hierarchy of class loaders.
    Try this and see if it works better:
                ClassLoader classLoader           = Class.forName(CLASS_NAME).getClassLoader();
                URL propertiesURL                       = classLoader.getResource(propertiesFileName);
                InputStream propertiesStream    = propertiesURL.openStream();
                Properties properties                     = new Properties();
                properties.load(propertiesStream);
                propertiesStream.close();Make sure the path to the .properties file is in your CLASSPATH, of course. AND import java.net.URL.

  • Even after classpath setting in jserv.properties file  error.

    hi kali,
    i have used a custom jsp page for export to excell using a jar file poi-3i-200566.jar which i deployed in oracle apps version 11.5.10.2.
    the jar is put in $JAVA_TOP and class path entry is set in jserv.properties file as
    wrapper.classpath=/d2_u10/....../poi-3i-200566.jar .
    After setting the classpath , bounced the apache.
    But even after the setting , the same error continues.
    I refered the mod_jserv.log file for error details , the error is in import statement of classes present in the poi-3i-200566.jar file like
    could not find the symbol HSSRow , HSSpreadsheet , etc. all these are classes in jar file.
    please anybody know any extra conf is needed or any idea where i am going wrong.
    thanks
    prabhakr,ap

    Hi,
    Please check your jserv.properties file whether the custom class path that you have set is present or not in jserv.properties after restarting the AutoConfig and Apache server.
    Thanks & Regards,
    Sagarika

Maybe you are looking for

  • XSLT ?

    A silly question really, and one where I suspect the answer is yes, but I'll ask anyway. Does Safari (any version) suport XSLT?

  • Conductor collumn?

    Hi Maybe off topic... I have been importing some classical albums lately, and some albums is almost all about the conductor. He/She is the star of the recording. Example: Herbert Von Karajan. I still don't how, or where, to put the conductor's name i

  • Customizing Spry

    Is there a way to modify the borders and background images of spry flyout menus?

  • Adobe flash player for xoom

    Hi, when will the flasher player be available for the motorola xoom 3G?  if unknown, is there a replacement out there somewhere?

  • MOV files are not able to be synced into iPhone.

    Hi, there, Here is how I get this problem. I took the video on the iPhone 4, imported in Image Capture into a MacBook, so now in MacBook it is like IMG_xxxx.MOV. Now move this file into a Windows XP, where I sync my personal stuff is. So in iTune, un