The IT Alchemy Lab really doesn't have any set "purpose" to speak of. It is more about the IT technologies and issues I come across in my day-to-day business, meetings and chats (lunches, coffee and drinks) with my IT colleagues and friends.

Blog Archive

Tuesday, August 10, 2010

Something new in JDK 6

(IMHO) I have to admit, Oracle is doing a nice job managing the java releases. They have added the jvisualvm option (blogging this feature soon), added the G1 GarbageCollector to the later releases of JDK 6 (_14 to be exact). This was slated as one of the big performance items in JDK 7. Today I found a very cool new feature ... not often used, but still a huge benefit.
Java classpath (-cp or -classpath) arguemnt in JDK 6 now supports the wildcard feature.
For example, if you want to included 3 external libraries in a bootstrap script you would have to use the following:

#!/bin/bash
libSource=/opt/lib/mysql-version.jar:/opt/lib/gwt-version.jar:/opt/lib/j2ee-version.jar
java -classpath $libSource target/myExecutableJar-version.jar

With JDK 6, it is much easier (and cleaner) to implement. So much so that a bootstrap might not be necessary.

java -classpath /opt/lib/'*' target/myExecutableJar-version.jar

1 comment:

Sven said...

Indeed a helpful feature. Unfortunately it doesnt work inside a manifest.mf file. For the Class-Path field you still have to write down every single dependency and cant use the wildcard.

About Me

My photo
Don't tell people how to do things, tell them what to do and let them surprise you with their results. --General George S. Patton
Open Source Links | Sourceforge | Slashdot | Open Source