1

How do I set an environment variable for sudo in MacOS?

view story
linux-howto

http://unix.stackexchange.com – I have installed ServiceMix on my machine, and am trying to start it. The startup script is called start.sh. When I did ./start.sh, it gave me a Permission Denied message. So I used sudo ./start.sh, which starts the server fine. However, it seems to be using Java 7, when I would like to use Java 6 (for various reasons). I looked through the start.sh script and found that it uses the JAVA_HOME variable. So I set my JAVA_HOME to the JDK 6 directory. However, ServiceMix still uses Java 7. A Google search revealed that when a command is run with sudo, sudo removes certain environment variables. (HowTos)