why System.getenv("CATALINA_HOME") returns null?

Possible reasons:

  1. You've used set CATALINA_HOME in a command prompt. That makes this variable local to this window. It should be visible to processes started from this command prompt but nowhere else. Use My Computer > Advanced > Environment Variables to make a variable visible to all new processes.

  2. The process which tries to read the variable is already running. Restart it. (it applies to an IDE running java which needs to be restarted, or the java process to be restarted).

  3. The start script of Tomcat unsets the variable before it invokes java.exe

  4. Tomcat unsets the variable in it's Java code.


If method system.getenv("some name") return null probably you define this variable in your environment after lunching your Eclipse IDE. Just restart your Eclipse and then run your project again.