Log4j email error "Cannot find java.home ??"

I am using log4j under J2SE. I configured it to use an email program for a specific type of log event. When logger.error triggers 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) 

Has anyone come across this before? I also have the required mail.jar library.

Any help is appreciated. Thanks Chris

+4
source share
1 answer

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

The only explanation I can think of is that something in your application or any third-party library that you use explicitly disables this property. This is obviously a bad thing ...

+5
source

Source: https://habr.com/ru/post/1344342/


All Articles