File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes How can i get a resource using relative path ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How can i get a resource using relative path ?" Watch "How can i get a resource using relative path ?" New topic
Author

How can i get a resource using relative path ?

Eusebio Floriano
Ranch Hand

Joined: Mar 07, 2004
Posts: 237
Hello,

I would like that my app could get a resource that is out of my ear but
using a relative path.
For example,
if my app is deployed in "c:\jboss-4.0.0\server\myapp\deploy", i would like to
access "c:\jboss-4.0.0\sever\myapp\conf\blabla".
But if using the relative path is "c:\jboss-4.0.0\bin", right ? So, how to get the information that my application is running on the context "myapp" ?
As these resources are not in my classpath, i can�t use


Does anyone know how to help me ?

Regards,


SCJP 1.4 / 5.0 - SCBCD 1.3 - SCWCD 1.4 - IBM 484
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

Are you looking for the home folder of your server? This is going to return you the home folder of your server:


So if you have deployed the application in C:\jboss\server\myapp\deploy\xyz.ear, then the above property is going to return you C:\jboss\server\myapp. Is this what you are looking for?


[My Blog] [JavaRanch Journal]
Eusebio Floriano
Ranch Hand

Joined: Mar 07, 2004
Posts: 237
Jaikiran,

It was exactly what i was looking for.
Thank you very much.

Regards,
subodh axe
Greenhorn

Joined: Jun 22, 2011
Posts: 2
Jaikiran Pai wrote:Are you looking for the home folder of your server? This is going to return you the home folder of your server:


So if you have deployed the application in C:\jboss\server\myapp\deploy\xyz.ear, then the above property is going to return you C:\jboss\server\myapp. Is this what you are looking for?


how can i get the same for server installed in linux?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

The code remains the same irrespective of the operating system. The value returned will correspond to the path where the JBoss AS is installed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i get a resource using relative path ?