Jar Bar guide to Install Intellij IDEA on Linux by Yucca Nel

Intellij IDEA is the Integrated Development Environment from Jetbrains centred around Java. Linux supports many IDE editors, like IDEA. But as it is my favourite IDE, I decided to make a guide for installing it by means of a bash script.

IC:

#!/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

jar-bar-linux-install-idea-free.sh

IU:

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#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/ideaIU-$ideaVersion.tar.gz;
tar -zxvf ./*;

#Move it to a better location...
mv ./idea-IU-* $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


jar-bar-linux-install-idea-personal.sh

I continue to read users struggle to install IDEA on Linux, I wrote a script that should get this right with some additional benefits for developers using a dual development system in VirtualBox. Basically there is an error message from Intellij that does not get to the root of the problem. If you are getting IDEA_JDK or any JDK "not found" issues despite setting these variables, then this should solve them.

sh idea.sh (your project name)

Jar Bar video showing how to install Intellij IDE on Linux Ubuntu