You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by Markus Rathgeb <ma...@gmail.com> on 2019/03/05 12:41:34 UTC
Karaf: Java detection on Karaf
Hi,
I recently decided to remove my system wide Java installation from my
Gentoo machine.
I don't need it system wide.
I am the only user of that system that needs Java -- to be more
precise I am the only user of the system at all.
Additionally I switch between different Java versions and dstributions
for testing purposes.
I ensure that a java is present in a directory that is part of the
PATH environment variable.
Additionally I set JAVA_HOME to the desired location.
All tools still work as expected.
BUT: I realized that Karaf does not work as expected anymore.
It is caused by the function "locateJava" in
"./assemblies/features/base/src/main/filtered-resources/resources/bin/inc".
If the environment JAVA is not set and the file "/etc/gentoo-release"
is readable, JAVA_HOME is set to the output of "java-config
--jre-home".
"java-config" does not exist on my system at all.
It is only present if you install global Java support on the Gentoo
machine, so it is optional.
I also wonder why JAVA_HOME is not, if it is already set?
There are several options:
* If JAVA_HOME is set, keep it as it is.
* If JAVA / JAVA_HOME is not set /etc/gentoo-release is present AND
java-config is executable, execute it.
* ...
WDYT?
Why is there a requirement for "java-config" on Gentoo?
Why is "java-config" used if I already set JAVA_HOME to a specific
Java location?
Best regards,
Markus
Re: Karaf: Java detection on Karaf
Posted by Markus Rathgeb <ma...@gmail.com>.
Thanks!
Am Fr., 8. März 2019 um 06:29 Uhr schrieb Jean-Baptiste Onofré
<jb...@nanthrax.net>:
>
> Hi Markus,
>
> for the tracking:
>
> https://issues.apache.org/jira/browse/KARAF-6189
>
> Regards
> JB
>
> On 07/03/2019 10:57, Markus Rathgeb wrote:
> > Hi JBO,
> >
> > any news about your findings?
> >
> > Best regards,
> > Markus
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
Re: Karaf: Java detection on Karaf
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Markus,
for the tracking:
https://issues.apache.org/jira/browse/KARAF-6189
Regards
JB
On 07/03/2019 10:57, Markus Rathgeb wrote:
> Hi JBO,
>
> any news about your findings?
>
> Best regards,
> Markus
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Karaf: Java detection on Karaf
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Markus,
I'm completing a Felix ConfigAdmin release and I will check.
I keep you posted.
Regards
JB
On 07/03/2019 10:57, Markus Rathgeb wrote:
> Hi JBO,
>
> any news about your findings?
>
> Best regards,
> Markus
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Karaf: Java detection on Karaf
Posted by Markus Rathgeb <ma...@gmail.com>.
Hi JBO,
any news about your findings?
Best regards,
Markus
Re: Karaf: Java detection on Karaf
Posted by Markus Rathgeb <ma...@gmail.com>.
I assume you just need to create a file "/etc/gentoo-release" and mark
it readable for your user.
Am Di., 5. März 2019 um 16:49 Uhr schrieb Jean-Baptiste Onofré
<jb...@nanthrax.net>:
>
> Hi Markus,
>
> you are right: I'm on Debian but not with java provided package.
>
> On my system, I manually installed java in /opt/java and define
> JAVA_HOME in /etc/profile.
>
> It seems in your case that JAVA_HOME is not considered. Let me try to
> reproduce playing with the env variables.
>
> Regards
> JB
>
> On 05/03/2019 16:35, Markus Rathgeb wrote:
> > Hi JBO,
> >
> >> I don't think java-config is used if you have JAVA_HOME defined right ?
> >> (it's what I have on my systems).
> >
> > You are using Gentoo / have a readable file "/etc/gentoo-release" and
> > you also did not install the system wide java support?
> > What a remarkable coincidence.
> >
> > I wonder why it is working on your system.
> > My reading of the scripts indicates the problem should exist in this
> > constellation.
> >
> > Please have a look at the output following information:
> >
> >
> > Here my current JAVA_HOME:
> > ===
> > $ echo $JAVA_HOME
> > /home/rathgeb/bin/pkgs/java/jdk/8/current
> > ===
> >
> > As you can see java is part of the PATH
> > ===
> > $ command -v java
> > /home/rathgeb/bin/pkgs/java/jdk/8/current/bin/java
> > ===
> >
> > The current java version is
> > ===
> > $ java -version
> > java version "1.8.0_202"
> > Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
> > Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
> > ===
> >
> > Now let's start Karaf
> > ===
> > $ bin/karaf
> > /home/rathgeb/workspace/projects-oss/karaf/bin/apache-karaf-4.3.0-SNAPSHOT/bin/inc:
> > line 198: java-config: command not found
> > karaf: JAVA_HOME not set; results may vary
> > karaf: Enabling Java debug options:
> > -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
> > Listening for transport dt_socket at address: 5005
> > __ __ ____
> > / //_/____ __________ _/ __/
> > / ,< / __ `/ ___/ __ `/ /_
> > / /| |/ /_/ / / / /_/ / __/
> > /_/ |_|\__,_/_/ \__,_/_/
> >
> > Apache Karaf (4.3.0-SNAPSHOT)
> >
> > Hit '<tab>' for a list of available commands
> > and '[cmd] --help' for help on a specific command.
> > Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
> >
> > karaf@root()>
> > ===
> >
> > You see the message
> > ===
> > /home/rathgeb/workspace/projects-oss/karaf/bin/apache-karaf-4.3.0-SNAPSHOT/bin/inc:
> > line 198: java-config: command not found
> > ===
> >
> > So, please have a look at:
> > https://github.com/apache/karaf/blob/8c3dda1/assemblies/features/base/src/main/filtered-resources/resources/bin/inc#L187-L217
> >
> > ===
> > if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
> > JAVA_HOME=$(java-config --jre-home)
> > fi
> > ===
> >
> > If the environment JAVA is not set (AFAIK this is not a commonly used
> > one) and there is a readable "/etc/gentoo-release" file, JAVA_HOME is
> > set by using "java-config" -- regardless if the tool is present.
> >
> > The "locateJava" method is called by e.g. the init method of Karaf.
> >
> >
> >
> >> but you can define JAVA_HOME in bin/inc right ?
> >
> > Sure, I can modify "bin/inc" all the time I unpack the official distribution.
> > But is this what you would like to tell users?
> > e.g. "If you unpack the official distribution and use Gentoo without
> > "java-config" present, please edit the "bin/inc" file in front of
> > starting karaf."
> > I don't think this is nice if we could modify the script so no
> > interaction is necessary.
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
Re: Karaf: Java detection on Karaf
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Markus,
you are right: I'm on Debian but not with java provided package.
On my system, I manually installed java in /opt/java and define
JAVA_HOME in /etc/profile.
It seems in your case that JAVA_HOME is not considered. Let me try to
reproduce playing with the env variables.
Regards
JB
On 05/03/2019 16:35, Markus Rathgeb wrote:
> Hi JBO,
>
>> I don't think java-config is used if you have JAVA_HOME defined right ?
>> (it's what I have on my systems).
>
> You are using Gentoo / have a readable file "/etc/gentoo-release" and
> you also did not install the system wide java support?
> What a remarkable coincidence.
>
> I wonder why it is working on your system.
> My reading of the scripts indicates the problem should exist in this
> constellation.
>
> Please have a look at the output following information:
>
>
> Here my current JAVA_HOME:
> ===
> $ echo $JAVA_HOME
> /home/rathgeb/bin/pkgs/java/jdk/8/current
> ===
>
> As you can see java is part of the PATH
> ===
> $ command -v java
> /home/rathgeb/bin/pkgs/java/jdk/8/current/bin/java
> ===
>
> The current java version is
> ===
> $ java -version
> java version "1.8.0_202"
> Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
> Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
> ===
>
> Now let's start Karaf
> ===
> $ bin/karaf
> /home/rathgeb/workspace/projects-oss/karaf/bin/apache-karaf-4.3.0-SNAPSHOT/bin/inc:
> line 198: java-config: command not found
> karaf: JAVA_HOME not set; results may vary
> karaf: Enabling Java debug options:
> -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
> Listening for transport dt_socket at address: 5005
> __ __ ____
> / //_/____ __________ _/ __/
> / ,< / __ `/ ___/ __ `/ /_
> / /| |/ /_/ / / / /_/ / __/
> /_/ |_|\__,_/_/ \__,_/_/
>
> Apache Karaf (4.3.0-SNAPSHOT)
>
> Hit '<tab>' for a list of available commands
> and '[cmd] --help' for help on a specific command.
> Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
>
> karaf@root()>
> ===
>
> You see the message
> ===
> /home/rathgeb/workspace/projects-oss/karaf/bin/apache-karaf-4.3.0-SNAPSHOT/bin/inc:
> line 198: java-config: command not found
> ===
>
> So, please have a look at:
> https://github.com/apache/karaf/blob/8c3dda1/assemblies/features/base/src/main/filtered-resources/resources/bin/inc#L187-L217
>
> ===
> if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
> JAVA_HOME=$(java-config --jre-home)
> fi
> ===
>
> If the environment JAVA is not set (AFAIK this is not a commonly used
> one) and there is a readable "/etc/gentoo-release" file, JAVA_HOME is
> set by using "java-config" -- regardless if the tool is present.
>
> The "locateJava" method is called by e.g. the init method of Karaf.
>
>
>
>> but you can define JAVA_HOME in bin/inc right ?
>
> Sure, I can modify "bin/inc" all the time I unpack the official distribution.
> But is this what you would like to tell users?
> e.g. "If you unpack the official distribution and use Gentoo without
> "java-config" present, please edit the "bin/inc" file in front of
> starting karaf."
> I don't think this is nice if we could modify the script so no
> interaction is necessary.
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Karaf: Java detection on Karaf
Posted by Markus Rathgeb <ma...@gmail.com>.
Hi JBO,
> I don't think java-config is used if you have JAVA_HOME defined right ?
> (it's what I have on my systems).
You are using Gentoo / have a readable file "/etc/gentoo-release" and
you also did not install the system wide java support?
What a remarkable coincidence.
I wonder why it is working on your system.
My reading of the scripts indicates the problem should exist in this
constellation.
Please have a look at the output following information:
Here my current JAVA_HOME:
===
$ echo $JAVA_HOME
/home/rathgeb/bin/pkgs/java/jdk/8/current
===
As you can see java is part of the PATH
===
$ command -v java
/home/rathgeb/bin/pkgs/java/jdk/8/current/bin/java
===
The current java version is
===
$ java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
===
Now let's start Karaf
===
$ bin/karaf
/home/rathgeb/workspace/projects-oss/karaf/bin/apache-karaf-4.3.0-SNAPSHOT/bin/inc:
line 198: java-config: command not found
karaf: JAVA_HOME not set; results may vary
karaf: Enabling Java debug options:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Listening for transport dt_socket at address: 5005
__ __ ____
/ //_/____ __________ _/ __/
/ ,< / __ `/ ___/ __ `/ /_
/ /| |/ /_/ / / / /_/ / __/
/_/ |_|\__,_/_/ \__,_/_/
Apache Karaf (4.3.0-SNAPSHOT)
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
karaf@root()>
===
You see the message
===
/home/rathgeb/workspace/projects-oss/karaf/bin/apache-karaf-4.3.0-SNAPSHOT/bin/inc:
line 198: java-config: command not found
===
So, please have a look at:
https://github.com/apache/karaf/blob/8c3dda1/assemblies/features/base/src/main/filtered-resources/resources/bin/inc#L187-L217
===
if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
fi
===
If the environment JAVA is not set (AFAIK this is not a commonly used
one) and there is a readable "/etc/gentoo-release" file, JAVA_HOME is
set by using "java-config" -- regardless if the tool is present.
The "locateJava" method is called by e.g. the init method of Karaf.
> but you can define JAVA_HOME in bin/inc right ?
Sure, I can modify "bin/inc" all the time I unpack the official distribution.
But is this what you would like to tell users?
e.g. "If you unpack the official distribution and use Gentoo without
"java-config" present, please edit the "bin/inc" file in front of
starting karaf."
I don't think this is nice if we could modify the script so no
interaction is necessary.
Re: Karaf: Java detection on Karaf
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Markus,
Maybe I didn't understand, but you can define JAVA_HOME in bin/inc right ?
I don't think java-config is used if you have JAVA_HOME defined right ?
(it's what I have on my systems).
Regards
JB
On 05/03/2019 13:41, Markus Rathgeb wrote:
> Hi,
>
> I recently decided to remove my system wide Java installation from my
> Gentoo machine.
> I don't need it system wide.
>
> I am the only user of that system that needs Java -- to be more
> precise I am the only user of the system at all.
>
> Additionally I switch between different Java versions and dstributions
> for testing purposes.
>
> I ensure that a java is present in a directory that is part of the
> PATH environment variable.
> Additionally I set JAVA_HOME to the desired location.
>
> All tools still work as expected.
>
> BUT: I realized that Karaf does not work as expected anymore.
>
> It is caused by the function "locateJava" in
> "./assemblies/features/base/src/main/filtered-resources/resources/bin/inc".
> If the environment JAVA is not set and the file "/etc/gentoo-release"
> is readable, JAVA_HOME is set to the output of "java-config
> --jre-home".
> "java-config" does not exist on my system at all.
> It is only present if you install global Java support on the Gentoo
> machine, so it is optional.
>
> I also wonder why JAVA_HOME is not, if it is already set?
>
> There are several options:
> * If JAVA_HOME is set, keep it as it is.
> * If JAVA / JAVA_HOME is not set /etc/gentoo-release is present AND
> java-config is executable, execute it.
> * ...
>
> WDYT?
> Why is there a requirement for "java-config" on Gentoo?
> Why is "java-config" used if I already set JAVA_HOME to a specific
> Java location?
>
> Best regards,
> Markus
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com