Monday, September 3, 2012

How to add xml resources in package using maven

By default maven does not include any files from "src/main/java" (${sourceDirectory} variable). You have two possibilities (choose one of them):
  • put all your resource files (different than java files) to "src/main/resources" - recomended
http://stackoverflow.com/questions/9798955/with-maven-clean-package-xml-source-files-are-not-included-in-classpath

Wednesday, May 30, 2012

String pool management summary

package testPackage;
class Test {
public static void main(String[] args) {
String hello = "Hello", lo = "lo";
System.out.print((hello == "Hello") + " ");
System.out.print((Other.hello == hello) + " ");
System.out.print((other.Other.hello == hello) + " ");
System.out.print((hello == ("Hel"+"lo")) + " ");
System.out.print((hello == ("Hel"+lo)) + " ");
System.out.println(hello == ("Hel"+lo).intern());
}
}
class Other { static String hello = "Hello"; }

and the compilation unit:

package other;
public class Other { static String hello = "Hello"; }

produces the output:

true true true true false true

This example illustrates six points:

  • Literal strings within the same class in the same package represent references to the same String object.
  • Literal strings within different classes in the same package represent references to the same String object.
  • Literal strings within different classes in different packages likewise represent references to the same String object.
  • Strings computed by constant expressions are computed at compile time and then treated as if they were literals.
  • Strings computed by concatenation at run time are newly created and therefore distinct.

Wednesday, April 11, 2012

Ant reset property value

Ant works with "first setter wins principle"  Ant properties accept the FIRST setting of the property as the definitive one. Thereafter, future attempts to set the property will be ignored. Properties therefore are not variables, but more like manifest constant definitions.

Monday, March 19, 2012

Jboss Logger

If you want to add a new category to your Jboss Log4j logger, you need to define a log variable in your code like:

>LogFactory.getLog("application-name");

and you should add a new category in jboss-log4j.xml file like:






and may be you can define a appender for log management :









Friday, March 16, 2012

Maven quick tips

mvn ant:ant                     ==> generate build.xml
mvn archtype:generate   ==> generate maven project ---->'generate archtype.goal'
mvn help:effective-pom ==> parent pom included

maven ====> has  3 lifecycle (1=clean 2=default 3=site)
               
clean has 3 phases
                1.1 pre-clean
                1.2 clean
                1.3 post clean

                       
mvn help:system variables can be accessed via ${env.key}

Sunday, March 11, 2012

Oracle XE: Changing the default http port

Need to run following command only:

SQL>connect user/pass@xe

SQL> -- set http port and ftp port
SQL> begin
2 dbms_xdb.sethttpport('80');
3 dbms_xdb.setftpport('2100');
4 end;
5 /

http://daust.blogspot.com/2006/01/xe-changing-default-http-port.html

Friday, March 9, 2012

How to export a schema to local Oracle XE

1-exp sourceUserName/sourcePassword@SID STATISTICS=NONE
2-imp destUsername/destPassword@xe file=expdat.dmp fromuser=sourceUserName TOUSER=destUsername

Change "tnsnames.ora"

Damn. I was trying to upgrade my local 10g XE to 11g. And suddenly I found myself in this situation. I could not change tnsnames.ora file because of a silly privilege. I inspected all the possible processes that might be using this file and googled for half an hour. So the solution is just as easy as right click and add modify privilege to the current user.