Java, C++: ClassLoader and Qt Resource System
Here a little comparison between the Java ClassLoader and the Qt Resource System:
If you want to load an Icon and/or an Image in a Java Class (e.g. in a .jar-File) you have to do the following:
Icon icon;
Image image;
ClassLoader CLDR = this.getClass().getClassLoader();
String path = "src/to/images/name.png";
URL url = CLDR.getResource(path);
// An Icon
if (!(url == null)) {
icon = new ImageIcon(url);
}
// An Image
try {
iconDock = ImageIO.read(CLDR.getResource(path));
} catch (IOException e) {
// ExceptionHandling here
}
In Qt they have another approach:
The Resources associated with an Application are specified in a XML-based .qrc File.
The specified Paths are relative to the Directory containing the .qrc File (listed Files must be located in the same Directory or any Sub-Directory).
In the Source-Code the Resources are accessible under the same Name they have in the Source Tree, with a “:/” Prefix.
Here an Example:
<RCC>
<qresource prefix="/dir/subDir" lang="en">
<file alias="License">subDir/FileName<file>
<qresource>
</RCC>
In your Source Code you can access FileName (if FileName e.g. is a QFile) via
QFile file(":/dir/subdir/AliasName");
after adding the following Line to your .pro-File:
RESOURCES = yourRsrcFileName.qrc
The Option lang=”langCode” (here: “en”) is for Localization:
If you want to add another Language to your Application you have to have the File “AliasName_langCode” in your Source Tree.
Here an Example for the Java ClassLoader and here an Example for the Qt Resource System:
- The Resource File
- The Usage (Lines 58-59)
C++: How to Include the Boost Library in XCode Projects
0. Download the boost-Library and unzip it anywhere (here: “/Developer/Tools/boost”)
1. Create a Project.
2. Right-click at the Project-Name and select “Get Info”
3. Set the “Header Search Paths” to the Folder you unzipped the Library (here: “/Developer/Tools/boost”)
4. Ready to boost.
About Videos, Music and more…
Thanks to Superlevel for the Idea!
Mac OS X – “Automator”: Combine PDF Files
Today I had to find a Program that combines/merges 2 or more PDF-Files.
Because I didn’t want to use Adobe Acrobat (Pro?) I turned my Internet-Search on and found an interesting Program: The Mac OS X Automator.
Without reading any Tutorial or something different (Automator is really self-explanatory!) I created a good-working “Automation”/Program that performs that Task.
Here’s the Workflow:
- Ask for Finder-Items
- Combine PDF Pages
- Move Finder Items

- Update 11.10.2009 -
Created a Sub-Site named Automator-Workflows at www.calltopower.de/automatorworkflows where you can see Screenshots of the Workflows and/or download the Workflows and/or Programs. I created among other things “Save Pictures from the current Website”, “Take Screenshot”, “Take Image from Webcam (iSight or other)”, “Pictures to PDF”.
C: KaR – Exercise 1-14 – Horizontal Histogram of Char-Frequencies
It’s Time for another Exercise from “Kernighan and Ritchie – The C Programming Language” – Exercise 1-14:
Write a program to print a histogram of the frequencies of different characters in its input
The 2 main Routines are:
1. Read in the Characters and count up the Position in an Array
/* Get a Character */
while((c = fgetc(text_file)) != EOF) {
/* If c is a Character */
if(isalpha(c)) {
/* Count up the Array at Chars Position */
char_counter[(int)(toascii(tolower(c))-toascii('a'))]++;
/* Count up Counter for total Characters */
chars_total++;
}
}
2. Print the horizontal Histogram
/* Print the horizontal Histogram */
printf("\n\tChar\tTimes\n");
for(i = 0; i < ALPHABET_LENGTH; i++) {
/* Print Header */
printf("\t%c\t%d\t", (i+'a'), char_counter[i]);
for(j = 0; j < char_counter[i]; j++) {
/* If Diagram Print Limit not exceeded */
if(j < diagramm_print_length) {
printf("-");
} else {
/* Print a '+' and the Number of Chars >
Diagram Print Limit and break the Loop */
printf(" + %d", (char_counter[i] - j));
break;
}
}
printf("\n");
}
printf("\t------------------------");
printf("\n\tTotal Chars: %d\n", chars_total);
Here the full Program to download.
And if the Program analyses itself you will get the following Output:

SICK Robot Day 2009
Today’s the SICK Robot Day 2009 (Link1 | Link2).
I have worked on it for the University of Osnabrueck.
We’ve had tough luck because we had to completely “re-write” our Behaviours a Week ago but theoretically the Robot is ready now
.
He avoids Collisions, respects the Rule “left yields right”, is able to detect Numbers as well as Markers and drives to the right Numbers from 0-9 and/or vice versa.
So…good Luck to everyone in Waldkirch.
Here some Photos of Kurt2 at our self-made Parcours:

And some Videos at our self-made Parcours:
Java: Text to Speech on Mac OS X
Tonight I wanted to do something different: Text to Speech on my Mac – via Java.
So here the Main Routine to do that Task:
Runtime.getRuntime().exec(new String[] { "say", "-v", "YourVoice", "Text" });
(YourVoice is a Mac OS X-supported Voice, e.g. “Zarvox”)
You can see the full Class here.
For testing it without embedding the Class compile it
javac TextToSpeech.java
and run it with one of the Voices
java TextToSpeech Hi dude, whats up? Zarvox
or without (=random Voice)
java TextToSpeech Hi dude, whats up?
To see it live in Action have a Look at my jPortscanner.



