Friday, October 10, 2008

Maven

Sonatype Nexus is great as it simplifies maven. Maven is a useful java tool that allows for simplification of development within a team by removing unnecessary complexity within build scripts however it may seem overwhelming with configuration and repository management.

Development teams should use Sonatype Nexus to provide a cache of public repositories. This also ensures that each developer is using the same internal repository and simplifies configuration on each machine.

The following public repositories should be added to nexus. Note: www.ibiblio.org is a maven 1 repository and you would have to tell nexus to remap virtually present this as a maven 2 repository.

* http://repo1.maven.org/maven2/
* http://download.java.net/maven/2/
* http://repository.codehaus.org/
* http://www.ibiblio.org/maven/



Flexibility



If you need to still need to customise your build you can still use ant by using the antrun plugin.


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<echo message="Hello World"/>
<mkdir dir="target/sample"/>
<javac classname="tim.HelloWorld" classpathref="maven.plugin.classpath" fork="true" dir="target/sample"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>tim.example</groupId>
<artifactId>MyHelloWorld</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>

Friday, October 03, 2008

Zimbabwe

Zimbabwe is slowly heading back to the stone age - Banks are now unable to do internet transfers, or even internal transfers within the same bank ( Banking Chaos in Zim ). In some sick morbid way this is an interesting study of how a government can meltdown.

Sunday, September 28, 2008

S/PDIF and positional audio using DTS Connect

The ALC889A and ALC1200 with DTS Connect, DTS Interactive and/or Doldby Digital Live.

Gigabyte ALC889A with software can fully encode positional DTS for 3d games and general windows use. This is a function of the bundled software and I dont think it would work on Linux.

When buying a new PC one of my big concerns was sound quality and sound drivers. I did not want to buy a separate sound card and I wanted to use my home theater system. Unfortunately due to a hasty purchase some years back I somehow managed to buy a home theater system that takes Stereo In, SPDIF Coaxial In and SPDIF/Toslink Optical In. This means that to get surround my sound card must produce a DTS or Dolby digital signal with more than 2 channels. Also, the home theatre system only had a single Stereo. Some sound cards have multiple analog stereo outputs which plug into many stereo inputs on the home theatedr system which relies on the sound card to produce 3 or 4 analog signals.

In persuit of fewer cables, the important bit again: the sound card must produce a DTS or Dolby signal with more than 2 channels. Many sound cards will encode to DTS or Dolby but produce a stereo digital signal. That means you have stereo and in 3d games and it will not be positional sound. When watching movies the sound card will pass the digital signal directly to the sound card but it will not perform any positional encoding. Some sound cards will label this as "DTS" and "Dolby" which is deceptive.

For 3d games or any funky usage of winamp you PC needs to be able to encode DTS or Dolbly signals on the fly. Realtime encoding of DTS and Dolbly goes under the name of "DTS Connect", "DTS Interactive" or "Dolby Digital Live" and involves a combination of software or hardware to produce the multi-channel digital output. (Rember: A 2 channel DTS signal is not the same as 7.1. Many sound cards will perform stero encoding which is not what you want).

I bought a Gigabyte GA-MA78-S2H which has the ALC889A sound chipset and this implements DTS Connect and DTS Interactive and I get positional sound in games and music via my optical out. The software that comes with this Gigabyte mainboard is great and allows you to tweak all sorts.

One of the more impressive tweaks is to adjust the center channel which is usefull when you play stereo music on 5 speakers. Typically you end up getting all of the voice out of the center channel and its nice to distribute this across other channels by making the center channel wider.

Some websites suggest that the using DTS Connect and DTS Interactive takes 1-3% CPU power to perform this. I dont notice a difference so I dont really care. Dolby Digital Live encoding is supposed to be slightly more efficient to encode in software but I dont currently notice a difference so I dont really care - it works.

My experience with Gigabyte is good. Now although the ALC889A that is used on the gigabyte mainboard can fully encode DTS I believe that this is a feature of the gigabyte software. The ALC889A is a customised ALC885 and is made by Realtek for exclusively for Gigabyte.

One of the alternatives to Gigabyte was ASUS which also has an exclusive sound chipset from Realtek - the ALC1200. I did quite a bit of research and could not confirm that it is able to do DTS Connect. I would imagine it is more advanced because its version number is higher [How technical is that :-) ] but nowhere could I see any mention of realtime positional encoding of Dolby Digital Live, DTS Connect or DTS Interactive and they fall into the same trap where the mainboard supports Steria Digital encoding, will pass DTS and dolby signals from a DVD to your amp or will render the DVD digital to your 4 analog stereo outputs. Very Deceptive.

I dont think that this board will have DTS for linux since the DTS Connect / DTS Interactive has to be implemented by software drivers. In comparison, there has only been one "perfect solution" which was implemented completely in hardware. The nVidia Soundstorm along with its nForce 2 transparently produced full digital signals. This was implemented in hardware.

Enjoy,

-Timothy

Friday, September 19, 2008

Installing Windows

Its that time again - I have a new computer. Its been about 6 to 8 years since I have bought something new for my home PC. I'm buying a beast in a box (Micro ATX, Quad Core, 8gig memory, Blue-ray, Wifi, etc) and hopefully it will be another 6 to 8 years before I have to buy another PC.

The big question is what software I should re-install?

Windows ultimately ends up as an unstable dog with fleas due to failed attempts at finding reasonable software. Having learned from my many mistakes with software of all types, the following is a list that I consider being the most effective in their category. I have linked to the author's website so that in future the latest version may be downloaded.

There are still a few items that I am looking for (suggestions welcome):
  • Photo touchup and image Editing
  • Media Player and Media Organiser
  • Offline CD Collection Organiser
  • Archive Organiser (Old Documents, Projects, Backups, etc)
The following list is linked to its author's website. Free may be open source, freeware or freely downloadable (subject to license, eg: ie8, etc).










Operating System

Windows Vista Operating System
Retail
Windows XP SP3 Operating System
Retail

Office Suite

Microsoft Office Documents
Retail
Open Office Documents
Free
Star Office Documents
Retail (Inexpensive)

Internet Browser

Fire Fox Internet
Free
Google Chrome Internet
Free
IE 8 Internet
Free

DVD Player

Windows Media Player 11 Media
Free
Power DVD Media
Retail

Tools


Acrobat Documents
Free
KeyNote Documents
Free
DVD Shrink File Archive
Free
Image Burn File Archive
Free
IZArc File Archive Slick Free
Dyna DNS Internet Dynamic DNS name Free
Free Download Manager Internet
Free
uTorrent Internet
Free
Google Earth Map
Free
VLC Media Player Media
Free
Dot Net Platform
Free
Java 6 Platform
Free
Shockwave Platform
Free
CC Cleaner OS Tool I don’t like it phoning home Free
Daemon Tools OS Tool Mount CD images (old games, etc) Free
Easy Cleaner OS Tool
Free
FreeUndelete OS Tool Install this before you need to Free
Process Explorer OS Tool Replace Task manager Free
Treesize OS Tool
Free
Tweak All 3 OS Tool Helps removing Browser Helper Objects Free
UnixShell OS Tool wget, grep, etc Free
Who Lock Me OS Tool
Free
Terminals Remote Desktop Multi Tab - VNC, Telnet, SSH, Citrix Free
Google Desktop Shell
Free
Launchy Shell Incredible ** Free
TeraCopy Shell
Free
Xplore2 Shell Plugins required Free
nLite Slipstream
Free
Virtual Box Virtual Machine 3-5% slower than VMWare but free Free
Tomcat 6 Web Server
Free

Development Tools

Hibernate Development
Free
HSSQL Development
Free
Inno Setup Development
Free
IntelliJ IDEA Development Amazing Retail
JDK 1.4.2, 5.0, 6.0 Development
Free
Maven Development
Free
Subversion Development
Free

Internet Tools

FireFTP Firefox Plugin
Free
Adblock Plus Firefox Plugin
Free
Bookmark Duplicate Detector Firefox Plugin
Free
Foxmarks Bookmark Synchronizer Firefox Plugin Same bookmarks at home and at work Free
FoxyProxy Firefox Plugin
Free
IE Tab Firefox Plugin
Free
NewsFox Firefox Plugin
Free
PDF Download Internet Better flexability when clicking on PDFs Free

Web Resources

Life Hacker Internet Resource Life Free
DZone Internet Resource Development Free
Google News News Resource
Free
SlashDot News Resource Technology Free
Old Version Internet Resource
Free
Softpedia Internet Resource
Free

Thats my list of software. Suggestions and recommendations welcome. This list is actually future documentation for myself and it may help others make their life easier.

-Tim

Monday, September 08, 2008

International Shipping



I have been playing with myus.com which is a US re-mailer and gives me a US address in Florida. This allows items purchased from US companies that only deliver to US postal addresses. This costs about $60 a year which has already payed for itself when buying high cost items.

The price of a mid-range / cheap goods turns out to be only slightly cheaper (R100-R500) when purchasing them locally. High end goods seem to attract a very high margin locally so you can easily save up 50% of the cost by purchasing from overseas when taking advantage of exclusive US discounts.

Saturday, August 30, 2008

IDE + SATA to USB converter



The Vantec IDE+SATA to USB converter is useful and allows you to easily access old IDE drives via USB without cluttering your desk. In addition it seems you can use an IDE drive and a SATA drive at the same time.

Saturday, August 02, 2008

Improving Java Swing Performance

I propose a method to improve java swing performance by force-loading commonly used classes.

It is commonly thought that Java is slow and that Swing GUI applications are slow however after the JVM has been running for some time this is shown to be incorrect. It is obvious that poorly designed Swing applications will be slow however is there anything we can do to speed up well designed swing applications?

Part of my perception of a java application's "slow speed" is due to the fact that java loads the classes it needs when the class is used. This means that when you use a feature for the first time the JVM will spend a small amount of time loading the necessary classes. Milliseconds can affect our perception of performance. The solution is to simply move this processing elsewhere and force load these classes before first use.

I recommend loading these classes while the splash screen is being displayed.

How?

1. Track what classes are used
2. Identify which classes you want to load during your splash sequence
3. Load your classes

1. Track what classes are used

The following class is used to instrument java and track class loader activity. Pack the following files into a jar along with the manifest and add the following to your application's command line:
-javaagent:MyInstrument.jar=dummyArg


eg:
java -javaagent:MyInstrument.jar=dummyArg -jar MyApp.jar


ClassLogger.java
public class ClassLogger implements ClassFileTransformer {
String output;

ClassLogger(String output) throws Throwable {
this.output = output;
}

private void log(String s) throws FileNotFoundException {
PrintWriter writer =
new PrintWriter(
new FileOutputStream(new File(output),true));
writer.println(s);
writer.close();
}

public static void premain(
String agentArgs,
Instrumentation inst) throws Throwable {
System.out.println("Class Logger Active");
inst.addTransformer(new ClassLogger("loaded.txt"));
}

public byte[] transform(
ClassLoader loader,
String className,
Class classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
throws IllegalClassFormatException {
try {
log(className.replaceAll("/","."));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return classfileBuffer;
}
}

manifest.mf
Premain-Class: tim.build.instrument.ClassLogger


2. Identify which classes should be force loaded

The above will create a file loaded.txt which will contain a list of classes. You will have to review this class list and remove any classes that should not be loaded.

It is easy to identify common functions. Consider using the most common features in the application and forcing these to be preloaded.

Classes created by CGLIB are dynamically generated and do not exist in your application. These should be removed from the list of classes.

3. Load classes during the splash sequence

The following code will have to be customised based upon your application. Basically it loads the list of classes and executes Class.forName on each of them. Java does have java.lang.Compiler which has a method compileClass(Class) and, although I call it below, I believe that it does nothing with JDK6 (I secretly hope it improves performance).

public static void precacheClasses() {
try {
InputStream is = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("precache.txt");
try {
java.lang.Compiler.enable();
} catch (Throwable t) {
log.warn("Compiler force JIT is not enabled",t);
}
if (is != null) {
String s = IOUtils.toString(is);
for (String sv:s.split("\n")) {
String value = sv.trim();
if (value.length()>0
&& value.charAt(0) != '#') {
try {
Class clazz = Class.forName(value);
java.lang.Compiler.compileClass(clazz);
} catch (Throwable t) {
log.warn("Could not compile class ["+
value+"]",t);
}
}
}
}
} catch (Throwable t) {
log.warn("Problem trying to precache classes",t);
}
}

Usage

Small Applications: Force load every class used. A small utility may be used many times and there is no chance for the JVM to store pre-loaded classes.

Larger Applications: Force load only the classes related to the most commonly used features because of memory constraints.

Success

This makes a well designed application snappy right from the start.

Enjoy,

-Tim

Saturday, February 16, 2008

I've recently been fiddling with a range of Java technologies with ideas involving the application of XWork and EventBus in the context of remote rich clients. With this in mind, I've been porting some of my older applications to the newer frameworks with renewed interest in seeing how much code I can delete using the most advanced features from the various tools.

Some of the tools I've covered are:
  • Hypersonic SQL
  • OGNL
  • XWork
  • Hibernate / EJB3 Annotations
  • Spring Framework
  • SWT
  • JGoodies
  • EventBus
  • MigLayout
  • XFire
  • JGoodies Binding
  • JIDE


Most Impressed With:
  1. Hypersonic SQL - Its ease to setup and has certain deployment possibilities that are not possible with another database.
  2. EventBus - The conceptual application of this is quite broad.
  3. MigLayout - Simplicity - It makes SWT and Swing layout simple.
Most Dissapointing:
  • SWT - Binding seems horrible and JFace seems annoying to use if you dont use Eclipse. Maybe I'm not using the correct data binding frameworks or using it incorrectly. The basic component layer is incredible but the binding is severely lacking.
Most Eager to Work With:
  • OGNL - This could be applied in quite a few areas.
  • EventBus - Conceptual application could simplify a few areas.
Most Mature:
  • Hibernate - Its come along way from when I last used it and the documentation is good.
  • Spring - It still does what I expect of it.
Most Flexible:
  • Hibernate - Its event listeners are mighty useful.
Most Lusted After:
  • JIDE - If only it were free. If I were developing commercial rich client projects this would be good value.
Most Complex:
  • JGoodies Binding - Admittedly, binding is a complex problem, especially when considering Swing. (After being exposed to SWT I feel that the SWT component hierarchy has a level of simplicity around which binding might be made slightly easier. I dont think it will be less complex but there would be at least one or two layers of abstraction less.)

Having listed the above, I'll go into more detail in future posts however. I still need to look at a few gaming libraries for Java (Java 3D, AI, Swing & SWT Theming, etc).


Friday, February 08, 2008

Well, its been a while. In that time a lot has happened... I've climbed Kilimanjaro, scuba dived in Zanzibar and I've even started painting (water paints, still learning before I move to acrylic).

I have a renewed interest in a few technologies so I expect to post more technical commentary and technical ideas/concepts. Over the last 7 years I have great opportunities to experience a very wide range of technologies and paradigms and I am reviewing certain paradigms and technologies a good 7 years later. I hope to blog on my understanding of some of the changes.

-Tim