Friday, March 12, 2010

Can't load PHP's mcrypt extension?

After installing MySQL and PHP, both were working correctly and the only thing missing was to install phpMyAdmin. After downloading and unzipping the installation file I try to access the application through the browser and I get this error:

"Cannot load mcrypt extension"

This can be solved quite easily:

  1. Open your php.ini file (e.g. c://php5/php.ini or c://windows/php.ini)
  2. Find and uncomment "extension=php_mcrypt.dll", save the file.
  3. Copy "libmcrypt.dll" from your php folder to "c://windows"
  4. Restart the server
That's it!

Wednesday, March 10, 2010

How to install PHP 5.2 on Windows 2003 Server with IIS6

Let's skip all the blabbing and  go straight to the content.

Requirements:

1.    Windows 2003 Server
2.    IIS6 Web server
3.    PHP 5.2.13 binaries zip file (Download here)

Installation:

1.    Unzip the content of the zip in the following location "C:\php5"
2.    Copy "C:\php5\php.ini-recommended" to "C:\WINDOWS"
3.    Rename the previous file to "php.ini"
4.    Copy "C:\php5\php5ts.dll" to "C:\WINDOWS\system32"
5.    Open IIS Manager - Expand your server - Right click on "Websites" - Properties - Home Directory - Configuration - Add
6.    Browse and select the file "C:\php5\php5isapi.dll" and set the extension value to ".php" and click "OK"
7.    Now in the same "Websites" properties window, go to the "Documents" tab
8.    Click on "Add" and enter this value "index.php" and move it to the top
9.    Right click on the "Web Service Extensions" and add a new one
10.    Set the extension name to "PHP", then click on "Add" and select the file "C:\php5\php5isapi.dll"
11.    Tick on "Set extension status to Allowed"
12.    Create a text file with the following content " to test our installation:
 <?php phpinfo(); ?>  
13.    Save the file as "index.php" in the following location "C:\inetpub\wwwroot"
14.    Open your internet browser and open "http://localhost" or "http://localhost/index.php"

That should it be it! you should get a PHP info similar to this one:

Monday, March 1, 2010

Useful constants in JavaFX

There are a couple of useful constants in JavaFX that for sure I'll use later in the future, check them out:

__DIR__ 
Dir will return the directory of the currently executed FX source file. A sample of how to use it would be something simple like:
 println("The current directory of this FX file is: {__DIR__});  
The value of this constant may be a jar in case you are executing this from a jar.


__FILE__ 
File is similar to the previous one, the main difference is that it will return the url of the current source file.

__PROFILE__
Profile will have only three values, "mobile","desktop" and "browser" depending on how the script was executed.

Codebase
Using the following code you will get the value of the "codebase" attribute located in the .jnlp file from your application. So in case you .jnpl file goes like this:
 codebase="http://example.sun.com/JavaFX/AppletDeploy/dist/"   
Then you can retrieve the value this way:
 var codebase = FX.getProperty("javafx.application.codebase");  

Wednesday, January 27, 2010

How to clear your browser's JRE cache?

I was just testing a Java Applet on Firefox and noticed that either I had to reload the page a thousand times or restart the browser, obviously this results in wasting a big amount of precious time but fortunately there is an easy way to clear your browser's JRE cache:

1. Open the Java console -> Tools -> Web Developer -> Tools -> Java Console
2. Click on "x" to clear the classloader cache and you will get the following message:

"Clear classloader cache ... completed."

Thursday, January 21, 2010

JavaFX Eclipse plugin error

If you decided to give it a try to JavaFX using Eclipse you may run into your first problem right after installing the JavaFX plugin for Eclipse and it may look like these errors:

Cannot access java.lang.Object class file for java.lang.Object not found
Invalid assignment
Package javafx.scene does not exist
Package javafx.stage does not exist

First of all make sure that you added correctly the JavaFX SDK to your libraries:



If this is correct then take a look at your ".classpath" file and make sure that the JavaFX entry looks like this:

      <classpathentry kind="con" path="com.sun.javafx.eclipse.core.classpath.SDKClasspathContainer"/>  

And not like this:

      <classpathentry kind="con" path="com.sun.javafx.eclipse.core.classpath.SDKClasspathContainer/reserved/desktop"/>  

That fixed it for me ;)

Tuesday, January 12, 2010

Simple Spring 3 tutorial

Here goes a tutorial to get your feet wet with a (really) simple Java Application using the latest version of Spring.

1- Create a simple Java project named "SimpleSpring3"




 2- Create a "lib" in your project right under your "src" folder, then download the latest Spring version and copy the jars to "lib". Also copy "commons-logging.jar" located in the following location "projects/spring-build/lib/ivy" in the unzipped Spring file. Your library should look like this



3- Create a "SimpleSpring3" java class in the "com.greensoft" package, this class will contain one simple "sayHola" method that prints "Hola Spring 3.0!!" in the console




4- Create the Spring config "SimpleSpring3.xml" file located in the "src" folder




5- Add the following code to the Spring config file

 <beans xmlns="http://www.springframework.org/schema/beans"  
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"  
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
      <bean id="SimpleSpring3Bean" class="com.greensoft.SimpleSpring3" />  
 </beans>  

The code in the config file defines a bean that can be accessed later on from our test file using the bean factory

6- Create the test file "SimpleSpring3Test" and the following code

 package com.greensoft;  
 import org.springframework.beans.factory.xml.XmlBeanFactory;  
 import org.springframework.core.io.ClassPathResource;  
 public class SimpleSpring3Test {  
      public static void main(String[] args) {  
           XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(  
           "SimpleSpring3.xml"));  
           SimpleSpring3 simpleSpringBean = (SimpleSpring3) beanFactory  
           .getBean("SimpleSpring3Bean");  
           simpleSpringBean.sayHola();  
      }  
 }  

In the above code we use XmlBeanFactory to get access to our config file "SimpleSpring3.xml" in order to get our "SimpleSpring3Bean" object.

7- The final project structure should look like this



8- Execute the code by right clicking on the test file "SimpleSpring3Test" then --> Run As --> Java Application" and you should get the following output in the console




simple, right? I hope it was useful for someone out there, that's it for now ;)

Sunday, January 10, 2010

Windows Movie Maker app on Linux

I was about to upload a video on YouTube for the first time (ever!) and I noticed that I was missing Movie Maker type of application in Linux,  After searching for a few minutes I found this post about "Top 10 Free Video Editors for Ubuntu Linux", well I decided to try some of them.

if you want a quick recommendation for a simple app, go for Avidemux, in case you are looking for more advanced features go for Cinelarra. Finally Kino maybe somewhere in between.