Jar Bar Guide to install NetBeans IDE on Linux by Yucca Nel

NetBeans is the Integrated Development Environment from Sun/Oracle. And is a very stable IDE for not just Java, but many other languages. NetBeans free and is one of the best documented IDEs out there, with an abundance of tutorials that focus on the Netbeans IDE. NetBeans has stable community that continue to improve it's worth and the IDE backed by numerous "Companion Projects" as are demonstrated by the Netbeans home page.

NetBeans is free

When I am not using IDEA, I turn to NetBeans mostly because I know it supports both JEE and SE versions and it can handle any Maven project from IDEA easily. I personally switch to NetBeans at times when my yearly IDEA license expires.

You need Java to Install NetBeans

NetBeans like a lot of other 'Java' IDEs, is built on Java and therefore Java is needed to run it. I included a command in the shell script to share projects from an IDEA on Windows to a VirtualBox Unix guest. This has it's own benefits. Developers can choose to develop on Oracles closed JDK on Windows and switch to an 'Open' JDK version on Unix if needed. For more info, see the "Sharing Files", "Guest Additions" and other related tutorials in the "Links section below. Adding Maven to your development environment will make your Java projects able yo be used by NetBeans and almost any modern IDE. Look at the other tutorials here from The jar Bar if you need help...

What my NetBeans script does

This tutorial provides an updated methodology to get the NetBeans installed in a way that it can be run with the "netbeans" command from the Linux terminal. Java is a requirement and must be installed for NetBeans to work. The bash script I created downloads and unpacks NetBeans and symbolically links the 'bin' contents to the Linux '/usr/bin' location which is by default added to the PATH.

Download the Jar Bar NetBeans install script

You can view the bash script I created below, copy it, download it by the link below or by clicking on the script. You can also modify them accordingly to reflect newer versions. The script Prompts you for the version of NetBeans you wish to download. Downloads it and installs it.

NetBeans for the VirtualBox Developer

If and only if you have set up NetBeansProjects to be shared from your host to a Linux guest, the script will prompt you for a file to write a mount command that is found at boot time. This will automate the process for you and additional Bash scripts are created in '/usr/local/bin' to allow you to mount and un-mount your projects if needed with either the bash netbeans-mount.sh or bash netbeans-umount.sh commands.

#!/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
defaultNetBeansVer=7.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] NetBeans Version ($defaultNetBeansVer is default):" netbeansVersion
netbeansVersion=${netbeansVersion:-$defaultNetBeansVer}

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;

wget http://dlc.sun.com.edgesuite.net/netbeans/$netbeansVersion/final/bundles/netbeans-$netbeansVersion-ml-javase-linux.sh
sh $tempWork/*sh;

#Add Netbeans launcher to your PATH. Doing so allows you to run 'netbeans' command from the terminal
#This line will need to be changed if you changed the default install location (IOW Netbeans is not in ~/)
sudo ln -f -s ~/netbeans-7.1/bin/netbeans /usr/bin/;

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

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

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

sudo chmod +x $locStartScript

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

echo '#!/bin/bash' > $tempWork/netbeans-umount.sh
echo "sudo umount $HOME/NetBeansProjects" >> $tempWork/netbeans-umount.sh
echo "echo 'unmounted NetBeansProjects'" >> $tempWork/netbeans-mount.sh
echo 'exit 0' >> $tempWork/netbeans-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 NetBeansProjects $HOME/NetBeansProjects" | 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 NetBeansProjects" $locBin/mount-all-from-host.sh
then
sudo sed -ie '$d' $locBin/mount-all-from-host.sh
echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects" | 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
sudo /sbin/reboot

exit 0

jar-bar-linux-install-netbeans.sh

To run NetBeans

Run the netbeans command in your Linux terminal


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