10 Ocak 2011 Pazartesi

changing netbeans locale

i am trying to reengineer my master thesis work in order to prsesent it as a set of web services instead of a web application.. well, it is not as easy as it seems, since i am also migrating the development environment from eclipse + tomcat + mysql to netbeans 6.8 + glassfish v3 + derby coming with netbeans ide.. while glassfish v3 is started, it comes up with this error:
Server cannot operate in current Locale. Locale is switched to en_US for the process.

actually, after clicking on the dialog box with the error, the server starts and the web service is deployed successfully, i can see the wsdl.. however, when i try to generate client stubs for a java client, stubs seems problematic.. Its the - big i - issue, if you see: (it says illegal character \65533)
private final static WebServiceException ONTOLOGYMNGWSSERV�CE_EXCEPTION;
private final static QName ONTOLOGYMNGWSSERV�CE_QNAME = new QName("http://ws.moass.com/", "OntologyMngWSService");
therefore, i want to change my Netbeans Locale to en_US in order to generate client stubs currectly..

unfortunately, changing the Locale by adding -locale en_US to netbeans_default_options= in NETBEANS_HOME/etc/netbeans.conf file did not help my cause..

i still get the error :(

Edit on 11/1/2011, 13:23:
i tried the same thing on my office computer which is an OpenSuse environment.. i checked the locale with env command, it is set to en_US.. luckily, the above error did not show up this time.. however, it tries to generate constructors such as
public CalculatorWSService(WebServiceFeature... features) {
super(__getWsdlLocation(), CALCULATORWSSERVICE_QNAME, features);
and the super method results in error this time..
by the way, i made the test with Netbeans 6.9.1 and glassfish v3.1..

on the contrary, my home computer is windows vista and here is how to change windows locale: http://windows.microsoft.com/en-US/windows7/Change-the-system-locale

2 Ocak 2011 Pazar

printing an object with reflection api (for debug purpose)

I am at work on a very very cold sunday morning.. then lets learn something in companionship of a cup of hot coffee in this empty office..
my aim is to print an objects attributes regardless of its type.. in other words, i do not want to write seperate debug statements for all my object types.. i want a static method written in java reflection api and use it everywhere.. by the way, i am only interested in printing methods that start with get...()..

good code samples here: http://java.sun.com/developer/technicalArticles/ALT/Reflection/

here is the code to do that:
public static void printObject(String className, Object classItself) {
try {
System.out.println("PRINTING-OBJ " + className);
Class c = Class.forName(className);
Field[] f = c.getFields();
for (int i = 0; i <>
Method[] m = c.getDeclaredMethods();
for (int i = 0; i <>
// System.out.println(m[i].getName());
if (m[i].getName().startsWith("get")) {
try {
System.out.println("METHOD: " + m[i].getName() + " : " + m[i].invoke(classItself, null));
} catch (Exception ex) {
// do nothing
System.out.println("END OF PRINTING-OBJ " + className);
} catch (Exception ex) {
// do nothing
a sample call:

Helper.printObject(Parameter.class.getCanonicalName(), parameter);


PRINTING-OBJ .admin.Parameter
METHOD: getName : name
METHOD: getDescription : description
METHOD: getCode : -10117439
END OF PRINTING-OBJ admin.Parameter