gpt4 book ai didi

java - 使用java获取tomcat的安装目录

转载 作者:行者123 更新时间:2023-11-28 22:14:16 25 4
gpt4 key购买 nike

我想用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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com