Saturday 22 March 2008

Portable NetBeans

The hype of portability is still fresh and as the pile of available applications grows bigger and bigger providing you with a digital personality on an USB disk just in your pocket, a question arises:
"If I can carry anywhere my own browser, my office suite and my data, is it possible to make my flash drive a development environment?"
Of course you can. It is extremely easy. There are some limitations, mostly concerning performance (the transfer speed of a flash memory sometimes is an issue) or system privileges on public computers, but such obstacles are negligible.


In case your favorite development tool is NetBeans and you still haven't figured out how to put it on your portable disk, read on. For the environment will be needed at least 1 GB big drive for a standard installation. Two downloads are required - the latest JDK and the latest NetBeans IDE.

1. Prepare the environment
There are two ways to make the standard Java Development Kit from SUN Microsystems (the latest version as of the time of writing is JDK 1.6.0 Update 3) available from the portable device - to copy it from installation directory or to make a fresh install. Both cases are equally easy:
  • Copying the JDK folder (usually stored on C:\Program Files\Java\ in Windows) somewhere on the USB file system takes only minute or two. Of course, if there are defined some system variables (such as JAVA_HOME, JRE_HOME, etc.) they won't be useful anymore (on other PC).
  • Installing the development kit from scratch is a good decision. Just point the installer a path on your USB ('X:\tools\' for example).
All additional packages you might use (JavaDB, SwingX, etc.) can be installed the same way.

2. The IDE
The latest stable version of NetBeans is 6.0.1 and there is a Beta 1 version available for testing of the newest release 6.1. We'll point out some of the cool new features of the IDE a bit later. As for the installation - there is no difference which version you choose. From version 6 NetBeans has very nice and comfortable new installer. Customizing what to have in the IDE is a matter of personal choice and needs. If you bought a fast drive with good access speed, then you might try to install even the application server (Glassfish) an run it from the USB (with the quite bearable maximum of 480 Mbit/s for the hi-speed mode of the 2.0 standard). That would be quite an adventure on a bit older architecture - the 1.1 USB standard provides up to 12 Mbit/s speeds.
Anyway, running portable NetBeans on top of portable Java (even the fast 1.6 version) will generally appear slower than the natively installed ones on the host system. But actually that's the worst news about this (may I call it) portable platform. Portability itself is an enormous advantage.
So let's go through the installer of the latest beta version - I'll use the variant with all packs.
The first page of the wizard gives you the opportunity to customize your IDE. Let's see what's in there:
  • Base IDE (requires 58.3 MB) - only this choice isn't really optional. This is the absolute minimum installation and actually it is the platform.
  • Java SE (takes up to 112.6 MB) - this is the essence of the standard Java IDE.
  • Web and Java EE (takes up to 214.5 MB - it requires not only the Base IDE but also the Java SE module) - this module completes NetBeans as an Enterprise Java development tool.
  • Mobility (takes up to 209.5 MB - it also requires the Java SE module) - this module contains the Wireless tollkits of the mobile edition of Java.
  • UML (takes up to 147.6 MB - it also requires the Java SE module) - this module makes NetBeans very powerful application for UML modeling and reverse engineering of source code.
  • SOA (it requires the large amount of 339.7 MB because it depends not only on the Web & Java EE package but also on the both GlassFish end OpenESB runtimes) - the addition for Service Oriented Architecture is an extension of the Web & Enterprise edition of Java.
  • Ruby (occupies 90.2 MB) - a module that gives the Ruby developers a powerful tool for their needs.
  • C/C++ (fills 69.9 MB on the drive) - this module makes the IDE suitable for programming in the powerful languages from the C family. But it does not include the compilers, linkers, etc. - you still have to install your preferred ones on your own as is explained here.
There are three additional runtimes that are a must for some of the development purposes. They might be installed on their own and don't need the Base IDE package:
  • GalssFish V2 UR1 (requires 83.5 MB) - the Open Source variant of the SUN Microsystem's application server (the former SUN Application Server).
  • Apache Tomcat 6.0.16 (a thin application server that takes only 10.4 MB on the drive) - a lightweight web application server from the Apache Software Foundation.
  • Open ESB V2 Preview 4 (takes up to 101.9 MB) - only this runtime cannot be installed on its own because it runs in the context of the GlassFish application server. This is an implementation of an architecture for easier web services integration.
As you may noticed there can be installed several different development environments for various needs. There are Java and Java Web/Enterprise IDE, IDE for mobile Java development, application for UML modelling, Ruby IDE and C/C++ IDE.
A full installation requires about 530 MB and that's without the JDK.
If you choose to install everything after you accept the terms of the License Agreement three screens follow that let you:
  • Provide folder where the application will be installed (that should be on your portable drive) and the folder where the Java Runtime is (where we put it on the previous step).
  • Provide the information for the installation of the GlassFish application server - folder, administrative account, etc.
  • Provide folder where the Apache Tomcat server you want to be installed.
A confirmation page with choices made and Install button follows. Just press it and few minutes later you'll be able to import your projects and libraries and start code on whatever Windows system chance takes you.

8 comments:

Frank Montanaro said...

Trying this out at the moment, the installation seems to be going really slow though =/

Unknown said...
This comment has been removed by the author.
Unknown said...

yes its pretty slow, but that is a price im willing to pay for portability with netbeans
also thank-you for the great tutorial

johnniepop said...

Well, the slowness is something inevitable when we deal with USB Drives. I just installed the new 6.5 version (without Java ME, C/C++, SOA and the servers, BUT with the new Python EA editor ~ 400 MB). It took me around 2 hours - time for taking just a tiny glimpse at the vast debris of the NetBeans site.
Patience is virtue, they say. I'm pretty satisfied with my portable IDE's behavior. I still will be looking for some adjustments and improvements.

MotoMurphy said...

I wish there just was a simple zip or rar..

Anonymous said...

installed with no stress on 16gb USB2.0
Tomorrow i will try to find a way to do the same with VS2008 just need the C# things and the comptact 3.5 FW

Chezars

Pon said...

hi, I found your post on a portable netbeans really good, I got everything working. I just have a problem installing the C/C++ compliler with Cygwin, for some reason, it still tells me I don-t have a compiler for those 2, and I have already installed it before on my pc and it worked fine, but for some reason it doesn-t want to be recognised on my portable hard drive.

I am doing exactly what was written on the Netbeans website "http://www.netbeans.org/kb/60/cnd/setup-Windows.html"

the only stepI am slightly confused with is step 6. if it's a portable hard drive, do I have to add the compiler directory to your path on every single pc I log on to ?

Thanks for the help.^^

Anonymous said...

Want better performance? Install to HD, then move the folders to the USB. If you don't need a LOT of portability (say you'll need to use your environment repeatedly on the same machine; instead of running off the USB, you may copy the dirs to the c:\temp or to %temp% and work from there, just saving your work to the USB).
I use a LOT of portable apps; some of them however aren't USB-aware and save files byte-per-byte (which is VERY VERY slow on any USB device) so I always copy them to the machine's %temp% before using.
%temp% is the current user's temporary folder, its (as far as I know) always accessible and invisible to other users on the same machine; most corporate machines also clear this folder on log-off (I always clear it myself, just in case however).