Setting JAVA_HOME automatically

Asked by hasgarion

Hello,

IS:
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 http://stackoverflow.com/a/23645482/1220636 I need to update it everytime
a new / different version of a jdk is installed or used.

WISH:
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,
Alexander

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu openjdk-8 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

I suggest you report a bug

Revision history for this message
hasgarion (hasgarion) said :
#2

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,
Alexander

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

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 :
#5

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 :
#6

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.