Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The JAVA situation #3215

Open
Aqua1ung opened this issue Nov 30, 2024 · 15 comments
Open

The JAVA situation #3215

Aqua1ung opened this issue Nov 30, 2024 · 15 comments
Assignees
Labels

Comments

@Aqua1ung
Copy link

I installed the java-basic bundle, yet all my Java-based applications complain that they cannot find any Java installed on my system. What am I doing wrong??

Does installing this bundle requires further (so far undocumented) steps in order to make Java work on one's system? Is this bundle not self-contained?

Interestingly, whereis java returns java: /usr/bin/java, which does not seem to be a symlink. Furthermore, java -version also complains that the java command cannot be found, as there's no JAVA_HOME variable set. Doing some further digging reveals a Java installation ... of sorts in /usr/lib/jvm/java-1.19.0.

Anyone care to disentangle this mystery? What do we have to do to get an honest-to-goodness Java installation on our CL systems?

@K1ngfish3r
Copy link

K1ngfish3r commented Nov 30, 2024

Probably installing the java-basic bundle should export JAVA_HOME env variable.
Considering that CL is stateless, we can't add files to the user dir, but I see that default configs go to /usr/share/defaults/etc/. Perhaps something can be appended here?
Either that, or a message in swupd that tells us to export the env variable?

@Aqua1ung
Copy link
Author

Probably installing the java-basic bundle should export JAVA_HOME env variable.

And, more importantly, what value should the JAVA_HOME env variable have? Where is Java installed after all? Should it be /usr/bin/java, or /usr/lib/jvm/java-1.19.0/bin/java?

@K1ngfish3r
Copy link

K1ngfish3r commented Nov 30, 2024

JAVA_HOME doesn't lead directly to the Java binary, so it's /usr/lib/jvm/java-1.19.0 as per your previous post (which is what I use in my config)

@Aqua1ung
Copy link
Author

JAVA_HOME doesn't lead directly to the Java binary, so it's /usr/lib/jvm/java-1.19.0 as per your previous post (which is what I use in my config)

Thanks. Nevertheless, what's with this /usr/bin/java binary? Who put it there? Does the java-basic bundle dump that in there, or is that file the result of some rogue installer? (Note that in the same /usr/bin/ directory there's a whole host of java-related symlinks such as javac and the like that point to the /usr/bin/java binary, so it doesn't look to be some accident.)

@K1ngfish3r
Copy link

K1ngfish3r commented Nov 30, 2024

/usr/bin/java is the executable (EDIT: I went down a rabbit hole https://github.com/clearlinux-pkgs/usrbinjava/blob/main/usrbinjava.spec)
the folder /usr/bin is available in the PATH so apps can use it globally
you can use it like so

i@clr~ $ java --version
openjdk 19.0.2-internal 2023-01-17
OpenJDK Runtime Environment (build 19.0.2-internal-adhoc.mockbuild.corretto-19-19.0.2.7.1)
OpenJDK 64-Bit Server VM (build 19.0.2-internal-adhoc.mockbuild.buildavx2, mixed mode)

Some apps need more than just the java binary so they want the entire JDK through the JAVA_HOME env variable. I use it with gradle for building android apps, (and for the occasional .jar file)

extra info: in windows, you dont get a java.exe, however you do get a javac.exe. I believe thats the same behaviour you're seeing here. where /usr/bin/java points to the javac binary

@Aqua1ung
Copy link
Author

Aqua1ung commented Dec 1, 2024

I believe thats the same behaviour you're seeing here. where /usr/bin/java points to the javac binary

Actually here it's the other way around: it's javac that points to /usr/bin/java.

Anyway, thanks for investigating things. Let me attempt to draw the line on the "no multiple Javas" scenario:

  1. installing the java-basic bundle should be followed by:
  2. the adding of the following lines to the .bashrc file:
export JAVA_HOME=/usr/lib/jvm/java-1.19.0
export PATH=$JAVA_HOME/bin:$PATH

Is that it? Is that all?

@K1ngfish3r
Copy link

exporting the JAVA_HOME/bin path on the PATH is something I never had to do. Apps pick up java pretty well with just /usr/bin/java and for the rest, manipulating JAVA_HOME was enough. Such as when I was building Lineage from source and it complained when it had detected my Java 19 install (Java 11 still gets updates, who knew)

In short, export JAVA_HOME=/usr/lib/jvm/java-1.19.0 is all that is needed.
In CL, I'm hoping this can be provided, with the option of being able to override it later in the /etc/ folder or something like the other config stuff

@fenrus75
Copy link
Contributor

fenrus75 commented Dec 1, 2024 via email

@ephut ephut removed the new label Dec 5, 2024
@bryteise
Copy link
Member

I retired our /usr/bin/java and put in some setting for our profile but also updated Java.

@Aqua1ung
Copy link
Author

I retired our /usr/bin/java and put in some setting for our profile but also updated Java.

What release will that show up in?

@K1ngfish3r
Copy link

K1ngfish3r commented Dec 20, 2024

What release will that show up in?

clearlinux-pkgs/filesystem@b38fb07

it's out in 42800 i believe
EDIT: https://download.clearlinux.org/releases/42800/clear/RELEASENOTES

@schiele
Copy link

schiele commented Jan 24, 2025

Since this does break other code can you please verify whether your problem is also resolved with the alternative setting for JAVA_HOME I proposed in #3250?

@Aqua1ung
Copy link
Author

Aqua1ung commented Feb 9, 2025

I am guessing this has been fixed in 42960?

@schiele
Copy link

schiele commented Feb 10, 2025

I am guessing this has been fixed in 42960?

As @K1ngfish3r pointed out it was already fixed with 42800 but as I pointed out in #3250 and the comment above this fix is incorrect since it breaks other Java software. Therefore it would be great if you would try whether the alternative fix as proposed in #3250 does also solve your issue.

@Aqua1ung
Copy link
Author

Aqua1ung commented Feb 10, 2025

As @K1ngfish3r pointed out it was already fixed with 42800 but as I pointed out in #3250 and the comment above[,] this fix is incorrect since it breaks other Java software.

If it breaks something else (whatever that may be), then it has not been fixed.

Therefore it would be great if you would try whether the alternative fix as proposed in #3250 does also solve your issue.

I would rather wait until the devs themselves fix it. So far, there's no skin off my back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants