Thursday, August 2, 2012

schedule a job in java code

simple way to schedule a job running periodic


Timer timer = new Timer();
long delay = 10 * 60 * 1000; //10 minutes
timer.schedule(new Task(), 0, delay)



class Task extends TimerTask {

public void run() {
               //do the job
        }
}

send a HTTP Get request by Java


URL stageds2k7 = new URL("http://xxx.stg.yyy.com/ds2k7/services");
URLConnection sc = stageds2k7.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(sc.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
               content.append(inputLine);
// System.out.println(inputLine);
}
in.close();

how to pack a maven jar project with all dependencies and create a executable jar file

first, we need add following plugin into build tag


<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>fully.qualified.MainClass</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

then do following


mvn assembly:assembly
Note that this way is now deprecated. The preferred way is using:
mvn assembly:single

Monday, July 30, 2012

few SAP key words

1)A deferred cost is a cost that occurred in a transaction, but will not be expensed until a future accounting period.
2)A deferred credit could mean money received in advance of it being earned, such as deferred revenue, unearned revenue, or customer advances. A deferred credit could also result from complicated transactions where a credit amount arises, but the amount is not revenue.
3)Deferred revenue is not yet revenue. It is an amount that was received by a company in advance of earning it. The amount unearned (and therefore deferred) as of the date of the financial statements should be reported as a liability. The title of the liability account might be Unearned Revenues or Deferred Revenues.
4)A deferred expense is not yet an expense, even though it has already been paid. The deferred expense is reported on a company’s balance sheet until it becomes an expense in a future accounting period.

Monday, July 16, 2012

Friday, July 6, 2012

maven grail app failed on build

add this env parameter:  MAVEN_OPTS="-Xms256m -Xmx1024m -XX:MaxPermSize=256m"

Tuesday, July 3, 2012

CVS on Cygwin - ": no such repository"


when running cvs from cygwin get error says no such respository
after covert all cvs files format from dos to unix,command will be success.

$ find . \( -name Entries -o -name Root -o -name Repository \) -exec dos2unix {} \;