Sunday, August 2, 2009

Java Tracing & logging

Reference from: http://java.sun.com/javase/6/docs/technotes/guides/deployment/deployment-guide/tracing_logging.html

Tracing

Tracing is a facility to redirect any output in the Java Console to a trace file.

Java Plug-in

Tracing can be turned on by enabling the property javaplugin.trace. However, it turns on all tracing facilities inside Java Plug-in. To enable more fine-grained tracing, javaplugin.trace.option may be used. You can set trace-level options (0-5) in the Java Console, shown in the previous chapter, with the following meanings:

  • 0 — off
  • 1 — basic
  • 2 — network, cache, and basic
  • 3 — security, network and basic
  • 4 — extension, security, network and basic
  • 5 — LiveConnect, extension, security, network, temp, and basic

This enables tracing on the fly.

Another way to set fine-grained tracing is through the Java Control Panel. For instance, to enable tracing for everthing (option 5 above), enter the following in the "Java Run Time Parameters" textfield:

-Djavaplugin.trace=true
-Djavaplugin.trace.option=basic|net|cache|security|ext|liveconnect|temp

Tracing set through the Control Panel will take effect when the Plug-in is launched, but changes made through the Control Panel while a Plug-in is running will have no effect until restart.

Java Web Start

To set the initial trace level for a Java Web Start application set the deployment property deployment.trace.level. The deployment.trace.level property can have one of the following values:

  • basic
  • cache
  • net
  • security
  • ext
  • liveconnect

To use all the tracing level set deployment.trace.level to all.

Logging

Similar to tracing, logging is a facility to redirect any output in the Java Console to a log file using the Java Logging API. To enable logging perform the following actions:

  • Open Java Control Panel
  • Click Advanced tab.
  • Select Enable Logging under the Debugging option

Other Options

File Names

The names of the trace and log files are

plugin.trace
plugin.log

where the includes the major, minor and patch version numbers; e.g., plugin142_06.trace or plugin150.log

File Locations

The default location (directory) of the trace and log files is:

  • /.java/deployment/log on Unix/Linux
  • \Sun\Java\Deployment\log on Windows

where is as defined here.

If the environment variable USER_JPI_PROFILE is set to then the trace and log files will be written to:

  • /.java/deployment/log on Unix/Linux
  • \Sun\Java\Deployment\log on Windows

Wednesday, July 29, 2009

Personal 2D barcode

http://mobilecodes.nokia.com/create.jsp?terms=accepted

Tuesday, July 28, 2009

log4J internationalization & localisation

http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/
http://java.sun.com/docs/books/tutorial/i18n/index.html
http://forums.sun.com/thread.jspa?threadID=5370732&tstart=60
http://blogs.sun.com/CoreJavaTechTips/entry/logging_localized_message

Log4J internationalization
http://forums.sun.com/thread.jspa?threadID=770074



Debug java util MissingResourceException

java.util.MissingResourceException Can't find bundle for base name, locale...How did I get this exception? The crux of this problem is the requested resource, in most cases, a properties file, is not configured correctly in the classpath. For example, you have a properties file, connection.properties, in the same source directory as Java source files. Javac will compile *.java into *.class in a target directory such as build/classes, which is in your runtime classpath. But connection.properties is not copied into build/classes directory unless you either add a task after in the Ant build file, or do so manually.

How to fix it? Make sure this resource is configured correctly in the classpath through one of the following:

  • Like I said above, copy the resource from source directory to build/classes directory, which is in the classpath.
    • If your code is like ResourceBundle.getBundle("connection"), then after copying you should have build/classes/connection.properties.
    • If your code is like ResourceBundle.getBundle("com.javahowto.test.connection"), then after copying you should have build/classes/com/javahowto/test/connection.properties.
  • Or you can choose package resources into a jar file, say, connection-info.jar, which is included in runtime classpath (not needed in Javac classpath).
    • If your code is like ResourceBundle.getBundle("connection"), then connection-info.jar should contain this entry: connection.properties.
    • If your code is like ResourceBundle.getBundle("com.javahowto.test.connection"), then connection-info.jar should contain this entry: com/javahowto/test/connection.properties.
  • Or you can choose to put the resource in a separate resources directory, include resources directory in runtime classpath. This way you don't have to duplicate the resource in multiple directories/jar. The disadvantage is it's a little inconvenient at development time to have resource in a separate directory than Java code.
    • If your code is like ResourceBundle.getBundle("connection"), then you should have resources/connection.properties.
    • If your code is like ResourceBundle.getBundle("com.javahowto.test.connection"), then you should have resources/com/javahowto/test/connection.properties.

J2ME barcode libraries

available Java ME barcode libraries:
http://sourceforge.net/projects/readbarj/
http://code.google.com/p/zxing/
http://code.google.com/p/zxing/wiki/GetTheReader
http://people.inf.ethz.ch/adelmanr/batoo/index.php
http://code.google.com/p/jjil/
http://code.google.com/p/pp-barcode-reader/

http://www.jappit.com/ - mobile and web blog

articles
http://blog.erikdebruijn.nl/archives/78-Camera-phones-as-barcode-readers-increased-buying-power.html

Saturday, July 25, 2009

java localisation & Internalization

java
http://java.sun.com/docs/books/tutorial/i18n/intro/after.html
http://java.sun.com/docs/books/tutorial/i18n/resbundle/propfile.html
http://www.velocityreviews.com/forums/t153252-resourcebundle-cant-find-properties-file-unless-in-package.html
http://www.rgagnon.com/javadetails/java-0135.html

Wednesday, July 22, 2009

XML Schema

http://www.datypic.com/books/defxmlschema/chapter13.html
http://www.w3schools.com/schema/schema_simple.asp

Tuesday, July 21, 2009

Blog Recommendation

java exception handling

- http://tutorials.jenkov.com/

- http://www.javaworld.com/javaworld/jw-07-2005/jw-0711-exception.html?page=5

static Intialiser
- http://www.developer.com/java/other/article.php/2238491
- http://java.sun.com/docs/books/tutorial/java/javaOO/initial.html