This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 235
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: 9915
    
158

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: 235
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: 9915
    
158

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 ?
 
Similar Threads
How to run more than one JBoss 4.x server in one m/c
Accessing resources outside of the Jar
Jboss Starter Duke's Bank Application
temp location
Tomcat 404 error