Archive

Archive for the ‘Uncategorized’ Category

Removing french language in Eclipse’s findbugs plugin

September 16th, 2009

When using the findbugs plugin in Eclipse in an environment where the locale is french, all bug descriptions appear in french. Theses messages are not displayed correctly, supposedly because of an encoding incompatbility with HTML.

In order to get the original, english messages, we will remove the french messages from the plugin. Do the following:

  • locate and go to your Eclipse plugin folder (maybe at c:\Program Files\Eclipse\plugins)
  • in the plugins find the findbugs folder (edu.umd.cs.findbugs.plugin.eclipse_x.x.x.xxxxxxxx, where the x stand for a version number)
  • in that folder, you find the plugin as a jar (findbugs-plugin.jar), open it with a zip utility and rename the file messages_fr.xml to (for example) messages_fr.xml.noFrench so that it won’t be found on startup

Uncategorized

Getting the location of an executing batch script (.bat file)

July 24th, 2009

A Windows batch script (.bat file) has an associated directory; the current working folder. It can be accessed in a batch file by the system variable %cd%. If instead, you want to obtain the location of the currently executing script, use %~dp0.

Note that both may be the same, but are not necessarily.

Uncategorized

htpasswd.exe to make your apache password files

May 27th, 2009

It happened several times that I was looking for htpasswd.exe which is distributed with the apache web server, but had it not handy. The apache foundation unfortunately does not distribute this exec separately, and installing / uninstalling the server just to get the password making program is a bit tedious. So here it is:

htpasswd.exe

.
Note that the Windows executable cannot encode the password using the CRYPT method (although it says so in the help screen). If you need to make passwords for a system expecting CRYPT, you may use the service at http://www.askapache.com/online-tools/htpasswd-generator/

Uncategorized , , ,

Quote or escape your Java classpath in cygwin!

April 17th, 2009

If you are using Java in cygwin, a little attention is necessary because two worlds collide. On the one hand, the Windows world, where the java.exe lives and on the other the bash of cygwin in which you are starting the command. In particular, when setting the classpath you need to pay attention to the differences.

Java on Linux separates its classpath entries using the colon (:) while Java on Windows separates the entries with a semi-colon (;). There is a good reason for this; on Windows the colon would have been impractical as it is used in file pathes (c:\…), on Linux the semi-colon is impractical, as it is used to end a command line.

Thus using the Windows Java in cygwin forces us to use the semi-colon (because that’s what the java.exe expects) in an enviornment where the semi-colon is a command line end. So to make it work, you need to either quote the argument or escape the semi-colons
$ java -cp "path/to/include;path/to/some.jar" Main
$ java -cp path/to/include\;path/to/some.jar Main

Else the following errors occur.
When using the semi-colon un-escaped:

$ java -cp .;Printer.jar PrintTest
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
[...]

When using the colon (which would be correct in a Linux environment)

$ java -cp .:Printer.jar PrintTest
Exception in thread "main" java.lang.NoClassDefFoundError: PrintTest
Caused by: java.lang.ClassNotFoundException: PrintTest
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: PrintTest. Program will exit.

Uncategorized , ,

Setting ls to reasonable colors in cygwin

April 15th, 2009

I often navigate folders in Windows explorer without using the mouse. This is quick, as you can jump to any file or folder by typing the first letters of the name and use backspace to go up one level. The speed is probably faster than what you achieve in a bash shell, where you complete names with tab.

In the Windows explorer, folders are listed first and have a yellow icon, files are just plain black-on-white. Using the bash shell in cygwin, I wanted to retain these mnemonic features.

Here is what goes into my .bashrc to achieve this:

alias ls='ls -A --color=auto --group-directories-first'
alias ll='ls -lh'
LS_COLORS='no=00:di=33;01:tw=33;01:ow=33;01'
LS_COLORS=$LS_COLORS':fi=00:ln=00:pi=00:so=00:bd=00:cd=00:or=00:mi=00:ex=00'
LS_COLORS=$LS_COLORS':*.sh=31:*.sh=31:*.exe=31:*.bat=31:*.com=31'
export LS_COLORS

A few words of explanation. It defines two aliases, one shadowing the ls command itself to 1) hide the . and .. folders in each output using the -A option 2) use coloring on device which support it only with the --color=auto 3) have folders listed first with the --group-directories-first. The second alias is really just a shortcut (using the first!) long listed dirs (with human readable file sizes).

The colors are basically bright-yellow (33;01) for all dirs, red (31) for executable files and default (00) for all other files and text. Note that it doesn’t really make sense to define a color for executable files in cygwin, as all existing files are executable per default.

Uncategorized , , ,