Setting JAVA_HOME automatically

Asked by hasgarion


when I install openjdk-8-jdk I can run e.g. javac and can work with java.
When a framework like Hybris requires the env var JAVA_HOME to be set, it is not.
It will not run without a proper JAVA_HOME, so I need to set it myself (/etc/environment or .bashrc)
But when I need to change to let's say openjdk-7-jdk (for an older hybris version) I need to readjust
JAVA_HOME by hand, as it is not handled by update-alternatives
If I modified the alternatives according to I need to update it everytime
a new / different version of a jdk is installed or used.

each jdk should define JAVA_HOME in a way it can be set by update-alternatives.
Unfortunately I am very new to ubuntu so I have no point to start with this issue myself.
If someone could point me in the right direction (how to integrate alternative env vars in packages)
I could try to work on it.

Best wishes,

Question information

English Edit question
Ubuntu openjdk-8 Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :

I suggest you report a bug

Revision history for this message
hasgarion (hasgarion) said :

Hello Andrew, thank you for your reply. I'm not sure it's a bug, more a feature request? Can you give me a hint were to start to work on it?
Best wishes,

Revision history for this message
Manfred Hampl (m-hampl) said :
Revision history for this message
Launchpad Janitor (janitor) said :

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.

Revision history for this message
hasgarion (hasgarion) said :

Hi Manfred, yes I did, but I'm looking for a more generic approch to have set JAVA_HOME by update-alternatives.

Revision history for this message
Manfred Hampl (m-hampl) said :

I do not think that you can use update-alternatives to set an environment variable (that's not what it was made for).

Maybe you can create a script that does both - using update-alternatives AND setting the env variable?

Can you help with this problem?

Provide an answer of your own, or ask hasgarion for more information if necessary.

To post a message you must log in.