I want to get tomcat's installation directory in my computer using java. I tried using :
System.getProperty("catalina.base");
and
System.getProperty("catalina.home");
But both methods return null
as the answer. I tried it with System.getProperty("java.home");
and it correctly returns the java path.
Any ideas as to what the problem is? Thanks
I also encountered the same error as you did. but then I realized that the tomcat server was not running. After starting the server, I still failed to get the tomcat path.
Then I realized that I was trying to get the path from the main method in a JSF project while tomcat was still running.
So i finally got the tomcat path by using:
System.out.println(System.getProperty("catalina.base"));
in a@PostConstruct
method of one of my@ViewScoped
beans in aJSF
project. And it successfully displayedC:\Documents and Settings\S!LENT W@RRIOR\Application Data\NetBeans\7.2.1\apache-tomcat-7.0.27.0_base
in the console inNetBeans
.So In order to get Tomcat's installation directory, following points should be kept in mind:
main
methodhope this helps
we are using cucumber for testing and in cucumber cases, we are accessing project's individual method. in project, we are reading configuration for xml and the location is in config folder of Apache tomcat. Now when i run project,System.out.println(System.getProperty("catalina.base")); it's provide the proper path however when i call project's method from cucumber then it's returning null
Try installing this JSP and passing various values for the "property" parameter:
Maybe you can find a pattern to which property values return null.