FAQ Database Discussion Community

## Problems reading keys from properties file java

java,properties-file
I have a properties file that is used to control specific variables within my application. All but one of the keys I am using work perfectly fine as the application has been working. The structure of the ini file is: JDBC_DRIVER=com.mysql.jdbc.Driver DB_URL=localhost/tempTables [email protected] [email protected] host=<sanitised> port=25 USER=root PASS=Fo0b4R path=C:/Users/foo/Desktop/profile_admin_ logLevel=2...

## Parsing a .properties file with getClassLoader()

java,inputstream,properties-file
I'm writing a Java program that takes a foo.properties file and parses it into a Properties object. After a quick search, I found this code: public Properties getProperties() throws IOException{ String fileIn = "foo.properties"; Properties p = new Properties(); InputStream inStream = getClass().getClassLoader().getResourceAsStream(fileIn); if(inStream != null) { p.load(inStream); } else...

java,localization,internationalization,translation,properties-file
I have the following Java i18n Message class.: public class Messages { private static final String BUNDLE_NAME = "languages.message"; private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private Messages() { } public static String getI18n(String key) { try { return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { return '!' + key +...

## Constants and properties in java

java,configuration,constants,config,properties-file
Java best practices recommends read properties as constants. So, what do you think is the best approach to reach it? My approach is: A Configuration class to read the properties file only one time (singleton pattern) and use this class to read properties when needed as constants. And a Constants...

java,properties,jboss,properties-file,jboss-eap-6
I am new to jboss eap 6.3. I have to load a list of configuration parameters (properties file) into a cache in my application running on jboss eap 6.3. I checked the developers guide from red hat but did not find anything specific. Any pointers will help. I have this...

## How do you populate a displaytag column title with a Struts2 properties file entry?

struts2,displaytag,properties-file
In Struts2 you can populate a label for a component with a value from a properties file. The properties file must have the same name as the Struts2 Action Class that will serve up the JSP and be in the same folder as that Action Class. <s:textfield key="field.label.casereference" name="caseReference" />...

## WiX - Set MSI's Program name

wix,windows-installer,manifest,properties-file,details
in my WiX installer, if I right-click my MSI, hit Properties, go to Details, and browse the details of my MSI package, I see that under Origin, the default Program name is set to Windows Installer XML Toolset (3.9..... How can I change the Program name that appears in the...

## Why Ant add an equal character in properties file

encoding,ant,properties-file
I have a some given properties file like this : firstvalue=1 secondvalue=hello I use this Ant script to change a value : <propertyfile file="A.properties"> <entry key="firstvalue" value="2" /> </propertyfile> After executing the script, the properties file is now : #Wed, 20 May 2015 11:42:46 +0200 = firstvalue=2 secondvalue=hello I understand...

I'm using Spring Boot 1.2.2.RELEASE, JUnit4, and Gradle 2.1 for a RESTful service and am trying to define a properties file which includes and/or overrides values which will be used in JUnit tests only. All tests execute without an issue when invoked as a JUnit test. However, when these same...

As part of building a number of projects, I would like to sort the contents in some property-files that are semi-generated but also checked in to source control. The generation/update step in Gradle leaves them in different order (Done in 3rd party plugin code, probably the changing ordering is due...

## How can I load a resource bundle properties file within a composite component?

jsf,composite-component,resourcebundle,properties-file
My component library directory tree is setup as the following: resources mylib css mycomponent.css properties mycomponent.properties mycomponent.xhtml I'd like to load the properties file within mycomponent.xhtml to use for messages. What is the proper way of doing this? Is there an f:loadbundle type of solution?...

## Using maven profiles to configure code based a Spring application

properties-file,spring-4,maven-profiles
I have a Spring application which is complete code based configured. And I am trying to combine maven profiles to setup my db connections. I defined some properties for a local, live and staging issues. Now I try to get control over maven profiles. Every profil defines my MySql db...

## Open a properties file from a class in a Dynamic Web Project

java,eclipse,jsp,properties-file
I'm using Eclipse for EE Developer. I need to access to a properties file (db.properties) from a class's method (DBQuery.java). The class is located inside a package inside the src folder. For the properties file i tried almost everything that i could find over the net to make it work,...

## How to fill HashMap from java property file with Spring @Value

java,spring,properties-file,spring-el
Is it possible to use Spring @Value, to map values from properties file to the HashMap. Currently I have something like this, and mapping one value is not a problem. But I need to map custom values in HashMap expirations. Is something like this possible? @Service @PropertySource(value = "classpath:my_service.properties") public...

## Inject values from messages.properties into ValidationMessages.properties

java,spring,hibernate,hibernate-validator,properties-file
I need to change the @NotNull message used by hibernate-validator. Have successfully done this using a line in ValidationMessages.properties, e.g: javax.validation.constraints.NotNull.message=my validation message. However, this isn't quite what's needed. Will spare the details about why but all these messages should originate from a single messages.properties file, whose purpose is not...

## Resource and properties file management issue

java,spring,resources,properties-file
I am trying to learn spring. I have some trouble to manage my resource and properties file. This is my mvc-dispatcher-servlet.xml file. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd...

## Can't load multiple property files in spring's application context

java,spring,spring-mvc,properties-file
I have three property files placed in a resource folder in classpath. The problem i am facing is while i am able to load invidual files separately i am unable to load them when they are declared together. Please see the XML below: <bean name="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basenames" value="resources\label"/> </bean>...

## Is it possible to use two “job.properties” file in a workflow oozie?

I need to use another file than the job.properties for my workflow. This file have the same structure than a properties file. I have a generator of result's path which create this file. The particularity of this one, is that it's change each time the workflow is launched (with new...

## How can I retrieve an external .properties file in Java?

java,file,java-ee,inputstream,properties-file
Hello to everybody I have the following problem trying to load a properties file from a directory that is external to my project. So my project have the following structure: PROJECT-ROOT | | |-----> confi | |------> src | | |------> mainPkg (the package name) | | |------> Main (the...

## java.lang.IllegalArgumentException: 'hello' does not contain an equals sign

java,apache-commons,properties-file
I am currently using the Apache commons configuration library to write and read data from a file. I am able to save the key value pair colors=hello to the user..properties file, but when i try to read the value is get the below exception. Exception in thread "main" java.lang.IllegalArgumentException: 'hello'...

## Does java.util.Properties support nested properties?

java,nesting,properties-file