Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Glassfish 3.1.2 installed on Ubuntu, I've set up a separate "glassfish" user to run it as and have JDK 1.7.0 installed. If I log in as the "glassfish" user and start GF via the shell:

/usr/local/java/glassfish/glassfish-3.1.2/glassfish/bin/asadmin start-domain domain1

It starts up fine, so I think I have everything installed ok. The problem is trying to start it with the following init.d script:

#! /bin/sh
export AS_JAVA=/usr/local/java/jdk1.7.0

case "$1" in
echo "starting glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1
$0 stop
$0 start
echo "stopping glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1
echo $"usage: $0 {start|stop|restart}"
exit 3

On trying that I get:

exec: 54: java: not found

I've also tried adding the following line to the init.d script:

export PATH=/usr/local/java/jdk1.7.0/bin:$PATH

But that didn't seem to do anything. I've been using instructions on to get this far. As someone more familiar with Windows I'd really appreaciate any help identifying the problem. Thanks.

share|improve this question
up vote 1 down vote accepted

It would take a little tracing to figure out what's setting the path but an easy way is to edit asadmin. It's a shell script and you can set the full path to java in there.

share|improve this answer
Good tip, I might resort to that, although I'd still like to try and understand why it isn't working at the moment. If nothing else comes up in the next day or two I'll accept this as the answer. – Nick Wilson Apr 24 '12 at 8:08
For tracing, I would look at the sudo stage. Print the environment from the init.d script and then again at the top of the asadmin script. I usually use su from init.d scripts. – JOTN Apr 25 '12 at 0:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.