Home > Software design >  Why I couldn't run same installed app on IDE integrated terminal even I could run on default te
Why I couldn't run same installed app on IDE integrated terminal even I could run on default te

Time:06-28

I just switch to try develop on Linux for a while.

But one thing I couldn't understand how to solve it, as I mentioned in topic.

I'm going to develop a project that need Java SDK, then I installed the SDK with command:

#bash
sudo apt install openjdk-17-jdk-headless

After installation finished, I could run command java -version and javac -version to see the result of installation and it looks OK.

openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3 7-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 17.0.3 7-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)

And then when I open IDE (Intellij IDEA) and it has feature of integrated terminal. (see picture)

But when I try to test java -version it was shown the error:

bash: java: command not found

As you can see from picture, I run java -version on terminal it return output properly, but when I run the same command java -version, it output with error message, like it couldn't find the java SDK that I installed.

Could anyone help me to describe the reason and solutions to solve the issue?

P.S. This is same on VS Codium.

java command not found on integrated terminal

CodePudding user response:

I found the answer.

Solution:

Install the IDE app with the file from official website instead of using package manager of OS.

Description:

The cause is I installed the IDE via Package Manager of OS (here I'm using Pop_OS, install via Pop!_Shop)

And its package manager has some strict rules for security purpose. I'm not sure, Pop_OS using which package manager, but I'll raise Flatpak as reference: https://docs.flatpak.org/en/latest/sandbox-permissions.html

And on blacklisted directories, my installed java command is under /usr/bin/ which is in blacklist.

CodePudding user response:

See step 6 in the intelliJ help. You need to configure intelliJ with the path to the SDK you installed. From the documentation:

To develop Java applications in IntelliJ IDEA, you need the Java SDK (JDK).

If the necessary JDK is already defined in IntelliJ IDEA, select it from the JDK list.

If the JDK is installed on your computer, but not defined in the IDE, select Add JDK and specify the path to the JDK home directory (for example, /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk).

  • Related