我想用java获取我电脑中tomcat的安装目录。我尝试使用:
System.getProperty("catalina.base");
和
System.getProperty("catalina.home");
但这两种方法都返回 null
作为答案。我用 System.getProperty("java.home");
试过了,它正确地返回了 java 路径。
关于问题是什么的任何想法?谢谢
最佳答案
尝试安装此 JSP 并为“property”参数传递各种值:
<%
String propertyName = request.getParameter("property");
Object propertyValue;
String typeString;
if(null == propertyName)
propertyValue = null;
else
propertyValue = System.getProperty(propertyName);
if(null == propertyValue)
typeString = "null";
else
typeString = propertyValue.getClass().getName();
%>
The system property <code><%= propertyName %></code> has the value:
<code><%= propertyValue %></code> (<%= typeString %>).
也许您可以找到属性值返回 null 的模式。
关于java - 使用java获取tomcat的安装目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10708295/