How-To Session: Installing Netbeans with JRE and JDK
Warning: Do NOT follow this guide if the default installation of NetBeans works for you, this is meant as a guide if NetBeans will not work due to conflicting packages such as JRE (java runtime enviroment) and JDK (java development kit)
I currently use Arch Linux as my main GNU\Linux distribution. That said this may apply only to Arch Linux, but I feel it applies to all distros, as I have tested it on others as well. By default, the installation of NetBeans will fail to start for many due to the fact it cannot find Java and tells you to: “Cannot find java. Please use the –jdkhome switch.” Of course this is ludacris, so I search forums and returned the following useful pages:
With the first link, I found that at least under Arch, that directory DOES NOT exist. The config file is actually located in “/usr/share/netbeans/bin/netbeans/etc/netbeans.conf” That was error number one. Error number two was Sun telling you to “unmark netbeans_jdkhome” and to ” link to JDK location e.g. /usr/local/share/java/jdk1.6.0_07/” in that “netbeans.conf” file. WRONG again (again, at least for Arch Linux). This could be fixed via the second link provided above, running “netbeans – -jdkpath /opt/java/jre” but for most users, they do not want to type this EVERY time then run netbeans right?
To fix this after netbeans is installed, ensure you have both “jre” and “jdk” installed on your respective distribution. After that follow these steps:
- open up Terminal
- cd to “/usr/share/netbeans/etc”
- type “nano netbeans.conf” or “vim netbeans.conf”
- Unlike what SUN told you, instead or editing the “netbeans_jdkhome” line, go to the line that reads “command line switches”
- Append the option like so “–jdkpath /opt/java/jre” to the END of the “netbeans_default_options=” block. You MUST leave a space after the previous option as such: “PREVIOUS-OPTION –jdkpath /opt/java/jre”
- save the file and exit Terminal
- Note: infront of “jdkpath those are (2) “dashes” HTML just likes to make them appear as one line, but they are in fact – –
You now should be able to start Net Beans in Terminal by doing “netbeans” or via the GUI in you applications menu. Thats it! Enjoy!