Archive for September, 2006

Useless Fact

On your Screen Saver dialog, there’s a check option beside the number of minutes to wait before activating your screen saver. Sometimes its “On resume, password-protect”. Sometimes its “On Resume, show welcome screen”.

The difference is when the “Fast User Switching” service is enabled. When enabled, the welcome option will be shown, otherwise password-protect will be shown.

Comments

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

Comments

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.

Comments

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.

Comments (1)

Undeletable Desktop Icons

Such nuisance can be found in the registry key:

HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\{CLSID}

Deleting the relevant CLSID key will remove it from the desktop. You might need to refresh the desktop after deleting it.

Warning: Remember to back up your registry before any modification!

Comments