Use update-alternatives to set JAVA_HOME on debian

Description

Patch from community to change way JAVA_HOME is set for debian

Environment

None

Activity

Show:

Lawren May 2, 2014 at 5:38 PM

Looks good. I tested it with my java and openjdk-7. Both now work with or without the variable set in /etc/default/openfire.

Thanks again for the quick response.

Daryl Herzmann May 2, 2014 at 5:12 PM

Lawren May 2, 2014 at 4:48 PM
Edited

Thanks for the quick response,

/etc/default/openfire is packaged with openfire.

We already have an "Include" of the file in the init script on line 41.

If we move this Include to line 22 before any of the update-alternatives section then we will be able to set the JAVA_HOME variable and skip all the update-alternatives stuff.

As you see here I added the JAVA_HOME variable to the end of the /etc/default/openfire file:

I would still fix the sed line so it works with any java path.

Daryl Herzmann May 2, 2014 at 3:20 PM

Lawren, Is the file in /etc/defaults/ or /etc/default/ ?

Lawren May 1, 2014 at 8:11 PM
Edited

I just upgraded to openfire version 3.9.2 .

We roll our own java which causes problems.

In 3.9.1 the init script test for /usr/lib/jvm/java-6-sun and uses that as JAVA_HOME . I used to create a symlink there pointing to my java directory.

3.9.2 introduces the update-alternatives test.

I didn't have an update-alternatives set so I considered adding an entry for my java directory, but even if I do that, your sed doesn't doesn't match on my java path:

sed 's/\/jre\/.*//g

A more defensive command here might be:

sed 's/\/bin\/java//'

It might also be a good idea to test for a standard directory like /usr/local/java before you do the update-alternatives testing.

Finally, if you perform the include of the defaults file first before any of these tests then I could just set JAVA_HOME in the /etc/defaults/openfire file.

. /etc/default/openfire

Thanks for great product,
-Lawren

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created February 17, 2014 at 3:21 PM
Updated May 2, 2014 at 5:38 PM
Resolved May 2, 2014 at 5:12 PM