Archive

Archive for May, 2011

Starting a minimal X

May 17th, 2011 No comments

Just because I always forget and the parameters are somewhat non-trivial, here’s how you start an xterm inside X:

startx $(which xterm) -- :0 vt01

Of course, the display name :0 is usually used by default, so you may need to use another one (:1 etc.) if you get an error like “Server is already active for display 0“. You can also select a different virtual terminal.

Note that the absolute path to xterm (or whatever application you’d like to start inside X) is essential.

Categories: Uncategorized Tags:

Multiple main methods in a single jar archive

May 13th, 2011 No comments

A Java archive file usually holds a manifest file that specifies the main class to start when you invoke java -jar jarfile. It’s something similar to this:

Main-Class: com.yourcom.package.MyClass

When you distribute your jar file, a user can simply execute it (possibly even with a double click) without knowing anything about your package structure or location of the main class.

But what if you want to execute a different main method in another class inside your jar file, maybe for testing purposes? Well, you don’t have to hack the manifest and re-package. Simply do

java -cp jarfile com.yourcom.package.MyClass

and the main method inside MyClass will be executed.

Categories: Uncategorized Tags:

Batch converting files from iso-8859-1 to utf-8

May 8th, 2011 No comments

I’ve already posted on how to convert a single file from one encoding to another (iso-8859-1 to utf-8 in this example). But how to do it for a large amount of files, let’s say LaTeX source files for example, in one go?

Here’s a little bash one-liner that could help:

find ~ -type f -name "*.tex" -exec sh -c '
  f="{}"
  iconv --from-code=ISO-8859-1 --to-code=UTF-8 -- "$f" > "$f".tmp
  mv -v -- "$f".tmp "$f"
  ' \;
Categories: Uncategorized Tags: