File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes locate properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "locate properties file" Watch "locate properties file" New topic
Author

locate properties file

arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
I have a build developed on window.Now this build need to be deployed on linux in jar format.working as user wasadmin

In this jar I am loading application.properties file from
/home/wasadmin/jar/application.properties.
b.jar is also in same folder

I am trying two options
1)in = new FileInputStream(
new File(propertiesFilePath+propertiesFile));

//sct01.px-dc.dl.com/home/wasadmin/jar/application.properties
java.io.IOException: Unable to locate resource application.properties

where sct01.px-dc.dl.com is linux server name
which I am reading as
in = new FileInputStream(new File(propertiesFilePath+propertiesFile));
public static final String APPLICATION_PROPERTY_FILE = "application.properties";
public static final String APPLICATION_PROPERTY_FILE_PATH ="//sct01.px-dc.dl.com"+"/home/wasadmin/jar/";

2)if i replace above code with this
in=ClassLoader.getSystemResourceAsStream("com/application.properties");
error message unable to access b.jar
important point for 2nd is when i run this jar on windows it is working fine
but when deployed on linux nothing happening

any idea
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
public static final String APPLICATION_PROPERTY_FILE_PATH ="//sct01.px-dc.dl.com"+"/home/wasadmin/jar/";

May I ask why you have added the "//sct01.px-dc.dl.com" to the front of the path?

If your code is on the same machine you don't need this (just use the "/home/wasadmin/jar/").

If your code is on a different machine, then you probably need to either tell it the network protocol lto use or (and probably a better solution) mount the remote directory somewhere in the filesystem of the local machine. But I would be surprised if this is the case from your description above.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
thanks you are right.machne name is not needed as code is on that machine only
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: locate properties file