java coding standards and best practices (2)

18May2010 In: Core Java

1.1 java coding standards and best practices Module Organization

The term module in this context refers to a source file. A source file should contain one public class; it may contain additional non-public classes. So java coding standards is basically refer to java source files. When coding source file is our best practices time(Best practice is to use only one class definition per module.) Read the rest of this entry »

Java coding style guidelines, why need?

17May2010 In: Core Java

 Java coding style to help ensure a uniformly high source code quality, so we always need to review our code keep readable, understandable. clearfully check every lines coding style. this article summarizes why Java coding style and guidelines is so much important?  and next articles we will get some detail rules and guiding principles to archieve this goal. Read the rest of this entry »

How to remotely debug Javascript in IDEA

15May2010 In: Development Tools

Talking about JavaScript debugging, it always, the first idea came to mind is to use firebug, undoubtedly, it’s the primary option for most of people. In this article, we have a new look to remotely debug JavaScript with IDEA, what we do is because we believe its getting benefits from IDEA’s flexibility, extensibility and favorable user faces. Read the rest of this entry »

CXF wsdl2java Ant Task Example

14May2010 In: Web Services

We have two ways to develop a web service, start with the XML Schema/WSDL contract first followed by the Java code second, or start with Java code first followed by WSDL second, however, the recommended way is to use contract-first mode, then translate the WSDL to the the Java stub code by using wsdl2java utility tool. Read the rest of this entry »

How do I Start and Stop Jetty Server from Ant

12May2010 In: Jetty

To start and stop Jetty from Ant command line, we can use the Ant Jetty plugin jetty-ant in the codehouse trunk, it is a new plugin available in the /extras/ant location, which makes it possible to start Jetty web server directly from the Ant build script, and, actually, to embed the Jetty web server inside your build process.
Read the rest of this entry »

Why we need to use Multiple Threads?

12May2010 In: Core Java

Why Use Multiple Threads?

In many situations, having more than one thread running in a program is beneficial. Here’s a more in-depth look at why this can be good.

Better Interaction with the User

If only one thread was available, a program would be able to do only one thing at a time. In the word processor example, how nice it was to be able to open a second document while the first document was being formatted and queued to the printer. Read the rest of this entry »

Golden Rules for Meetings – Getting successful bussiness

10May2010 In: Best Practice

Golden Rules for Meetings

The invitation:

Is this meeting really needed? If not, tell the meeting organizer up front.

Are the right people, and only the right people, invited? If you cannot contribute, decline or leave the meeting once you realize it.

Schedule the meeting to be as possible to maximize efficiency. Read the rest of this entry »

Whats these Time-consuming Operations in java

9May2010 In: Core Java

Read the rest of this entry »

How do I Stop/Suspend a Java Thread

8May2010 In: Core Java

If using methods stop/suspend to stop a thread, this is unsafe and thus deprecated. If a thread being stopped now is modifying common data, that common data remains in an inconsistent state. However, 3 solutions is available as following:

1. let the method run() of the thread finishes itself, it’s best and have no any unsafe factors, for example:

public class OurThread extends Thread(){
  public void run(){

when the console output the string “OK”, this thread ends safely.

2. use a variable indication, in Thread, iterate this variable and check it, e.g while(flag){}, the indication can be modified outside, if it is modified, thread will be ended.

public class OurThread extends Thread(){
  private volatile boolean stop = false;
  public void run(){
    while (!stop) {
    //Do your actions

Set the variable stop to volatile, this make sure all reads and writes will go straight to “main memory”.

3. use interrupt() method and then catch InterruptedException to stop thread.

What Is a Thread?

7May2010 In: Core Java

When a modern operating system wants to start running a program, it creates a new process. A process is a program that is currently executing. Every process has at least one thread running within it. Sometimes threads are referred to as lightweight processes. A thread is a path of code execution through a program, and each thread has its own local variables, program counter (pointer to the current instruction being executed), and lifetime. Most modern operating systems allow more than one thread to be running concurrently within a process. When the Java Virtual Machine (JavaVM, or just VM) is started by the operating system, a new process is created. Within that process, many threads can be spawned (created).  Read the rest of this entry »