**Contents** [[!toc levels=2]] # Introduction Netbeans, along with Eclipse, is one of the most widely used Java IDE (Integrated Development Environment), also capable of Ruby and C/C++ development. The purpose of this document is to describe the steps needed to run Netbeans 6.0 on a NetBSD system, using Linux Java Virtual Machine and Linux compatibility mode. # Downloading Netbeans The latest version of Netbeans may be downloaded from [here](http://www.netbeans.info/downloads/index.php). We will be using version 6. After having downloaded file _netbeans-6.0.zip_, we compare the SHA256 sums to ensure data integrity: $ digest sha256 netbeans-6.0.zip SHA256 (netbeans-6.0.zip) = fc80d6fd507c5bcc647db564fc99518542b9122d7ea6fcf90abb08156a26d549 **XXX: This is from the NetBeans DVD, check if the downloadable version is the same.** which is equal to the one mentioned in the download page. Next we extract the compressed archive: $ unzip netbeans-6.0.zip inflating (...) $ ls -ld netbeans drwxr-xr-x 11 user users 1024 Dec 23 16:55 netbeans/ # Verifying Linux compatibility mode ## Kernel support Since we are going to install a Linux binary JVM, we must also enable Linux compatibility mode in our system. If you are using a [GENERIC kernel](http://netbsd.org/Documentation/kernel/#generic_kernel), you are already done since the Linux compatibility layer is enabled by default. If not, you will need to compile your kernel with the following options: options COMPAT_LINUX In case you are unfamiliar with the process of building a custom kernel, please refer to [NetBSD Documentation](http://www.netbsd.org/guide/en/chap-kernel.html). A quick way to check whether you are ok as far as kernel support is concerned, is to invoke the following command: $ config -x | grep COMPAT_LINUX options COMPAT_LINUX # binary compatibility with Linux (Configuration data will be available if the given kernel was compiled with either INCLUDE_CONFIG_FILE or INCLUDE_JUST_CONFIG options.) Alternatively you can search across the [Sysctl](http://en.wikipedia.org/wiki/Sysctl) tree: $ sysctl -a | grep emul emul.linux.kern.ostype = Linux emul.linux.kern.osrelease = 2.4.18 emul.linux.kern.osversion = #0 Wed Feb 20 20:00:02 CET 2002 Note that the NetBSD documentation covers extensively this [topic](http://www.netbsd.org/guide/en/chap-linux.html), so if you run into trouble, please consult the respective pages. ## Linux shared libraries Most of the times, applications are linked against shared libraries, and for Linux applications, Linux shared libraries are needed. You could get the shared libraries from any Linux distribution theoretically, as long as they are not too outdated, but the suggested method is to use the pkgsrc system. This package supports running [ELF binaries](http://en.wikipedia.org/wiki/Executable_and_Linkable_Format) linked with glibc2 which don't require X11 shared libraries. # cd /usr/pkgsrc/emulators/suse100_base/ # make install clean This package contains some old shared libraries required for backwards compatibility. # cd /usr/pkgsrc/emulators/suse100_compat/ # make install clean This package supports running ELF binaries linked with glibc2 which require X11 shared libraries. # cd /usr/pkgsrc/emulators/suse100_x11/ # make install clean # Installing Sun's JDK NetBeans IDE 6.0 requires a Java SE JDK, version 5 or 6. lang/jdk6 unfrotunately fails to run NetBeans with segmentation fault errors, so we will use lang/jdk15. Next we modify the make configuration file `/etc/mk.conf` and add `ACCEPTABLE_LICENSES+=jdk13-license`, to accept the jdk license. You can do that with the following command: # echo "ACCEPTABLE_LICENSES+=jdk13-license" >> /etc/mk.conf We will manually download the Linux self-extracting jdk file `jdk-1_5_0_12-linux-i586.bin` from [here](http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=jdk-1.5.0_12-oth-JPR&SiteId=JSC&TransactionId=noreg), and put it in `/usr/pkgsrc/distfiles`. But since jdk15 depends on jre15, we have to download the Linux self-extracting jre file `jre-1_5_0_11-linux-i586.bin` from [here](http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=jre-1.5.0_12-oth-JPR&SiteId=JSC&TransactionId=noreg) and put it in `/usr/pkgsrc/distfiles` aswell. $ ls -l *.bin -rwxr-xr-x 1 user wheel 49622107 Dec 23 15:44 jdk-1_5_0_12-linux-i586.bin* -rwxr-xr-x 1 user wheel 17138633 Dec 23 15:18 jre-1_5_0_12-linux-i586.bin* Now we are ready to install jdk: # cd /usr/pkgsrc/lang/sun-jdk15/ # make install clean ## /proc filesystem Some Linux programs like Netbeans rely on a Linux-like /proc filesystem. The NetBSD procfs filesystem can emulate a /proc filesystem that contains Linux-specific pseudo-files. We now manually mount the proc file system. # mount_procfs -o linux procfs /usr/pkg/emul/linux/proc and verify it with: # mount /dev/wd0g on / type lfs (local) ptyfs on /dev/pts type ptyfs (local) tmpfs on /tmp type tmpfs (local) procfs on /usr/pkg/emul/linux/proc type procfs (local) You may have NetBSD mounted it automatically during the booting process, by modifying the /etc/fstab file by adding the following line: procfs /usr/pkg/emul/linux/proc procfs rw,linux Please be careful with your `/etc/fstab`. Wrong entries may lead to an unbootable system. ## Data segment size In `usr/pkgsrc/lang/sun-jdk15/MESSAGE.NetBSD` it is stated that "The maximum data segment size assigned to your user must be at least 262144". It is known, that this value isn't enough. Thus enter: $ ulimit -d 400000 You may want to put this into your `.profile` In case you encounter runtime errors of the following form: [stathis@netbsd ~] ./netbeans/bin/netbeans --jdkhome /usr/pkg/java/sun-1.5 Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. [stathis@netbsd ~] try increasing the data segment size. # Running Netbeans You may now run Netbeans, by typing: [stathis@netbsd ~] ./netbeans/bin/netbeans --jdkhome /usr/pkg/java/sun-1.5 Note that you can edit `netbeans/etc/netbeans.conf` and add the following line: netbeans_jdkhome="/usr/pkg/java/sun-1.5" so you won't have to explicitly set the location of J2SE JDK everytime you run Netbeans.