in my servlet,there is following code block:
File f=new File("%JAVA_HOME%\\test.txt");
the "JAVA_HOME" is the environment variable of my windows.after i deploy it to jboss,it threw exception.that tell me can't find the path.
then i modify it as:
File f=new File("%JBOSS_HOME%\\test.txt");
the "JBOSS_HOME" is definde in its "run.bat " file.
the code still don't work.
who can tell me :
1 how can i use the environment variable of os or app server?
2 how and where can i set up a envrionment variable as the base dir ?
I don't believe Java security features will allow you to get a handle on the jboss home dir environment variable with pure Java, but the standard way of getting the java home dir is like this:
String javaHome = System.getProperty("java.home");
See this Java tutorial page for more system properties you can use: