Slow Explorer

If you’re browsing in Windows Explorer and particular folders load just so much slower than the others, check if those folder contains zip files.

This is because Windows Explorer takes effort to “help” read those zip files so that you can access them as if they’re another sub-folder. If you’re accessing that folder often, you might want to shift those zips somewhere else to prevent Windows from trying to read them.

For those keen on removing this “feature” permanantly, run:

regsvr32 /u %systemroot%\system32\zipfldr.dll

Ant

I’ve been avoiding ANT for many many years now… probably because I’ve not got into any serious deployment, or something which simple compilation cannot do. However, I finally took my step in (JUST to try it), and it wasn’t so bad after all.

Essentially, the Ant tool is a cross-platform build script (windows batch file or unix make) that can run commands in batches. Core commands (“built-in”) include copy, delete, javac, java, jar, etc. You can group these commands in ‘tasks’ in a ‘project’ to be executed separately or you can create dependant tasks that executes one after another.

Common tasks include init (which setup variable for use in the tasks, usually a dependancy for all other tasks), build/compile (main javac code to javac and move them to appropriate dir), deploy (copy ready jar/war and files to deployment locations) and clean (delete everything).

I’ve used the core copy and jar commands to build Wildfire plugins that are deployed directly, eliminating the need to manually move class files, jar and copy to deploy folder. Compilation was automatically done with Eclipse, and the Ant task was run directly in Eclipse too.

For more complicated projects Ant also support defining your own Ant tasks, though I’ve yet to need such services. However being so extensible you can say it can do anything that you can code.

System Variables: PATH vs CLASSPATH

Still a lot of people don’t understand the purpose of these system variables. They don’t know when to set it, what it really does and therefore cannot determine that this IS or IS NOT a path or classpath problem.

The PATH variable is a Windows system variable that Windows uses to find executable files. When you type a command in the cmd window, e.g. “javac”, Windows will search in your PATH to find the program to execute. The search sequence is as follows:

Current Dir > PATH Variable > Command Interpreter

In the example, the interpreter will first look in the Current Dir for a javac.com, javac.exe or javac.bat respectively. If found, it will be executed. If not it continues its search through the PATH variable in definition sequence and extension sequence. This means for PATH=C:\Temp;C:\Windows, C:\Temp\javac.com will be searched 1st, followed by C:\Temp\javac.exe, C:\Temp\javac.bat, C:\Windows\javac.com, and so on.

Once the PATH is exhausted, the interpreter will be checked if it is a interpreter command (such as “copy”). If so it will be invoked. Finally the interpreter will return a “Bad command or file name” if the command is not found.

All these means that if you’re getting a “Bad command or file name”, it is likely a PATH problem. It also means if you’re somehow running the wrong program, it may be a program of the same name in a path earlier than yours (useful for java version conflicts).

The CLASSPATH variable is a Java runtime system variable that Java uses to find class files. When Java tries to load a class, it will lookup its ClassLoader. If the class is not yet loaded, Java tries to find the class in the CLASSPATH variable. Sometimes the CLASSPATH may be appended from the runtime command line directly.

This means that if you’re getting a ClassNotFoundException during runtime, or “Unable to resolve symbol” during compile, you may have a CLASSPATH problem. (NOTE: Typos and other errors may also raise same compile error). If the classes are in the current directory and still cannot be found try adding “.” (current dir) to the classpath or check if the sources are in java packages.

To check the current PATH on cmd, type “PATH” or “set PATH”. To check the CLASSPATH, type “set CLASSPATH”.

To fix the PATH or CLASSPATH, you can either set it on the command line directly or set it through System Environment Variables. To set it from cmd, type “set CLASSPATH=someClassPath”. To append to the existing PATH or CLASSPATH, use %xxx%. E.g. “set CLASSPATH=%CLASSPATH%;.” to append the current directory into the classpath without affecting the existing classpath. Setting the variables on cmd only persists for that session. If you start another cmd or close this cmd the variables will be reset.

To persist the variables permanantly, you can set it through System Environment Variables. For XP Pro, go to the “System Properties” first. You can get there by

  1. Start > Control Panel > System
  2. Start, right-click “My Computer”, select “Properties”
  3. Press [WindowsKey]+[Break] simultaneously

with option 3 being the fastest. From there, click the “Advanced” tab and click “Environment Variables” at the bottom. Set either the User variables or System variables. The User variables only affect your Windows Login, and System variables will affect everyone. User variables will overwrite any System variable settings.

Sun Solaris Installation

Had a chance to install Sun Solaris 10 on a Solaris machine today with a 64-bit AMD Opteron processor. The machine came installed with Windows XP 64 bit (first time seeing it too) but we didn’t have the password to access the system.

The installation was quite straightforward with its auto-boot GUI installation wizard, although it asked damn lots of questions from network settings to locale BEFORE asking the user to assign disk space for the installation. (imagine the situation when you configured everything but did not have enough disk space for it.

The end result of it is a unix system (with /etc /var /bin), and two GUI apps (CDE – Common Desktop Environment & Java Desktop) which are Windows-like GUI systems. The CDE resembles more like X-Win while Java Desktop mimics Windows closer (with a “Start” button and taskbar). Configuration is still as weird as normal Unix, since I’m not that Unixy.

The weirdest part was before installation we used a “self-burnt” DVD to try install Solaris 10 x86 Update 2. The CD-ROM boots and stucks at “Loading stage2…”. Google say its a known bug when installing from SCSI DVD-ROM drives but ours is IDE (I think). Popping the CD out throws us into GRUB (GRand Unified Bootloader), but we can’t start the install wizard despite trying those “boot” and “kernel” commands.

In the end we resorted to using an “older” original version of Sun Solaris 10 x86, also DVD.

Tidbits:
– ifconfig = ipconfig
– DNS nameservers is set in etc/resolv.conf

UltraVNC

UltraVNC is a flavour of VNC — its an open source project in SourceForge. It provides all basic VNC features: connecting to remote machine, perform mouse/keyboard tasks on remote machine, transfer files, etc. It even allows connection via HTTP using a Java Viewer, possibly allowing it to cross firewalls.

Configuration is straightforward with a single password, but I’ve yet to see if it can integrate into the Windows Authentication.

So far UltraVNC has served me well and hasn’t given me serious problems. Server installs cleanly, and the client is light and doesn’t even need installation. A simple unzip and the viewer can be run.

VMWare

VMWare allows you run an OS inside your OS, eg. Run Linux in your Windows machine, or Windows in Linux. A very useful program I think.

I installed my WinXP Pro in an WinXP Pro machine, and used the VM as a test platform to try out software without corrupting my actual system. Can be also used to test if some software is spyware-like. Once I made a complete installation, I made a “copy” of the OS so I have a clean WinXP installation anytime.

Working within the VM is exactly like having another machine, much like what VNC provides, except the VM is not any physical machine anywhere else. The VM has its own BIOS, hard disk space and IP address… I could ping from my host to VM and VM to host, very real.

The only annoyance was trying to transfer files between my host OS and the VM. This is especially necessary when I want to copy installation files over. Shared folders didn’t really work out, so I had to use another machine’s shared folder. Perhaps there exists an easier way for file transfer from host to VM.

I give VMWare 10 out of 10.

Effective Java (Review)

4. Avoid creating duplicate objects
5. Eliminate obsolete object references

12. Minimize accesibility of classes and members

21. Replace enum constructs with classes

23. Check parameters for validity
27. Return zero-length arrays, not nulls

29. Minimize the scope of local variables
30. Know and use the libraries
31. Avoid float and double if exact answers are required
32. Avoid strings where other types are more appropriate
33. Beware the performance of string concatenation
36. Use native methods judiciously
37. Optimize judiciously

39. Use exceptions only for exceptional conditions
47. Don’t ignore exceptions