Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Select Home Directory for JDK because IntelliJ can't see it?

My system is Linux Mint 18.3 Cinnamon 64-bit.

I've installed IntelliJ-IDEA and Default-jdk (openjdk-8-jdk) using the software manager.

I can see what I believe to be the JDK folder under either /usr/lib/jvm/java-1.8.0-openjdk-amd64 or /etc/java-8-openjdk when browsing with the file manager (Nemo) or the terminal. But it doesn't matter because IntelliJ can't see either folder anyway. In fact, when trying to Select Home Directory for JDK, IntelliJ only seems to have visibility to 14 sub-folders (out of hundreds) under /usr/lib.

Not even sure how to launch IDEA from the command-line using sudo, e.g. to test that the issue is permission-related, since it is apparently being launched vicariously via flatpak.

Seems like this should be simple. I'm not sure what I'm doing wrong.

like image 662
Jason Avatar asked Feb 03 '19 01:02

Jason


2 Answers

As others said - sandboxing is a feature, not a bug.

I think @Kevin Dubois' answer should perhaps be preferred where applicable (installing via flatpak the thing you want to share), but there is another solution to this problem if you would like to continue using flatpak

How to find /etc and /usr paths in a flatpak:

As mentioned at the end of this section of the documentation:

  • /etc is mounted at /var/run/host/etc for the flatpakked software
  • /usr is mounted at /var/run/host/usr for the flatpakked software

If you need to find or manage other paths:

NB: It is generally a good idea to give software as little extra access as possible. That's why it is preferable to use the optional :ro suffix when granting access to a path to make it accessible in read-only. You will also be partly responsible if some software abuses the access it has to your device.

There's some useful path variables in the filesystem permissions reference and a lot of additional information about filesystem permissions here.

GUI option:

Flatseal seems pretty neat.

CLI option:

The examples below are for managing the path /var/lib/gems for the flatpak app com.jetbrains.IntelliJ-IDEA-Community.

To check current permissions:

flatpak info --show-permissions com.jetbrains.IntelliJ-IDEA-Community

To grant access:

sudo flatpak override --filesystem="/var/lib/gems":ro com.jetbrains.IntelliJ-IDEA-Community

To forbid access:

sudo flatpak override --nofilesystem="/var/lib/gems" com.jetbrains.IntelliJ-IDEA-Community

To reset permissions to initial state:

sudo flatpak override --reset com.jetbrains.IntelliJ-IDEA-Community
like image 95
Carolus Avatar answered Nov 13 '22 01:11

Carolus


The hint to the mounted directories by @Carolus worked perfectly for me: On my Linx Mint the jdk had been installed within /usr/lib/jvm/java-11-openjdk.

(found by usage of "which java" and using the result with "readlink -e ")

Selected /var/run/host/usr/lib/jvm/java-11-openjdk within the Idea addJdk dialog instead and it works! No change of flatpak permissions was required.

like image 30
Camilla Avatar answered Nov 13 '22 02:11

Camilla