• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Finding the current path

 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a Java application running on JBoss application server. The JBoss instance name is different in development, UAT and production regions.

jboss\server\app_d\KPMapp
jboss\server\app_uat\KPMapp
jboss\server\app_p\KPMapp

Is it possible to get the current isntance name or path using Java code within the application? I need to know the path for some special logic but I don't want to hardcode the path for each environment. Appreciate any suggesions.

Thanks much.
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on intermediate Java.

For more information, please read this.

This post has been moved to a more appropriate forum.

 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dilip ,

Do you mean the pwd or cwd of the class file which is actually running. may be try getting the results from System.getProperty(user.dir) . Look for other properties as well which might help you.
SystemClass
PS: i haven't tried it yet. let us know if that works.

 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, follow the suggestions given by Bear. Please carefully choose the forum before posting, if you want to get the results quickly. Our moderators/bartenders would move this thread to the appropriate forum for you.

Dilip kumar wrote: I need to know the path for some special logic but I don't want to hardcode the path for each environment. Appreciate any suggesions.



You can make use of a .properties file to accomplish the same. You have to make use of java.util.Properties class for reading the .properties file.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The system property jboss.server.home.dir contains the location of the server configuration directory: "jboss_home/server/xxx"
 
Bring out your dead! Or a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic