Fun at work!

Archive for the ‘Programming’ Category

Red5 restart failed after upgrading

After upgrading Red5 v.1.0.1 to Red5 v.1.0.5 on CentOS 6.6, starting the service displays OK status but stopping failed. In fact, starting was not successful, thus stopping fails. The main reason it that the latest version requires Java 8 to make it run. After upgrading Java, restarting Red5 works well.



Reference: jQuery

So you want to unlock the power of jQuery to make the web a better place? Awesome, but there are a few things you should know about JavaScript first.

Introduced at the dawn of the web, JavaScript is a powerful and expressive language that runs inside the browser in conjunction with HTML and CSS. Based on an open standard called ECMAScript, JavaScript has quickly become the “programming language of the web.” All the power of jQuery is accessed via JavaScript, so needless to say, it’s an important language to learn. Having a basic knowledge of JavaScript will go a long way in understanding, structuring, and debugging your code.

This guide covers the foundational concepts of JavaScript, as well as frequent pitfalls developers fall into during their first foray into the language. When possible, we’ll relate the JavaScript you learn here to how it’s applied in jQuery.

If you have experience with other programming languages, good for you! If not, don’t worry. We’ll take it slow and teach you everything you need to know to unlock the power of jQuery with JavaScript.

Go to site…

Reference: Knockout JavaScript

Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and maintainably.

Go to site…


Repost: How to Sign a JAR File

Repost: How to Sign a JAR File

When JAR files need to be downloaded as part of a Java applet or Webstart deployment it is best to digitally sign the JAR files.

Signing with a Test Certificate

1. Make sure that you have a Java SDK keytool and jarsigner in your path. These tools are located in the Java SDK bin directory.

2. Create a new key in a new keystore as follows:

  keytool -genkey -keystore myKeystore -alias myself

You will be prompted for information regarding the new key, such as password, name, etc. This will create the myKeystore file on disk.

3. Then create a self-signed test certificate as follows:

  keytool -selfcert -alias myself -keystore myKeystore

This will prompt you for a password. Generating the certificate may take a few minutes.

4. Check to make sure that everything is okay. To list the contents of the keystore, use this command:

  keytool -list -keystore myKeystore

It should list something like:

  Keystore type: jks
  Keystore provider: SUN

  Your keystore contains 1 entry:
  myself, Tue Jan 23 19:29:32 PST 2001, keyEntry,
  Certificate fingerprint (MD5):

5. Finally, sign the JAR file with the test certificate as follows:

  jarsigner -keystore myKeystore test.jar myself

6. Repeat these steps for all your JAR files.

Note that a self-signed test certificate should only be used for internal testing, since it does not guarantee the identity of the user and therefore cannot be trusted. A trustworthy certificate can be obtained from a certificate authority, such as VeriSign orThawte, and should be used when the application is put into production

Make sure you add the following tag to your .jnlp file:


Repost: Component Life Cycle in Flex

Repost: Component Life Cycle in Flex

These are the series of methods that are called by Flex Framework for all components:
  1. As the component is going to be in a container, the parent property of the component will be referred to the container.
  2. Component’s Constructor:
    • Setup initial properties and do tasks that are not related to display of UI or not.
    • Don’t create child components or position items.
    • Constructor is called when component is created but the other lifecycle methods don’t occur until a component is added to a container.
  3. Gets the Style setting of the component.
  4. preInitialize event on the component
    • UIComponent is in a very basic stage with no children added at this time.
  5. createChildren() method is called.
    • Creates visual children of the component.
    • Flex doesn’t size or position them at this point because it doesn’t know how much screen space it has.
  6. initialize event is dispatched by the component –
    • All the component’s children are initialized.
  7. commitProperties() method
    • Is responsible to coordinate property modifications.
    • This is needed when there are multiple properties that should be set before you take action.
    • This is called when selectedIndex or selectedChild is called
    • Can be called by calling invalidateProperties(). Each time this method is called commitProperties() is scheduled to be called next time there is a screen repaint or refresh.
  8. measure() method is called only if explicit height and width is not set in the code
    • Flex calls this method to determine how much screen size a component requires.
    • This is not called when the height and width are explicitly set in the code as flex knows offhand how much screen size it will take.
    • This method sets these four properties (or you can set it)
      • measuredMinWidth
      • measuredMinHeight
      • measuredWidth
      • measuredHeight
    • LayoutManager also gets started at this point as layour manager starts with the outermost component and to size the outer most component it should know the size of its children.
    • Can be called by calling invalidateSize(). Each time this method is called measure() is scheduled to called next time there is a screen refresh.
  9. updateDisplayList() method is called
    • Is responsible for positioning of children. You can specify your children here
    • It is passed two paramters
      • unscaledWidth
      • unscaledHeight
    • Flex containers choose never to size one of their children smaller than minimum size but you can choose to override it.
    • Can be called by calling invalidateDisplayList(). Each time this method is called updateDisplayList() is scheduled to be called next time there is a screen refresh.
  10. Dispatches creationComplete event.

How to install marketplace on Eclipse Indigo?

By default, market place in Eclipse Indigo Classic Version is not available.  The steps below will help you install it.

  1. Go to “Help”, then select “Install New Software…”.
  2. In the “Work with:” drop down menu, select ” Indigo – “. If not available, add the Eclipse Indigo download site with this URL – “
  3. On the category list, expand the “General Purpose Tools”, select “Marketplace Client” and follow the installation procedure.
  4. After finish installation, restart Eclipse and you can find “Eclipse Marketplace…” under the “Help” menu. Done.

Below the screenshot of the “Install New Software” dialog  box.


How to install Apache ANT on Windows 7?

Apache Ant is a Java library and command-line tool that help building software. Here’s how to install Apache ANT on Windows 7.

1. Download the latest ANT zip archive at
2. Unzip the package and rename the folder to “ant”.
3. Copy the “ant” folder to the desired location, say at the root of drive D.
4. Run the command prompt as Administrator and set the environmental variables for ANT and JAVA (Note: Set ANT_HOME to the uncompressed ant folder and JAVA_HOME to the Java JDK folder. If JAVA_HOME is incorrectly set, ANT cannot locate the needed tools.jar) as follows:

set ANT_HOME=D:\ant
set JAVA_HOME=D:\Program Files\Java\jdk1.7.0_09
set PATH=%PATH%;%ANT_HOME%\bin

5. Check whether ANT works correctly or not by using the command prompt.

ant -version

6. You’re done if you see the ANT version.

Screenshot of the example:


How to display line numbers in Eclipse IDE?

By default, Eclipse’s editor does not display line numbers. Follow this simple guide to enable “Show line numbers”:

In Eclipse IDE, go to Window>Preference>General>Editors>Text Editors, and check Show line numbers. See screenshot below.

Eclipse Display Line Number

Updating the Adobe playerglobal.swc

When I was building the red5sip package on FlashBuilder 4.6, I got the following errors:

1046: Type was not found or was not a compile-time constant: MicrophoneEnhancedOptions. PhoneCanvas.mxml  /red5sip/src    line 158    Flex Problem 
1061: Call to a possibly undefined method getEnhancedMicrophone through a reference with static type Class. PhoneCanvas.mxml    /red5sip/src    line 157    Flex Problem 
1119: Access of possibly undefined property codec through a reference with static type    PhoneCanvas.mxml    /red5sip/src    line 146    Flex Problem 
1120: Access of undefined property MicrophoneEnhancedMode. PhoneCanvas.mxml /red5sip/src    line 159    Flex Problem 1180: Call to a possibly undefined method MicrophoneEnhancedOptions.    PhoneCanvas.mxml    /red5sip/src    line 158    Flex Problem


To solve the problem, the latest version of “playerglobal.swc” must be used. Here are the steps to do this:

1. Download the latest version of “playerglobal.swc” from Adobe here. The latest version as of this writing is “playerglobal11_7.swc”.

2. Create a folder using the version number under “[Flex-SDK-Home]\frameworks\libs\player\[version].” Here version should  be “11”.

3. Copy the file to this folder, and change the filename to “playerglobal.swc”.

4. On the Flash Builder, go to “Project” menu, then open up “Properties”. On the left pane, select “Flex Compiler”. On the right side, you can find “Adobe Flash Player options”. Select “Use a specific version” and input the version of latest  “playerglobal.swc”. Click “Apply”, then “OK”.

5. Now clean and build the project. Done.

How to add older Flex SDKs to Flash Builder 4.6?

Steps in adding older Flex SDK to Flash Builder 4.6.

1. Download the Flex SDK from here.

2. Extract the SDK zip package to the Adobe Flash Builder SDKs folder. Conventionally, it is located in C:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\ for Windows.

3. On the FB 4.6 IDE, go to “Windows” and open up “Preferences”. On the left pane, expand the “Flash Builder” menu, and select “Installed Flex SDKs”. Now on the right, click “Add” and browse for the SDK folder you copied in step 3. A name for this SDK will be automatically displayed.

4. Now you should have new SDK listed as Installed Flex SDKs. Check the newly added SDK and click Apply.

5. Done.

Tag Cloud