Page 1 of 1

Setting Java_Home

PostPosted: May 25th, '25, 11:07
by laidlaws
I have a password manager and had JAVA_HOME set. Now it has gone. What I am currently using is:
Code: Select all
JAVA_HOME=/usr/lib/jvm/jre-17-openjdk-17.0.14.0.7-1.mga9.x86_64

but it doesn't work. Probably, the string is too long.

What is the correct setting?

Re: Setting Java_Home

PostPosted: May 25th, '25, 11:38
by sturmvogel

Re: Setting Java_Home

PostPosted: May 25th, '25, 13:32
by doktor5000
"doesn't work" means what in particular? Also how did you have it set previously and why is it gone all of a sudden ?

BTW: there is no real length limitation for variables/strings.

Re: Setting Java_Home

PostPosted: May 25th, '25, 17:09
by laidlaws
Thanks. "doesn't work means that the command doesnothing. Unread postby sturmvogel 's answer seems to be what I need, but I can't get a title to edit.

Re: Setting Java_Home

PostPosted: May 25th, '25, 19:19
by doktor5000
Which command? If you mean
Code: Select all
JAVA_HOME=/usr/lib/jvm/jre-17-openjdk-17.0.14.0.7-1.mga9.x86_64

then that is expected, only thing this does is setting the environment variable JAVA_HOME to /usr/lib/jvm/jre-17-openjdk-17.0.14.0.7-1.mga9.x86_64

But afterwards you also need to run your actual java application (in the same shell session where you set the environment variable),
you didn't post any error yet what that currently looks like.

Re: Setting Java_Home

PostPosted: May 28th, '25, 20:33
by laidlaws
Yes,, I am doing that. i am running the app after a shell prompt. A Windows user got his going by adding \bin at the end of the line, but in my installation, there is no such command.. About all that I have learned isthat JAVA_HOME will be the folder which contains /bin.

An earlier search said that I should use the path with "jre" instead of the one with "JDK" The result agrees with what I am doing anyway. But in a page I found today, a new user was advised to do the opposite.

Re: Setting Java_Home

PostPosted: May 29th, '25, 14:20
by doktor5000
laidlaws wrote:About all that I have learned isthat JAVA_HOME will be the folder which contains /bin.

No, it's the full path to the folder which contains the actual java binary, so including /bin.

Maybe you should stop guessing, and post some actual details what java JRE/JDKs you have currently installed. As regular user:
Code: Select all
rpm -qa|grep -iE "java|jre|jdk"|sort
update-alternatives --list java
java -version
echo $JAVA_HOME

Re: Setting Java_Home

PostPosted: May 30th, '25, 13:33
by morgano
My invoicing program need a specific java version.
My solution is a very short luncher shell script that sets folder, and calls that java to start the app:

Code: Select all
#!/bin/bash
cd ~/Tribun/Eko/FriBok
/usr/lib/jvm/java-1.8*/jre/bin/java -jar fribok-2.2*.jar
exit 0  # done

(EDIT: corrected)

Then, I have a desktop icon to call that .sh shell script.

Re: Setting Java_Home

PostPosted: May 31st, '25, 15:23
by doktor5000
Well, if you would want to set a folder as working directory, then you need to do that before running the program. Otherwise it's just useless and will only take effect after the program is closed. Also the exit 0 at the end does nothing.
BTW: there's no need for a shell script for that, you can simply add a launcher for that via the means of your desktop environment that does the same, and can have a nice icon.

But that's all a bit offtopic.

Re: Setting Java_Home

PostPosted: Jun 1st, '25, 18:40
by morgano
doktor5000 wrote:Well, if you would want to set a folder as working directory, then you need to do that before running the program.

:oops: right, copy paste mishap from longer script...

Re: Setting Java_Home

PostPosted: Jul 11th, '25, 01:25
by laidlaws
I haven't been following this thread, and a lot seems to have happened. All that I have discovered so far is that the expansion of JAVA_HOME should finish just before " /bin." so that the executable becomes the equivalent executable is $JAVA_HOME/bin. According to the Web references, I should stop JAVA_HOME at "-jdk.",
but it doesn't seem to work.

Ubuntu talks about a file called "environment." I didn't think that Mageia had one, but it does exist, but is used for setup.

Re: Setting Java_Home

PostPosted: Jul 11th, '25, 16:31
by doktor5000
laidlaws wrote:but it doesn't seem to work.

doesn't work means what exactly? You didn't post what exactly you set JAVA_HOME to and what error message you get when trying to start your program.


doktor5000 wrote:Maybe you should stop guessing, and post some actual details what java JRE/JDKs you have currently installed. As regular user:
Code: Select all
rpm -qa|grep -iE "java|jre|jdk"|sort
update-alternatives --list java
java -version
echo $JAVA_HOME