Tue 27 Nov 2007
Found this interesting article Complement testing with code inspections which lists and explains 11 common mistakes.
Tue 27 Nov 2007
Found this interesting article Complement testing with code inspections which lists and explains 11 common mistakes.
Fri 23 Nov 2007
The eSciDoc Infrastructure is published now under the CDDL-Licence .
eSciDoc uses the Fedora Repository as backend to store the digital objects and runs within a JBoss Application Server. Although it is still beta the main features are implemented and the install works without bigger problems now.
Fri 23 Nov 2007
Hier einige freie Bücher von Galileo Computing auf deutsch.
Integrationshandbuch Microsoft-Netzwerk
Ubuntu GNU/Linux
C von A bis Z
Java ist auch eine Insel – umfangreich
Praxisbuch Objektorientierung – enthällt auch moderne Konzepte wie IoC und Dependency Injection (siehe Spring Framework)
JavaScript und Ajax – ist für Ende November versprochen
Tue 7 Aug 2007
The Handle System provides an open source implementation of the Handle System protocol (read the license: 4263537/5024).
I was curious to see and learn from the code. Also I am developing webservices using Axis2 and Spring to wrap the Handles Client API. See also Adam Smith’s Article about Developing Handle System Web Services at Cornell University and the source code Cornell University published just yesterday – handle_services.
For that you need more information then provided by the written documentation. This kind of information you can find by studying the source code directly. Furthermore one also might wish to extend the provided resolution mechanism of the included proxy. So I decided to have the source code in the same workspace in Eclipse as my webservice project. How to set up an independend handle server at localhost to play with dummy handles for testing purposes I described here.
Download the hdl6.2.4.tar.gz file from Handle Software Download. From that archive you will need the src.zip (source code) und handle.jar files. Extract the src.zip file . From the handle.jar you will need to extract a library to compile the handle source:
jar xvf handle.jar net/cnrijar cvf cnriutil.jar netYou will also need the Java Servlet library ( jsdk.jar). Download it from here: SPECIFICATIONS – Download class files 2.3, rename the downloaded zip file to jsdk.jar.
How to import the code into a Eclipse Java project? There are two issues here – getting the libs right and the not eclipse-friendly project structure. This is the way it worked for me with Eclipse 3.2:
After that I had still some errors due to 6.0 compiler compliance level. Problem were variables called enum. Enum is a reserved Java keyword now. So I renamed the variables to enm.
There are two advices you can find in the build.xml and build.properties files – setting “maintainerMode = true” and override the build.properties by using user.properties. To use user.properties correctly I had to edit the build.xml file:
<!-- include user.properties file for custom config -->
<property file="user.properties">
<property file="build.properties">
The user.properties:
target = 1.6
# maintainerMode = true
I couldn’t use the maintainer Mode cause the appropriate root_info were not available in the source code. Still I could compile the source code by using the appropriate ant tasks in Eclipse and make server and clients run like described in this post.
Thu 2 Aug 2007
… or rather compiled versus interpreted languages. If you use static final sometype varname in Java to define constants belonging to some class and you are using them in other classes you will have to recompile that classes too after changing the value of the constant.The constants get compiled into every class that use them. A problem which does not exist with interpreted languages. In Java you can use enums in some cases instead.
Thu 12 Jul 2007
The Handle System provides a distributed infrastructure to manage persistent identifiers (PID) of digital ressources and resolve to their locations. There are several advantages of the Handle system like: scalability, detailed documentation, typed records structure, working global resolution infrastructure and last but not least – stable and readable Java code. By default a Handle server and its clients are designed to participate in the global PID resolution infrastructure.
But if you like to experiment with a local installation within your development environment you can follow these steps (you should be familiar with the Handle basics and Chapter 11 of the Technical Manual, also read the Handle System Service Agreement http://hdl.handle.net/4263537/5029 for more information).
Server setup:
/******************************************************************************
* Get IP address for server
*/
private static InetAddress getIPAddress()
throws Exception
{
String localAddress = "",
prompt = "Through what IP address will this server be accessible?";
try {
localAddress = InetAddress.getLocalHost().getHostAddress();
}
catch (Exception e)
{
localAddress = "";
}
if (localAddress.length() > 0)
prompt = prompt + " [" + localAddress + "]";while (true) // I.e., until "break" on success
{
String line = responseToPrompt(prompt);
if ((line.equals("")) && (localAddress.length() > 0))
line = localAddress;try {
InetAddress listenAddr = InetAddress.getByName(line);
/* if (listenAddr.getHostAddress().startsWith("127."))
throw new Exception("you must enter an address that is accessible from the network");*/
return listenAddr; // Success
}
catch (Exception e)
{
out.println("Invalid address (" + e + "), please try again.");
}
}
}java -cp ./bin/handle.jar net.handle.apps.db_tool.DBTool ./svr_1/ 300 HS_PUBKEY 1110 <hexcode of your pubkey>301 HS_SECKEY 1110 secret"server_config" = {
"server_admin_full_access" = "y"
"allow_na_admins" = "no""server_admins" = (
"300:1/ADMIN"
"301:1/ADMIN"
) and same for other admin elements./hs$ java -cp ./bin/handle.jar net.handle.server.Main svr_1/ Configure Client (linux):
Mon 18 Jun 2007
Einen ausführlichen Artikel findest du hier: http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html und hier: http://java.sun.com/performance/reference/whitepapers/tuning.html . Siehe auch das Beispiel für Eclipse in Eclipse Crash Problem . Ein geeignetes Profiling-Tool ist GCViewer.
Weitere Tips (aus der oben genannten Quelle):
Beachte auch (siehe http://java.sun.com/performance/reference/whitepapers/tuning.html)
:
Before you start to tune the command line arguments for Java be aware that Sun’s HotSpot™ Java Virtual Machine has incorporated technology to begin to tune itself. This smart tuning is referred to as Ergonomics. Most computers that have at least 2 CPU’s and at least 2 GB of physical memory are considered server-class machines which means that by default the settings are:
Tue 15 May 2007
Ever wondered about regular “out of memory” crashes of Eclipse? One solution for you might be to set the Java Virtual Machine settings in case you use sun java (on linux)
eclipse -vmargs -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m
(Thats rather pessimistic numbers, but my computer has 1,5 GB memory, so I can afford it.)
The problem seems to be that suns virtual machine is not reserving enough permanent generation space and can not handle big amounts of loaded classes. More detailed explanation you can find in my excerpt (in german language) Java Virtuell Machine Setzungen für große Serveranwendungen anpassen
“The permanent generation is used to hold reflective of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations. Generally, sizing of this generation can be ignored because the default size is adequate. However, programs that load many classes may need a larger permanent generation.”( Frequently Asked Questions
about Garbage Collection
in the HotspotTM JavaTM Virtual Machine).
See also jmap – Memory Map, Eclipse Bug 92250.
A great explanation you can find at Frank Kieviet’s Blog:
More Virtuell Machine (Hot Spot) options at http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp and tuning tips at http://java.sun.com/docs/hotspot/gc/.
Mon 16 Apr 2007
Sometimes the management asks: Why do we need to hire Java programmers, can
we not let our scripters do the job?
Ok, you can answer this question by using a lot of buzzwords. But it seems to me to be more difficult to explain it to someone who has not at least a basic insight into the programming domain. Here is a (too?) simple java example:
/* straight forward coding you will see suprisingly often done by people with scripting background only, creates 1000 copies of "D" */
String[] a = new String[1000];
for (int i = 0; i < 1000; i++) {
a[i] = new String("D");
}/* creates 1 instance of "D" and 1000 references to it,
in more serious operations that will have visible effect on the performance */
String[] a = new String[1000];
String d = "D";
for (int i = 0; i < 1000; i++) {
a[i] = d;
}/* So what about this? */
String[] a = new String[1000];
for (int i = 0; i < 1000; i++) {
a[i] = "D";
}
/* Actually the compiler will treat "D" as a static symbol, no overhead is produced
*/Check it out by yourself:
/**
* @see http://java.sun.com/docs/books/performance/1st_edition/html/JPRAMFootprint.fm.html
* @author Konstantin Rekk
*
*/
public class InitialisationIssues { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stubString[] a = new String[1000];System.out.println("before: " + getUsedMemory());
// String d = new String("-----DATA-----------------------------");
for (int i = 0; i < 1000; i++) {
// a[i] = new String("-----DATA-----------------------------"); ;
a[i] = "-----DATA-----------------------------";
}
System.out.println("after: " + getUsedMemory());
for (String el : a) {
System.out.println(el.toString());
}
}
private static long getUsedMemory() {
gc();
long totalMemory = Runtime.getRuntime().totalMemory();
gc();
long freeMemory = Runtime.getRuntime().freeMemory();
long usedMemory = totalMemory - freeMemory;
return usedMemory;
}
private static void gc() {
try {
System.gc();
Thread.sleep(100);
System.runFinalization();
Thread.sleep(100);
System.gc();
Thread.sleep(100);
System.runFinalization();
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Wed 28 Mar 2007
If you have a lot of eclipse workspaces to manage it is helpful to have them shown in the title bar of the window. Is there any setting in the preferences for this? I don’t know, but you can use the -showlocation option at start up:
eclipse -showlocation -vmargs -Xmx700M