使用java获取tomcat的安装目录 [英] Getting tomcat's installation directory using java

查看:534
本文介绍了使用java获取tomcat的安装目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用java在我的计算机中获取tomcat的安装目录。我尝试使用:

I want to get tomcat's installation directory in my computer using java. I tried using :

System.getProperty("catalina.base");

System.getProperty("catalina.home");

但两种方法都返回 null 作为答案。我尝试使用 System.getProperty(java.home); 并正确返回java路径。
关于问题是什么的任何想法?谢谢

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

推荐答案

尝试安装此JSP并为property参数传递各种值:

Try installing this JSP and passing various values for the "property" parameter:

<%
  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的模式。

Maybe you can find a pattern to which property values return null.

这篇关于使用java获取tomcat的安装目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆