Introduction to JAVA threads part 1

Simple java thread example retrieved from IBM developerWorks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class TwoThreads {
    public static class Thread1 extends Thread {
        public void run() {
            System.out.println("A");
            System.out.println("B");
        }
   }

   public static class Thread2 extends Thread {
       public void run() {
          System.out.println("1");
          System.out.println("2");
       }
   }

    public static void main(String[] args) {
        new Thread1().start();
        new Thread2().start();
    }
}

We have no idea in what order the lines will execute, except that “1″ will be printed before “2″ and “A” before “B.” The output could be any one of the following:
Continue reading Introduction to JAVA threads part 1

div in a form or mixing form with div [HTML]

I thought I cant mix between form tag and div tag, I’m talking about HTML. In a basic HTML explanation I thought form tag cant be mixed with other tag than form tag itself. Here’s example of form tag from w3c

1
2
3
4
5
6
7
<form action="form_action.asp" method="get">
  First name: <input name="fname" type="text" />

  Last name: <input name="lname" type="text" />

  <input type="submit" value="Submit" />
</form>

But I come across to this theme and realize its’ form theme doesn’t include a form tag, how could it be… Continue reading div in a form or mixing form with div [HTML]

debugging php in quick and lightweight environment

Sometimes the debugger, xdebug, zend debugger, aren’t working. So instead debugging, we just spend time to debug the debugger itself.
To debug quickly in php we just need to call exit function with variable or any parameter we want. so the script stop and displaying what exactly in the exit parameter.
Example, suppose you want to know what happen with an array so you just type

1
2
3
4
5
<?php
include_once 'some_include.php';

exit("What's this : ".print_r($arr));
?>

that’s all for today.

Simple PHP MySQL Blog Example

OK, this is just one of many PHP ad MySQL implementation, it is my course which I’m taking actually. So in this post is what my lecturer gave to us. Lets dive into our first step. OK, no more talk, lets practice.

Developing a web application based on PHP and MySQL as its database can be done by many tools, you can use EclipsePDT, Adobe® Dreamweaver®, Netbeans, and many more. We ‘ll not cover many PHP IDE feature, so we can focus on simplicity of this tutorial. To proceed to the next step we’ll use these tools:

  • Notepad++ (free text editor with php syntax highlighting)
  • SRWare (free web browser)
  • XAMPP 1.7.3 with PHP 5.3.1 and MySQL 5.1.41
  • This sample database

and now, we can try to cook from some PHP and MySQL, Continue reading Simple PHP MySQL Blog Example

JavaFX is dead?

According to this link Oracle has discontinued further development of JavaFX. Netbeans a free IDE from Oracle, later on its 7 version will not support javaFX, which will be release on march 2011 year based on their roadmap release.

Error preverifying class Preverification failed with error code 1

When I using both netbeans 6.7.1 and 6.9 to create some j2me based apps it’s stop compiling with the error code:

1
2
3
4
5
Preverifying 2 file(s) into E:\Play_On\Java\MyLab\mobileApp\mFaraid3\build\preverified directory.
Error preverifying class mfaraid.faraidMIDlet
java/lang/VerifyError:
E:\Play_On\Java\MyLab\mobileApp\mFaraid3\nbproject\build-impl.xml:470: Preverification failed with error code 1.
BUILD FAILED (total time: 0 seconds)

So I began investigating which is land me on some links, here, here, and here. After a few days of figuring out solution, fortunately my apps built again successfully. It happens when I realize my apps use java native floating point library, and I setting it to run on CLDC 1.0 not CLDC 1.1 which is floating point supported by built-in library.

Here is checklist I try to solve this problem:

  1. Try turning off obfuscation(still got same error).
  2. Lowering obfuscation level (still got similar error).
  3. Go to “Libraries & Resources” and uncheck “Netbeans MIDP Components”. as my apps was trying to use WaitingScreen but I canceled it, the netbeans not automatically uncheck the unused library. (still got similar error).
  4. Checking library used by the apps and matching it to target platform configuration. it was using floating number and java.lang.Math class, and somehow I was unconsciously switching to CLDC 1.0 which’s not support floating number and java.lang.Math class. So I switch back to CLDC 1.1 MIDP 2.0, and it works.

Why netbeans error log not pointing to this matter anyway….?