本文介绍了Log4j电子邮件错误“无法找到java.home ??”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在J2SE下使用log4j。我已经配置它使用一个邮件程序的某种类型的日志事件..当logger.error触发我得到以下异常:

  java.lang.Error:找不到java.home? 
at sun.net.NetProperties.loadDefaultProperties(NetProperties.java:45)
...
在org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:416)

以前有人遇到过吗?我也有包含所需的mail.jar库。



任何帮助都不胜感激。
谢谢,
Chris

解决方案

我查看了,错误基本上是指它说的。名为java.home的System属性未设置。根据,该属性由JVM自动设置为java安装目录。



我可以想到的唯一的解释是,您的应用程序或您正在使用的某些第三方库中的某些内容已明确地取消设置该属性。这显然是一件坏事...


I'm using log4j under J2SE. I've configured it to use a mailer for a certain type of log event.. When the logger.error triggers I get the following exception:

java.lang.Error: Can't find java.home ??
at sun.net.NetProperties.loadDefaultProperties(NetProperties.java:45)
...
at org.apache.log4j.net.SMTPAppender.sendBuffer(SMTPAppender.java:416)

Anyone run into this before? I have the required mail.jar library included as well.

Any help is appreciated.Thanks,Chris

解决方案

I looked at the source code of NetProperties and the error basically means what it says. The System property called "java.home" is unset. According to the javadoc for System.getProperties(), that property is set automatically by the JVM to the java installation directory.

The only explanation I can think of is that something in your application or some third-party library you are using has explicitly unset that property. That is obviously a bad thing to do ...

这篇关于Log4j电子邮件错误“无法找到java.home ??”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 12:43