47

I am trying to install IDEA on Ubuntu 11.10. First, I installed openjdk-7-jdk. Then I tried running the idea.sh file as instructed. However it complains:

ERROR: cannot start IntelliJ IDEA.
No JDK found to run IDEA. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME 
environment variable points to valid JDK installation.

Press Enter to continue.

Trying to echo these three variables prints an empty line to the screen. How (and to what values) do I set these variables and proceed with the installation? Thanks.

missingfaktor
  • 90,905
  • 62
  • 285
  • 365
  • http://askubuntu.com/questions/4667/where-to-declare-environment-variables – bbaja42 Dec 05 '11 at 08:44
  • 2
    @bbaja42: Doesn't really help. I also need to know what these variables I should set to. – missingfaktor Dec 05 '11 at 08:45
  • Well, error message is quite verbose. You have installed openjdk. Find it's installation folder, and set either of these 3 variables(IDEA_JDK, JDK_HOME or JAVA_HOME) to openjdk installation folder. – bbaja42 Dec 05 '11 at 09:00
  • @bbaja42: It really doesn't seem as straightforward as that to me. Also there is a reason I put "Noob here" in my original question. – missingfaktor Dec 05 '11 at 09:07
  • @bbaja42: See my comment below Low Flying Pelican's answer. – missingfaktor Dec 05 '11 at 09:09

10 Answers10

85

UPDATE:

It's recommended to use the bundled JetBrains Runtime on Linux to run IntelliJ IDEA. At the moment IntelliJ IDEA requires Java 8 to run on this platform. It's possible to switch to a system or some other Java version, please check the FAQ.


Original answer (obsolete):

It's recommended to use OpenJDK 1.7+ or Oracle JDK to run IntelliJ IDEA on Linux, OpenJDK 1.6 is strictly unsupported because of the known performance and visual issues.

Starting from IntelliJ IDEA 16, custom JRE is bundled with Linux distributions.

The tricky part is that Oracle JDK is no longer distributed via .deb packages and you can't just install it with apt-get or Ubuntu Software Center.

Their site is also confusing and you can easily download JRE instead of the JDK (which will not work as IntelliJ IDEA needs tools.jar that is missing from JRE package).

Here is the correct URL for the JDK downloads (version 1.6.0_29). From this URL download the appropriate .bin file, for example jdk-6u29-linux-i586.bin if you need 32-bit Java or jdk-6u29-linux-x64.bin for 64-bit version.

chmod +x jdk-6u29-linux-i586.bin
./jdk-6u29-linux-i586.bin

to install in the current directory.

Inside bin/idea.sh add the following on the second line:

export IDEA_JDK=/path/to/jdk1.6.0_29

Normally resides under /usr/lib/jvm/<YOUR_JDK>. Now IntelliJ IDEA should start fine under Oracle JDK 1.6.0_29. You can verify it in Help | About.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • I partially agree with your statement as it perfectly rational to develop with proprietary Java on a Windows based Hostas an example. Then share to an Ubuntu guest to develop with 'open' Java if needed... (ignore this if you don't use VirtualBox). – thejartender Dec 06 '11 at 09:05
  • 12
    I do not really get all that hysteric warnings about Idea on OpenJDK. I use OpenJDK and must note that all bugs that I have seen personally while running Idea on OpenJDK are perfectly reproducible on Sun JDK - I see no difference. There is also no noticeable degradation in performance (at least for projects I working on). – Petr Gladkikh Apr 27 '12 at 11:27
  • 2
    Not longer distributed on .deb files? What happened to write once run everywhere? – Jens Apr 25 '14 at 13:54
  • 3
    _8u25_ seems to be the current version but I'm not able to find the binary file anywhere – Pierre de LESPINAY Jan 02 '15 at 09:48
  • How up to date is this advice about OpenJDK not being explicitly supported? [The help article I came from](https://intellij-support.jetbrains.com/hc/en-us/articles/206827547-Selecting-the-JDK-version-the-IDE-will-run-under) seems to imply that it's now supported in some capacity under Linux. – Makoto Nov 28 '15 at 09:05
  • sadly my JAVA_HOME always seems to take precedence over IDEA_JDK - it always complains about Java 7 (which JAVA_HOME points to, for compiling a legacy project with Maven on the command line). I need different VMs for IntelliJ and the rest of my system. – Gregor Jan 28 '16 at 10:31
  • This solution works perfectly. I would like to add, for other jetbrain products the JDK variable name changes (for Pycharm for example, its name PYCHARM_JDK). – sogeking Dec 17 '18 at 10:47
3

i also face a question... in firs day all works without problems, but then... i solve a problem: add to file idea.sh line with path to JDK IDEA_JDK="/opt/java/32/jdk1.6.0_45/"

add after 46 line

qizer
  • 519
  • 2
  • 6
  • 14
3

You can set JAVA_HOME variable and add to your PATH, by doing the following. As root open up /etc/bash.bashrc and add the following to the end of the file.

JAVA_HOME=/usr/lib/jvm/java
export JAVA_HOME

When you reboot, try running the following:

$ echo $JAVA_HOME
sarnold
  • 102,305
  • 22
  • 181
  • 238
Low Flying Pelican
  • 5,974
  • 1
  • 32
  • 43
  • 1
    Note that `PATH` is completely unrelated and there is _no_ need to reboot -- just start a new shell. Setting the `JAVA_HOME` environment variable in the system-wide `/etc/bash.bashrc` is also a bit of a blunt hammer -- perhaps another user on the system might want to use a different JRE. – sarnold Dec 05 '11 at 08:45
  • I did as you sad. `echo $JAVA_HOME` works now. However trying to run `idea.sh` still fails with the same error. – missingfaktor Dec 05 '11 at 09:07
  • Is it the correct path referring to the JAVA_HOME? (where you have installed openjdk?) – Low Flying Pelican Dec 05 '11 at 09:16
  • @missingfaktor . For debugging: Could you give output of ls "$JAVA_HOME". Also, edit idea.sh and add -x at first line, which will printout result of each operation on console. Show us that output as well. – bbaja42 Dec 05 '11 at 09:23
  • @bbaja42: `echo $JAVA_HOME` prints `/usr/bin/java`. – missingfaktor Dec 05 '11 at 09:25
  • @missingfaktor OK. That means that JAVA_HOME destination is incorrect. It should point to java installation folder, I can only guess where it is installed on your machine. Have you tried pelicans try, 'usr/lib/jvm/java'* – bbaja42 Dec 05 '11 at 09:28
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/5583/discussion-between-bbaja42-and-missingfaktor) – bbaja42 Dec 05 '11 at 09:31
  • @bbaja42: Sorry for the delay, online on the chat now. – missingfaktor Dec 05 '11 at 09:38
  • 1
    @Low Flying Pelican It is NOT recommended to edit bash.bashrc according to Ubuntu help page. User is advised to edit the /etc/environment file. If they would like updated shell/terminal without restart then they can use the source command:$ source /etc/environment – thejartender Dec 09 '11 at 09:38
3

I have had this problem a few times...

  1. Add the IDEA_HOME/bin to your PATH Make sure JAVA_HOME & other variables are correct.

then run it from the terminal:

$ idea projects-name;

OR 2: navigate into the IDEA_HOME/bin and run it from there.

thejartender
  • 9,339
  • 6
  • 34
  • 51
2

If you had installed java, try:

type java

if you see like this:

java is /usr/java/default/java

then you should edit .bash_profile, add:

export JAVA_HOME=/usr/java/default

then execute:

source .bash_profile

if you did not install java, you should install manual or auto.

Saikat
  • 14,222
  • 20
  • 104
  • 125
QinL
  • 31
  • 2
  • @missingfaktor its a standard unix file which should be in your home directory and it must start with a `.` Personally I prefer to add this to `/etc/profile.d` if you have access to `root` – Peter Lawrey Dec 05 '11 at 09:24
1

Actually, you can configure the JAVA_HOME in bash. But, IDEA use javac and java from standard bin folders. So, you have to configure like this.

  • Download the JDK to home(~) folder
  • extract the zip file
  • use these command to mv to jvm folder under /usr/lib/jvm

    sudo mv -r ~/jdk-xx-version /usr/lib/jvm
    
  • use these commands to configure the JAVA_HOME

    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-xx-version/bin/java" 1 
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-xx-version/bin/javac" 1 
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk-xx-version/bin/javaws" 1
    
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Hafiz Shehbaz Ali
  • 2,566
  • 25
  • 21
1

You install JDK 8 with:

sudo apt-get install openjdk-8-jdk

Then, sometimes the problem lies on the default version of JAVA you are running. For this, use update-alternatives to modify it:

sudo update-alternatives --config java

See how I did it:

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

And now Intellij IDEA 2016.3 is running fine.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
0

This might not be the root cause for the original question, but it is the top hit when searching for this error:

ERROR: cannot start IntelliJ IDEA.
No JDK found to run IDEA. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME 
environment variable points to valid JDK installation.

Short answer: If you were upgrading IDEA and run into this error and are using JBRE (JetBrains Runtime), export your previous runtime path to JAVA_HOME to load up the latest version of IDEA and allow the import wizard to copy configs over.

  • The issue appears on my development environment when there's no default JAVA_HOME installed.
  • I updated from 2019.2 to 2019.3, which causes the latest version of IDEA to temporarily have no config files.
  • This would mean there would be no 'valid Java runtime'.

Solution

  1. Look into your previous configuration and lookup what runtime you're using:

% cat ~/.IntelliJIdea2019.2/config/idea.jdk /home/username/.IntelliJIdea2019.2/config/jdks/jbrsdk-8u232-linux-x64-b1638.3

  1. In my case above it is jbrsdk-8u232-linux-x64-b1638.3 and the path is as shown above. Export that temporarily as JAVA_HOME.

EXPORT JAVA_HOME=/home/username/.IntelliJIdea2019.2/config/jdks/jbrsdk-8u232-linux-x64-b1638.3

  1. Run idea &.

You should now have the first time run dialog show up to copy the config over, and you won't need to export the variable again.

matrixanomaly
  • 6,627
  • 2
  • 35
  • 58
0

the solution arch linux takes with intellij idea 2020 is here: https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/intellij-idea-community-edition

if [ -z "$IDEA_JDK" ] ; then
  IDEA_JDK="/usr/lib/jvm/java-11-openjdk/"
fi
# open-jfx location that should match the JDK version
if [ -z "$IDEA_JFX" ] ; then
  IDEA_JFX="/usr/lib/jvm/java-11-openjfx/"
fi
# classpath according to defined JDK/JFX
if [ -z "$IDEA_CLASSPATH" ] ; then
  IDEA_CLASSPATH="${IDEA_JDK}/lib/*:${IDEA_JFX}/lib/*"
fi

exec env IDEA_JDK="$IDEA_JDK" IDEA_CLASSPATH="$IDEA_CLASSPATH" /usr/share/idea/bin/idea.sh "$@"
soloturn
  • 958
  • 9
  • 8
0

Here is a bash script for developers that installs IDEA so that you can run it from the shell via idea.sh

It also:

  • Tests if the operating system is running on VirtualBox
  • If it runs on VirtualBox, tests if IdeaProjects is set up for sharing
  • If yes, writes a mount command to the bootstrap script to automount projects from host to guest
  • Also creates a script to mount and unmount idea projects on-the-fly

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Modify these variables as needed...
tempWork=/tmp/work
defaultStartScript=/etc/init.d/rc.local
defaultIDEA=11.0.1
locBin=/usr/local/bin

read -p "Please [Enter] full path name of your local startup script ($defaultStartScript is the default). Please
make sure on this before providing a value by consulting documentation for your system:" locStartScript
locStartScript=${locStartScript:-$defaultStartScript}

read -p "Please [Enter] IDEA Version ($defaultIDEA is default):" ideaVersion
ideaVersion=${ideaVersion:-$defaultIDEA}


if [ ! -f $locStartScript ]
then
    echo "The file you provided could not be found. Remember to include the full path and try again. Exiting in 7 secs..."
    sleep 7
    exit 1
fi

mkdir -p /$tempWork
cd /$tempWork

sudo wget http://download-ln.jetbrains.com/idea/ideaIC-$ideaVersion.tar.gz;
tar -zxvf ./*;

#Move it to a better location...
mv ./idea-IC-* $HOME/;

sudo ln -f -s $HOME/idea-*/bin/* /usr/bin/;

#If you use VirtualBox , you can share your projects between Host and guest. Name of shared
#folder must match 'IdeaProjects'
mkdir -p $HOME/IdeaProjects

if [ -f /sbin/mount.vboxsf ]
then
    sudo /sbin/umount $HOME/IdeaProjects
    sudo /sbin/mount.vboxsf IdeaProjects $HOME/IdeaProjects
fi

if mountpoint -q ~/IdeaProjects
then
#Add it to the start script to automate process...
if ! grep "sudo /sbin/mount.vboxsf IdeaProjects $HOME/IdeaProjects" $locStartScript
then
    echo "sudo /sbin/mount.vboxsf IdeaProjects $HOME/IdeaProjects" | sudo tee -a $locStartScript
fi
    sudo chmod +x $locStartScript

#Create a mount and unmount script file...
    rm -rf $tempWork/*
    echo '#!/bin/bash' > $tempWork/idea-mount.sh
    echo "sudo /sbin/mount.vboxsf IdeaProjects $HOME/IdeaProjects" >> $tempWork/idea-mount.sh
    echo "echo 'mounted IdeaProjects'" >> $tempWork/idea-mount.sh
    echo "exit 0" >> $tempWork/idea-mount.sh

    echo '#!/bin/bash' > $tempWork/idea-umount.sh
    echo "sudo umount $HOME/IdeaProjects" >> $tempWork/idea-umount.sh
    echo "echo 'unmounted IdeaProjects'" >> $tempWork/idea-mount.sh
    echo 'exit 0' >> $tempWork/idea-umount.sh

#Script for mounting ALL VirtualBox shared solders....
#If there isn't one create one...
if [ ! -f $locBin/mount-all-from-host.sh ]
then
    echo '#!/bin/bash' > $tempWork/mount-all-from-host.sh
    echo "sudo /sbin/mount.vboxsf IdeaProjects $HOME/IdeaProjects" | sudo tee -a $tempWork/mount-all-from-host.sh
    echo "exit 0" | sudo tee -a $tempWork/mount-all-from-host.sh

#Otherwise if there is one, but no mount, add one...
elif ! grep "sudo /sbin/mount.vboxsf IdeaProjects" $locBin/mount-all-from-host.sh
then
    sudo sed -ie '$d' $locBin/mount-all-from-host.sh
    echo "sudo /sbin/mount.vboxsf IdeaProjects $HOME/IdeaProjects" | sudo tee -a $locBin/mount-all-from-host.sh
    echo "exit 0" | sudo tee -a $locBin/mount-all-from-host.sh
fi

#Script for unmounting ALL VirtualBox shared folders...
#If there isn't one create one...
if [ ! -f $locBin/umount-all-from-host.sh ]
then
    echo '#!/bin/bash' > $tempWork/umount-all-from-host.sh
    echo "sudo umount -a -t vboxsf" | sudo tee -a $tempWork/umount-all-from-host.sh
    echo "echo 'unmounted all VirtualBox shared folders'" | sudo tee -a $tempWork/umount-all-from-host.sh
    echo "exit 0" | sudo tee -a $tempWork/umount-all-from-host.sh
fi

    sudo chmod +x $tempWork/*
    sudo mv -f $tempWork/*.sh $locBin/
    rm -rf $tempWork
fi

sudo rm -rf $tempWork

exit 0
thejartender
  • 9,339
  • 6
  • 34
  • 51