HOw to access ApplicationResource.properties file using getSystemResource
I am using struts. I need to access ApplicationResource.properties file, which I define my connection String there. All my methods are static method, so I cannot use getResourceAsStream() method from ClassLoader class, so i have to use getSystemResourceAsStream() method. However, I always get class not found error. Inputstream is always null.
my ApplicationResource.properties file is stored in projectname/classes, and all my other classes store in projectname/classes/com/testname/. Can anybody tell me how to make it work? Thank you in advance.
Here is my code:
private static String getConnectionURL() throws FileNotFoundException,IOException,ClassNotFoundException
Properties properties = new Properties();
InputStream fromFile = ClassLoader.getSystemResourceAsStream("ApplicationResources.properties");
if (fromFile !=null)
properties.load(fromFile);
String connectionURL = properties.getProperty("progressiveURL");
return connectionURL;
}
Try either:
ClassLoader.getSystemResourceAsStream("/ApplicationResources.properties");
or
YourClass.class.getResourceAsStream("/ApplicationResources.properties");
in either case, you need to add the "/" prefix.
Similar Messages
-
How we write into properties file using get class method
Hi
I want to set some value into properties file using given code
can any one please tell me how i can do this.
property file
setting.properties
Name = abc
and code I use is
java.io.InputStream oInputStream = this.getClass().getResourceAsStream("Setting.properties");
Properties obj = new Properties();
obj.load(oInputStream);
String myName = obj.getProperty("Name");
System.out.println("myName :"+myName);
obj.setProperty("Name","def");
FileOutputStream oOutput= new FileOutputStream("Setting.properties");
obj.store(oOutput, "");
thanks.You can't.
If you have properties that change dynamically, you should not be using a properties file that sits in the classpath, you should be using Preferences, or a properties file that sits in some application or possibly even user directory, but not one in the classpath. The proper way to do this, would be to have a properties file in your jar (or otherwise in your classpath) that contains the defaults, and another one outside of the classpath in one of the twwo above mentioned areas, then, you read the default one only if the other doesn't exist, or you read the default one first, then read the other overwriting the values from the defaults.
Don't forget to save the properties again (right after loading if you loaded, or always load, the defaults) after every change. -
How to access jdbc jar file using JWS - Hlep needed
hi guys i am having a problem running jdbc jar files (msutil,msbase,mssqlserver) using JWS. I am able to downlod it to the client machine but i am getting an error
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error opening/loading com.microsoft.util.transliteration.properties.
i am able to run it locally. but using JWS in my machine itself is generating this error. In general what am i supposed to do to run an application using jdbc through JWS. I am able to download the jar files do i need to do anything more. Your help will be well appreciated.
thanks,
ravi.hi guys i got the problem solved i was not metioning security tag in the jnlp file with all permissions.
thanks,
ravi. -
Problem in accessing application server file using open dataset
Hi All,
I am trying to access application server file using open dataset command, its working fine for normal path which imention. But when i am giving path of XI server file, its not working. How to access XI server file using open dataset. Please let me know.
Thanks in advance.
Regards,
VishalHi Vishal,
You need to verify if the location where you are trying to save the file is in the same server of SAP. In case that the location is in other server you need to map that directy into the same server of SAP.
You need to point always to a location in the same server of SAP, in order that the open dataset could work.
Regards,
Eric -
How to update MainApplicationResources.properties file
Post Author: fjaffery
CA Forum: JAVA
I am trying to update a key in the MainApplicationResources.properties file in Tomcat\webapps\businessobjects\enterprise115\desktoplaunch\WEB-INF\src\com\crystaldecisions\ePortfolio\framework\main\ folder. After the changes, I have updated the desktop.war file and redeployed but my changes are not getting reflected in the ApplicationResources.properties file in Tomcat\work\Catalina\localhost\businessobjects_enterprise115_desktoplaunch\loader\com\crystaldecisions\ePortfolio folder. How do I propogate the .properties files changes to the combined ApplicationResource.properties file?
Thanks.I think i have mixed it up :)
I have looked at it again and believe you are using regular JSP portlets.
Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
Reading propertie files is easy:
// Read properties file.
Properties properties = new Properties();
try {
properties.load(new FileInputStream("filename.properties"));
String myKey = properties.getProperty("yourKey");
} catch (IOException e) {
}Edited by: Yannick.O on 13-Apr-2010 05:52 -
Hoe do I access a properties file ??
I am developing an application using JSPs on WLS6.1. My JSPs want to
access a properties file that will have declarative information. Where
do I keep the properties file, and how do I access it ??
Reply,
Hemant.
Herr Bedekar,
The servlet spec helps you out here. Check out:
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletContext.html#getResource
ga
[email protected] (Hemant Bedekar) wrote:
>I am developing an application using JSPs on WLS6.1. My JSPs want to
>access a properties file that will have declarative information. Where
>do I keep the properties file, and how do I access it ??
>
>Reply,
>Hemant.
-
How to access/open rpd files in offline mode from client desktop
Hi All,
Please tell me what configuration settings I need to have on my desktop to access RPD files stored on BI server?
In our OBIEE environment, we have BI server installed on linux server, and I have installed BI admin tool on my desktop (Windows OS).
I need to know what settings I should configure in my NQSConfig.ini file on my desktop so that I can access rpd files stored on BI server...
I can access online RPD using BI server ODBC connectibity, but want to access other offline RPD files stored in repository directory on linux server where OBIEE 11g server installation is done.
Thanks and Regards
Santosh
Edited by: 910192 on 22-Feb-2012 08:09Saichand,
Highly appreciate your response.
But wht I am looking for is how to access other RPD files stored in repository folder on server machine where BI server is running, from BI administration tool which is installed on my desktop
I am able to access default online repository on BI server using ODBC configuration from BI admin tool on my desktop, but want to access other rpd files (lets say sample rpd files which are installed on BI server machine) using (file->open-offline) option.
As per Jay, it seems it is not possible to access repositories other than online repository on BI server, and I will have to copy those rpd files on my desktop and then access using file->open->offline option in BI admin tool.
If you have any other way of doing this or have done this somehow , please let me know.
Thanks and Regards
Santosh -
How To Access a jar file present outside the war file through a jnlp
Aoa
I m new to this forum
I m having problem with my jnlp file
i want to know is there any way to access a jar file through jnlp.The problem is that my jnlp file is present in the war file
and i want to know how to acess a jar file through this jnlp.The scenerio is as below
I m using ear file on jboss.Its hirerchy is as
-PAN-war.war
-launch.jnlp
-PAN-app-client.jar
my jnlp file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="PAN/launch.jnlp">
<information>
<title>PanEmirates</title>
<vendor>M Fazal Ur Rehman</vendor>
<description>PanEmirates</description>
<description kind="short">PanEmirates</description>
<homepage href=""/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+"/>
<jar href="PAN-app-client.jar" download="eager"/>
<jar href="lib/javafxrt.jar" main="true" download="eager" />
<jar href="lib/Filters.jar" download="eager"/>
<jar href="lib/javafx-netbeans-fxuserlib.jar" download="eager"/>
<jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
</resources>
<application-desc main-class="net.java.javafx.FXShell">
<argument>pan.Main</argument>
</application-desc>
</jnlp>
when i run launch.jnlp file it says unable to download resource http://localhost:8080/PAN/PAN-app-client.jar
how to access this jar file
Any help or comment would be highly appreciated
Regards
M Fazal Ur RehmanExcellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
Write another EAR file with the following structure:
ear:
META-INF/application.xml
util.jar
client.jar
client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
Points to note are:
you have to repackage util.jar again inside this ear file.
For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
Hope this helps,
Sahoo -
How to read the properties file available in Server File structure in webdy
hi all,
I have developed one webdynpro application. In this application i need to access mdm server to continue. For getting the connection i need to pass the IP addresses.
Can i have code how to read the properties file which is residing in the server file. with out included along with the application. keeping some where in the file structure in the server. I want to read that properties file by maintain the iP addresses and users in properties file based on the key i want to read like below.
servername="abcServer"
username="john"
password="test123"
Please send me the code how to read this properties file from the file structure and how to read this values by key in webdynpro application
Regards
VijayHi Vijay,
You can try this piece of code too:
Properties props = new Properties();
//try retrieve data from file
//catch exception in case properties file does not exist
try {
props.load(new FileInputStream("c:\property\Test.properties")); //File location
String serverName = props.getProperty("servername"); //Similarly, you can access the other properties
if(serverName==null)
//....do appropriate handling
} catch(IOException e)
e.printStackTrace();
Regards,
Alka. -
How to access the *.java file corresponding to a TypeElement T?
Here is a problem:
How to access the *.java file corresponding to a TypeElement T from a AnnotationProcessor environment?
Let us say the hook method
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment roundEnv)
is invoked with a TypeElement T such that T.getQualifiedname() = "a.b.c.X"
And the problem is how to locate the file that has the *.java source code for a.b.c.X?
That is the file that has the source code for a.b.c.X say "some/path/a/b/c/X.java"?
For simplicity, let us assume that TypeElement T corresponds to a top-level Java class.Pinaki wrote:
That is not something you as the annotation processor author should be asking about. That is something you the person configuring the javac environment should set up via the -d option or its equivalent.
I strongly recommend using a separate output directory hierarchy.That is the way the current implementation is. The annotation processor takes a -Aout= <some directory path> to write generated output relative to a user-specified location (which defaults to the class output location).That is contrary to the design of the annotation processing facility. The intended use is for that information to be configured via options like "javac -d".
Additionally, IMO it is a serious configuration error to put generated files and input files, presumably tracked under version control, in the same directory. Interesting you said that. We are just running some "field trial" with these things and some users want them to be in the same directory of the original *.java files (especially when their source files are spread across many roots) .
Who knows what the user wants?The user does and the user is free to (mis)configure their environment however they like ;-) However, that is the user's option and the user has control of this via the javac command line. The annotation processor is not the proper place to configure this setting; see slide 7 of http://blogs.sun.com/darcy/resource/J1_2006-BOF-0606.pdf for some thoughts on different roles in annotation processing.
presumably tracked under version control, in the same directory.version control is another 'usability issues' that we are trying to get our heads around with this stuff. "To check-in or not?" - that seems to be the question. When presented these facilities without any cue, "the users" were divided -- some wanted them to be checked-in, some did not. The context where these generated files being used -- there exists some rationale to check them in a version control system.The right answer depends on the circumstances, but IMO generally generated files should not be checked in under version control, especially if they are derived from other source files. Checking in generated files of this nature just creates the opportunity for them to get out of date with the originating files. -
How to read from properties file
Hi,
I am using JSR 168.
while creating a new portlet, a folder gets created with the name as "portlet". Under which is resource package and <PortletName>Bundle.java.
pls tell me how to read from .properties file.
waiting eagerly for some reply
Thanks & Regards,
HP
Edited by: user9003827 on Apr 13, 2010 3:42 AMI think i have mixed it up :)
I have looked at it again and believe you are using regular JSP portlets.
Can you tell what you want to achieve by reading .properties file. Are you meaning the preferences of the portlet or what exactly are you trying to do?
Reading propertie files is easy:
// Read properties file.
Properties properties = new Properties();
try {
properties.load(new FileInputStream("filename.properties"));
String myKey = properties.getProperty("yourKey");
} catch (IOException e) {
}Edited by: Yannick.O on 13-Apr-2010 05:52 -
Does anyone know how i can view PDF files using Galaxy Note 2?
Does anyone know how i can view PDF files using Galaxy Note 2?
This is what i have been doing;
I click on the file i wish to view (via a portal)
this file goes to notification widget (i drag down screen)
notification/message says download complete
i click on notification/message
nows it says complete action using (here i only have 2 icon options 1= DB Text Editor 2 = HTML Viewer)
I have installed Adobe Reader.Can you confirm if the downloaded file is a pdf file, that is it ends with .pdf?
-
How to create new XML file using retreived XML content by using SAX API?
hi all,
* How to create new XML file using retreived XML content by using SAX ?
* I have tried my level best, but output is coming invalid format, my code is follows,
XMLFileParser.java class :-
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.XMLFilterImpl;
public class PdfParser extends XMLFilterImpl {
private TransformerHandler handler;
Document meta_data;
private StringWriter meta_data_text = new StringWriter();
public void startDocument() throws SAXException {
void startValidation() throws SAXException {
StreamResult streamResult = new StreamResult(meta_data_text);
SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
try
handler = factory.newTransformerHandler();
Transformer transformer = handler.getTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
handler.setResult(streamResult);
handler.startDocument();
catch (TransformerConfigurationException tce)
System.out.println("Error during the parse :"+ tce.getMessageAndLocation());
super.startDocument();
public void startElement(String namespaceURI, String localName,
String qualifiedName, Attributes atts) throws SAXException {
handler.startElement(namespaceURI, localName, qualifiedName, atts);
super.startElement(namespaceURI, localName, qualifiedName, atts);
public void characters(char[] text, int start, int length)
throws SAXException {
handler.characters(text, start, length);
super.characters(text, start, length);
public void endElement(String namespaceURI, String localName,
String qualifiedName) throws SAXException {
super.endElement("", localName, qualifiedName);
handler.endElement("", localName, qualifiedName);
public void endDocument() throws SAXException {
void endValidation() throws SAXException {
handler.endDocument();
try {
TransformerFactory transfactory = TransformerFactory.newInstance();
Transformer trans = transfactory.newTransformer();
SAXSource sax_source = new SAXSource(new InputSource(new StringReader(meta_data_text.toString())));
DOMResult dom_result = new DOMResult();
trans.transform(sax_source, dom_result);
meta_data = (Document) dom_result.getNode();
System.out.println(meta_data_text);
catch (TransformerConfigurationException tce) {
System.out.println("Error occurs during the parse :"+ tce.getMessageAndLocation());
catch (TransformerException te) {
System.out.println("Error in result transformation :"+ te.getMessageAndLocation());
} CreateXMLFile.java class :-
Sax.startDocument();
Sax.startValidation();
Sax.startElement("", "pdf", "pdf", new AttributesImpl());
Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());
String xmp_str = new String(meta_data.getByteArray(),"UTF8");
char[] xmp_arr = xmp_str.toCharArray();
Sax.characters(xmp_arr, 0, xmp_arr.length);
Sax.endElement("", "pdf", "pdf");
Sax.endValidation();
Sax.endDocument();
Sax.endElement("", "basic-metadata", "basic-metadata");* In CreateXMLFile.java
class, I have retreived the xml content in the meta_data object, after that i have converted into character array and this will be sends to SAX
* In this case , the XML file created successfully but the retreived XML content added as an text in between basic-metadata Element, that is, retreived XML content
is not an XML type text, it just an Normal text Why that ?
* Please help me what is the problem in my code?
Cheers,
JavaImranSax.startDocument();
Sax.startValidation();
Sax.startElement("", "pdf", "pdf", new AttributesImpl());
Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());
String xmp_str = new String(meta_data.getByteArray(),"UTF8");
char[] xmp_arr = xmp_str.toCharArray();
Sax.characters(xmp_arr, 0, xmp_arr.length);
</code><code>Sax.endElement("", "basic-metadata", "basic-metadata");</code>
<code class="jive-code jive-java">Sax.endElement("", "pdf", "pdf");
Sax.endValidation();
Sax.endDocument();
* I HAVE CHANGED MY AS PER YOUR SUGGESTION, NOW SAME RESULT HAS COMING.
* I AM NOT ABLE TO GET THE EXACT OUTPUT.,WHY THAT ?
Thanks,
JavaImran{code} -
How to upload an excel file using ABAP.
Hi,
Can anyone please help me in understanding how to upload an excel file using ABAP.
Thanks!!http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/
check the link
TYPES: Begin of t_record,
name1 like itab-value,
name2 like itab-value,
age like itab-value,
End of t_record.
DATA: it_record type standard table of t_record initial size 0,
wa_record type t_record.
DATA: gd_currentrow type i.
*Selection Screen Declaration
PARAMETER p_infile like rlgrap-filename.
*START OF SELECTION
call function ALSM_EXCEL_TO_INTERNAL_TABLE
exporting
filename = p_infile
i_begin_col = 1′
i_begin_row = 2′ Do not require headings
i_end_col = 14′
i_end_row = 31′
tables
intern = itab
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message e010(zz) with text-001. Problem uploading Excel Spreadsheet
endif.
Sort table by rows and colums
sort itab by row col.
Get first row retrieved
read table itab index 1.
Set first row retrieved to current row
gd_currentrow = itab-row.
loop at itab.
Reset values for next row
if itab-row ne gd_currentrow.
append wa_record to it_record.
clear wa_record.
gd_currentrow = itab-row.
endif.
case itab-col.
when 0001′. First name
wa_record-name1 = itab-value.
when 0002′. Surname
wa_record-name2 = itab-value.
when 0003′. Age
wa_record-age = itab-value.
endcase.
endloop.
append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD
Display report data for illustration purposes
loop at it_record into wa_record.
write:/ sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop. -
Get the pc name with domain name and add it to my properties file using commands
i want to get the pc name with domain name and add it to my properties file using powershell .
sidfunction Get-Environment{
[environment]|Get-Member -Static -MemberType Properties |
ForEach-Object{
if($_.Name -ne 'StackTrace'){
$v=[scriptblock]::Create("[environment]::$($_.Name)").Invoke()
New-Object PsCustomObject -Property ([ordered]@{Name=$_.Name;Value=$v[0]})
Get-Environment
Get-Environment | Out-String | Out-File environment.txt
¯\_(ツ)_/¯
Maybe you are looking for
-
Problems in SEND STEP with transport confirmation
Hi everyone. I have a send step in a BPM. This send step has the 'transport confirmation' switch activated. If destiny system (SAP R3) is down, XI will retry to send the message. Problem is that XI has been waiting for a long time (because of R3 back
-
How do I downgrade to V. 18?
I updated both Folio Builder and folio producer tools and now I have the Content viewer problem. How do I downgrade to V. 18? Thanks
-
Quick Question re: Vintage AUR Packages...
Hi, Just loaded Arch again after a few years, and noticed that a couple of my favorite command line apps had been relegated to the AUR for becoming "out of date." I really liked the apps, so I built them in the prescribed manner, using the -s and -r
-
Calendar info window does not appear?
When I double click an appointment in the calendar app the info window doesn't appear. However, it sometimes shows up when swiping the trackpad for mission control, but as if it's coming from off the screen. It still shows as being on Desktop 1 (I ha
-
Clear win passwprd on hp compaq 6000 pro
Clear window password