Tuesday 27 October 2009

JAXB & Ant : package-info.java compilation problem of JAXB generated classes.

 package-info.class not generated

1.Generate the class
  xjc -p test.xsd -d C:/workspace/Test/src
2. Compile the project . package-info.class is generated.
3. Then call the clean task to remove .class files and rebuild the project. package-info.class is not generated.


Note on package-info.java from Ant Manual [http://ant.apache.org/manual/CoreTasks/javac.html]

 package-info.java files were introduced in Java5 to allow package level annotations. On compilation, if the java file does not contain runtime annotations, there will be no .class file for the java file. Up to Ant 1.7.1, when the task is run again, the task will try to compile the package-info java files again.

In Ant 1.7.1 the package-info.java will only be compiled if:

   1. If a package-info.class file exists and is older than the package-info.java file.
   2. If the directory for the package-info.class file does not exist.
   3. If the directory for the package-info.class file exists, and has an older modification time than the the package-info.java file. In this case will touch the corresponding .class directory on successful compilation.
  


Related Links
http://ant.apache.org/manual/CoreTasks/javac.html
http://article.gmane.org/gmane.comp.jakarta.ant.devel/52586
http://www.javalinux.it/wordpress/?p=261

Monday 26 October 2009

JAVA Compiler error : class file has wrong version 49.0, should be 48.0

Compiler error message :

    [javac] class file has wrong version 49.0, should be 48.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    [javac] import com.common.dao.QueueDAO;
    [javac]                         ^
    [javac] 1 error

Reason :

Java 1.4 creates class files labeled with version 48.0
Java 1.5 creates class files labeled with version 49.0
Check the java compiler versions


Related links :
http://forums.sun.com/thread.jspa?threadID=644158
http://www.dreamincode.net/forums/showtopic49155.htm

Thursday 15 October 2009

How does log4j load the config files ?

Add -Dlog4j.debug to the command line.


trace file :

log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@11b86e7.
log4j: Trying to find [log4j.xml] using sun.misc.Launcher$AppClassLoader@11b86e7 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader sun.misc.Launcher$AppClassLoader@11b86e7.
log4j: Trying to find [log4j.properties] using sun.misc.Launcher$AppClassLoader@11b86e7 class loader.
log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [null].
ControlListener Created





Links :
http://jaitechwriteups.blogspot.com/2006/07/know-how-log4j-tries-to-configure.html
http://jaikiran.wordpress.com/2006/07/05/i-get-log4jwarn-no-appenders-could-be-found-for-logger-message-2/
 

Friday 2 October 2009

Eclips Shortcut Key

       I do not have patient to browse through the files, I always look for shortcuts and customize the editor shortcut keys as I wish.

You can assign or edit the shortcut key binding.
Goto , Window  --> Preferences --> General --> Keys, Just play around with that window.

List of shortcut keys : CTRL+SHIFT+L


List of shortcut key list

Open a Resource : Ctrl+Shift+Y
Open a Type:        Ctrl+Shift+T

Go to Method :     Ctrl+O , Shift+O,O
Go to Line:           Ctrl+L

Lower Case:        Ctrl+Shift+Y
Upper Case:        Ctrl+Shift+X

Expand:              Ctrl+Numpad_Add
Expand All:         Ctrl+Numpad_Multiply
Collapse:            Ctrl+Numpad_Subtract
Collapse All:       Ctrl+Shift+Numpad_Divide