What am I doing wrong (java jdk install)?

Not an experienced Linux user. Just come over from Fedora.

Wanted to get java up and running on OM so I can continue doing some tutorials (Swing & JavaFX) I’d been working on back in F43.

Install command:
sudo dnf install java-24-openjdk-devel

Says it installed fine.

But when I check it by running
java -version
java --version

javac -version
javac --version

All I keep getting is
java: command not found
javac: command not found

What steps am I missing? What step did I not do that it needs in order to get the java compiler up and running on OM?

Thanks!

Just a reminder:
https://forum.openmandriva.org/t/support-template-in-details/7989/3

Now I’ll assume you did the obvious and rebooted …

also

dnf list installed | grep

:backhand_index_pointing_up:

I use that so often I made it an alias. So in your case:

dnf list installed | grep java

what does it report?

The package you actually want to install is jdk-current. That keeps moving from 24 to 25 to 26 ….. whenever something new is released.

Then, since various versions of the jdk must remain available in the tree (if nothing else, then for bootstrapping – can’t build 25 without 24 being there already), the jdks are installed in their own directory structure rather than the usual /usr/bin etc.

So you need to set PATH to find the one you want. jdk-current makes that easy for you by dropping a file in /etc/profile.d/90java.sh that gets run when you start a new shell (so close and reopen your terminal after installing the package).

If for some reason you don’t want to use jdk-current, do the equivalent of what 90java.sh does:

export JAVA_HOME=/usr/lib/jvm/java-PUTTHEVERSIONNUMBERHERE-openjdk
export PATH=$PATH:$JAVA_HOME/bin
3 Likes

Didn’t know that. Thanks Bero.

0 - did a search for jdk install
1 - Running on hardware / no virtual machines.
2 - KDE Plasma on X11

cat /etc/release
OpenMandriva Lx release 6.0 (Vanadium) Rock for x86_64

inxi -F
System:
Host: Motorpool Kernel: 6.14.2-desktop-3omv2590 arch: x86_64 bits: 64
Desktop: KDE Plasma v: 6.3.4 Distro: OpenMandriva Lx 6.0 Vanadium
Machine:
Type: Convertible System: LENOVO product: 82R8 v: IdeaPad Flex 5 16IAU7
serial:
Mobo: LENOVO model: LNVNB161216 v: SDK0T76463 WIN
serial: UEFI: LENOVO v: J7CN51WW date: 10/04/2024
Battery:
ID-1: BAT0 charge: 50.9 Wh (97.9%) condition: 52.0/52.5 Wh (99.0%)
CPU:
Info: 10-core (2-mt/8-st) model: 12th Gen Intel Core i7-1255U bits: 64
type: MST AMCP cache: L2: 6.5 MiB
Speed (MHz): avg: 400 min/max: 400/4700:3500 cores: 1: 400 2: 400 3: 400
4: 400 5: 400 6: 400 7: 400 8: 400 9: 400 10: 400 11: 400 12: 400
Graphics:
Device-1: Intel Alder Lake-UP3 GT2 [Iris Xe Graphics] driver: i915 v: kernel
Device-2: Chicony Integrated Camera driver: uvcvideo type: USB
Display: x11 server: X. org v: 1.21.1.18 driver: X: loaded: modesetting
unloaded: fbdev,vesa dri: iris gpu: i915 resolution: 1: 2560x1080~60Hz
2: 1920x1200~60Hz
API: EGL v: 1.5 drivers: iris,swrast platforms: gbm,x11,surfaceless,device
API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 25.0.7
renderer: Mesa Intel Iris Xe Graphics (ADL GT2)
API: Vulkan v: 1.4.312 drivers: N/A surfaces: xcb,xlib
Info: Tools: api: clinfo, eglinfo, glxinfo, vulkaninfo de: kscreen-console
x11: xdpyinfo, xprop, xrandr
Audio:
Device-1: Intel Alder Lake PCH-P High Definition Audio
driver: sof-audio-pci-intel-tgl
API: ALSA v: k6.14.2-desktop-3omv2590 status: kernel-api
Server-1: PipeWire v: 1.4.4 status: active
Network:
Device-1: Realtek RTL8852BE PCIe 802.11ax Wireless Network
driver: rtw89_8852be
IF: wlp45s0 state: down mac: f6:c9:fe:98:7c:1c
Device-2: Realtek RTL8153 Gigabit Ethernet Adapter driver: r8152 type: USB
IF: enp0s13f0u1u4 state: up speed: 1000 Mbps duplex: full
mac: 00:e0:4c:68:97:5e
Bluetooth:
Device-1: Realtek Bluetooth Radio driver: btusb type: USB
Report: hciconfig ID: hci0 rfk-id: 0 state: down
bt-service: enabled,running rfk-block: hardware: no software: yes
address: D0:39:57:50:26:E0
Drives:
Local Storage: total: 476.94 GiB used: 82.42 GiB (17.3%)
ID-1: /dev/nvme0n1 vendor: Samsung model: MZAL4512HBLU-00BL2
size: 476.94 GiB
Partition:
ID-1: / size: 468.09 GiB used: 82.41 GiB (17.6%) fs: ext4
dev: /dev/nvme0n1p2
ID-2: /boot/efi size: 299.4 MiB used: 9.2 MiB (3.1%) fs: vfat
dev: /dev/nvme0n1p1
Swap:
ID-1: swap-1 type: file size: 512 MiB used: 0 KiB (0.0%) file: /swapfile
ID-2: swap-2 type: zram size: 3.67 GiB used: 0 KiB (0.0%) dev: /dev/zram0
Sensors:
Src: /sys System Temperatures: cpu: 33.0 C mobo: N/A
Fan Speeds (rpm): N/A
Info:
Memory: total: 8 GiB note: est. available: 7.34 GiB used: 2.31 GiB (31.4%)
Processes: 271 Uptime: 8m Shell: Bash inxi: 3.3.37

ok…(monkey with calcuator) …..so is that:
sudo dnf install open-jdk-current
sudo dnf install open-jdk-current-devel
or just
sudo dnf install open-jdk

I gained a minimal about of familiarity in setting path’s in F42 and would not call myself knowledgeable on it.

Do I set the path in .bashrc or .bash_profile ?

I’m thinking it’s .bashrc since that’s not supposed to be the one-time log-in shells, but want to verify before I go monkeying around with it - already figured out you can get yourself in hot water pretty quick if you don’t know what you’re doing in those two files.

Btw, thanks for the help!

Based on @bero’s post:

I would first try

sudo dnf install jdk-current

And if that doesn’t work :wink: then

sudo dnf install open-jdk-current

Welcome to the world of programming :grin: where 50% of your time is spent looking up how to do something, 50% is experimenting to get it to work, and the next 50% is spent looking for the semi-colon you put in the wrong place…

As for path, it looks like the installer should handle that for you. You would only need to add that if you install a specific version other than the current.

Next post will be on Path

Setting up your path:

To see what your Path actually is use:

echo $PATH

I set that as an alias:

alias path="echo $PATH"

The $Path is actually set in multiple places. And if you just set the path:

export PATH=foo

that will actually completely replace the current path with “foo”. So you need to add the old path onto the new path:

export PATH=$PATH:foo

That puts foo on the end; meaning that a program located in foo will be found after the system has gone through the entire rest of the Path. If you want your program (located in foo) to be found first then:

export PATH=foo:$PATH

So order is important.

Where to put it?

System-wide the Path is set in a bunch of files located in /etc and it’s subs. As a general rule, you will never need to mess with those. That is the base Path you will be adding to whatever you do.

The 2 files you’ll be working with will be

~/.bash_profile
~/.bashrc

Bash_Profile is only read once - when you log in. So anything set there is set until you log out and log in again.

Bashrc is read every time you open a terminal window. So you could have multiple terminal windows open, each loading a different bashrc.

With that in mind, you would generally set your Path and other environment variables in Bash_Profile (~/.bash_profile). Then you can muck around in your terminal of choice as much as you want.

So here as an example is my current .bash_profile:

# .bash_profile

# User specific environment and startup programs

AppImages=$HOME"/Apps/AppImages"
Scripts=$HOME"/Apps/Scripts"

#Needed for HUGO
#------------------------
Golang="/usr/local/go/bin"
DartSaSS=$HOME"/.local/bin/dart-sass"

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes Go programming Language
if [ -d "$Golang" ] ; then
    PATH="$Golang:$PATH"
fi

# set PATH so it includes Dart-Sass
if [ -d "$DartSaSS" ] ; then
    PATH="$DartSaSS:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

# set PATH so it includes user's AppImages if it exists
if [ -d "$AppImages" ] ; then
    PATH="$AppImages:$PATH"
fi

# set PATH so it includes user's Scripts if it exists
if [ -d "$Scripts" ] ; then
    PATH="$Scripts:$PATH"
fi

export PATH

Not the prettiest, but it works. If you’ll notice, I set up variables (!) for each entry I wanted to add to my path. Which makes it real easy to change things around if I want to reorganize (not saying I’m OCD + chaos or anything…)

This is also why (when you asked about programming in the other thread) I said to learn bash. Because .bashrc, .bash_profile, .bash_aliases are all just bash scripts.

Which means when you load them into an editor like nano, kwrite, kate, micro, etc you’ll get syntax highlighting.

Does this help?

System-wide (for all users) it’s set in a bunch of files in /etc.

dnf list installed | grep java
java-21-openjdk.x86_64 21.0.5.4-1 @rock-x86_64
java-21-openjdk-devel.x86_64 21.0.5.4-1 @rock-x86_64
java-24-openjdk.x86_64 24.0.0.12-1 @rock-x86_64
java-24-openjdk-devel.x86_64 24.0.0.12-1 @rock-x86_64
rpm-javamacros.noarch 1.0-5 @rock-x86_64

The J24 stuff was already installed when I did the dnf install jdf-current. It added the J21 stuff from that command.

Total download size: 70 M
Installed size: 223 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): rpm-javamacros-1.0-5-omv4090.noarch.rpm
12 kB/s | 7.5 kB 00:00
(2/3): java-21-openjdk-devel-21.0.5.4-1-omv2490.x86_64.rpm
1.9 MB/s | 1.2 MB 00:00
(3/3): java-21-openjdk-21.0.5.4-1-omv2490.x86_64.rpm
21 MB/s | 69 MB 00:03

However, even after that it still doesn’t seem to know it’s on there. I’m thinking maybe I need to set a path so it can be used from anywhere. Or do I need to tell it which version to use by default?

Still getting:

java --version
java: command not found

javac --version
No command 'javac' found, did you mean:
Command 'javacc' from package 'javacc3' (contrib)

Found fastfetch. Don’t know if this is helpful or not, but here it is: (culled out the ANSI image.

OS: OpenMandriva Lx 6.0 (Vanadium) Rock x86_64
Host: 82R8 (IdeaPad Flex 5 16IAU7)
Kernel: Linux 6.14.2-desktop-3omv2590
Uptime: 1 hour, 38 mins
Packages: 2827 (rpm)
Shell: bash 5.2.37
Display (BOE0A31): 1920x1200 @ 60 Hz in 16" [Built-in] *
Display (Q2963): 2560x1080 @ 60 Hz in 29" [External]
DE: KDE Plasma 6.3.4
WM: KWin (X11)
WM Theme: Breeze
Theme: Breeze (Light) [Qt], Breeze [GTK2/3]
Icons: breeze [Qt], breeze [GTK2/3/4]
Font: Noto Sans (10pt) [Qt], Noto Sans (10pt) [GTK2/3/4]
Cursor: Breeze_Light (24px)
Terminal: konsole 25.4.0
Terminal Font: Liberation Mono (11pt)
CPU: 12th Gen Intel(R) Core™ i7-1255U (12) @ 4.70 GHz
GPU: Intel Iris Xe Graphics @ 1.25 GHz [Integrated]
Memory: 2.60 GiB / 7.34 GiB (35%)
Swap: 0 B / 4.17 GiB (0%)
Disk (/): 82.96 GiB / 468.09 GiB (18%) - ext4
Battery (L21M3PE1): 96% [AC Connected]
Locale: en_US.UTF-8

So yeah, the CPU might have enough horsepower to do some light work, but the iGPU may as well be a peddle bike with a busted chain.

Merry Christmas. :christmas_tree:

First off, don’t knock that little gpu. It can do more than you think…:grin: What you may need to do is go into the bios and let it access more of your ram (if your bios is set up that way). And I emphasize “may”.

Now the first thing I would do is remove all the java stuff. Completely. Then reboot.

Once it’s all cleaned out, then I would follow the post from @bero up above to just install the “current version”.

On Rock, java21 is the correct “current version”.

So by default

sudo dnf install jdk-current

will bring in 21

give that a shot

1 Like

That worked! Removed both, reinstall current. java & javac now work.

Going back through my Swing projects to make sure they all work.

@bero & @SomeDudeInAZ thank you for the help!

1 Like

Awesome. I think there is a way to mark something as solved and which post solved it. If you would be so kind as to do that to help some future seeker find what they’re looking for we’d appreciate it.

1 Like