Setting http Proxy for Java Application

There are 2 main ways to set/configure http proxy in your java application.

  • As a command line option when invoking the VM
  • Using the System.setProperty(String, String) in your code

There are 3 properties you can set to specify the proxy that will be used by the http protocol handler:

  • http.proxyHost: the host name of the proxy server
  • http.proxyPort: the port number, the default value being 80
  • http.nonProxyHosts: a list of hosts that should be reached directly, bypassing the proxy

Example of using command line option to set proxy configuration on java
java -Dhttp.proxyPort=8080
-Dhttp.noProxyHosts=”localhost|” YourAppMainClass

Example of using code to configure proxy setting on java
//Set the http proxy to
System.setProperty("http.proxyHost", "");
System.setPropery("http.proxyPort", "8080");
// Next connection will be through proxy.

There are other proxy settings that you can set as well such as https, ftp, socks.
More resources:

Lenovo SL500 continuous noisy loud fan after booting

I have just updated my Lenovo SL500 bios which ship with 1.07 bios version to the latest flash available on Lenovo support website that is v1.18. The update was smooth and the good news is I can switch off the Bluetooth by using Fn+F5 and it will keep the state when you reboot your laptop. It also keep the state of your screen brightness the next time you reboot in Windows XP. However, I didn’t realize that I have created big mess with the fan until recently.

I guess there is a bug on this new bios version relating to your fan speed control. The symptoms are if you have bios version 1.18 and you plug out the battery, few seconds after booting your laptop fan will go berserk creating high level of noise and air flow on the side of your laptop. By the way, when I use the battery with or without the main A/C adapter, it runs smoothly.

Well this is real bad situation for me, as I love to plug out my battery when I am not using it to prolong its life. Secondly, the fan noise is so disturbing so that you are barely can enjoy listening your music or watching movies.

What can we learn from this? Do not update if you live happily with your current system and do not need those extra feature which you can get from the new version. There are also some applications out there that I am aware of to control your laptop fan speed, but I strongly suggest to downgrade your bios to v1.16. Bios v1.14 and v1.16 are free from this loud fan bug. You can download this bios from lenovo support website and please select bootable cd method (it’s quicker and saver). Last word, Lenovo as a durable and business standard laptop provider should have published bug free drivers and software.

What’s new in ZenCart 2.0.0

After a long time waiting, Zencart team will release the new Zen Cart v2.0.0. It was originally planned to be released at the end of 2008 but they will most likely to release the upcoming Zencart 2.0 release early this year. The following will cover what you can expect from new Zencart 2.0.0, which is a summary of what I got from Zencart forum (Comming soon Zencart 2.0.0).

An emphasis has been placed on improving performance by various methods, especially reducing the number of database queries required for processing pages.

For the programmers, you’ll be happy to know that the code has been largely converted to a much more efficient OOP structure, which will ultimately end up making future growth much simpler.

Templating is much simpler, in that the complicated PHP blocks that used to make them so hard to read or follow or customize have been removed. Stylesheets are leaner. And there are some very easy-to-use admin-side layout controls to make setting your desired layouts *much* simpler.

The same override system exists for templates and language files, meaning that those already familiar with that part of the directory structure will find it easy to continue using.

UTF-8 support is now native, and the more complicated language files have been simplified and split off into their own for easier management.

Written for PHP 5
Zen Cart 2.0 takes advantage of features specific to PHP 5.2 and MySQL 4.1, thus, those are the new minimum requirements for your hosting service to provide in order to run it. CURL is also highly recommended.

And Many More…

It’s time to move our system from Zencart 1.3.8 to Zencart 2.0.0 and for those who are planning to customize Zencart system, I would just recommend you to postpone it. So that you can implement the changes in Zencart 2.0.0 directly to reduce overhead cost.

Error Install MS SQL Server Express in Windows XP SP3 / MSXML6 SP2

If you are trying to install SQL Server 2005 Express edition in Windows SP3 environment, it will most likely fail unless Microsoft has done something to fix this. Read through this blog to find how to get around with this issue.

Symptoms include SQL Server Express edition installation return error and the error log mentioned MSXML 6 Service Pack 2 (KB954459) — Configuration failed. I am not really sure what the root cause is, but it looks like Windows XP SP3 or MSXML 6 Service Pack 2 protects the MSXML 6 configuration file from update and changes. As a result, the setup fail to continue.

There are some ways to solve this, including

  • Uninstall Service Pack 3, install Microsoft SQL Server Express edition, and reinstall SP3.
  • Disable the File system protection temporarily using regedit.

But, in my opinion the best way is

Hope this post may help more people. I have received much gratitude from visitors all around the world regarding this post. Please continue to spread this post and share the good via bookmark. Cheers

Backup & Migration Microsoft Office Outlook to New system

If you have just bought new computer or reinstall your old machine and want to replicate your Microsoft Outlook profiles to the new system, this blog can answer your questions. This guide is based on my experience on Microsoft Office Outlook 2007.

First of all, there is no easy way to do this. I am amazed that Outlook 2007 does not provide account setting export tools. Thus, I believe that this is the simplest way to migrate your outlook to new system. Please be aware that you have to backup your old Microsoft Outlook before removing it and use this guide at your own risk.

  1. Backup your data from your old Outlook. There are several settings and data that you can export from your Outlook. I would recommend to copy your PST files and Outlook settings files. Guides to do this is available from Microsoft website;en-us;Q196492
  2. Install Microsoft Outlook in the new system
  3. Open Outlook and setup your email accounts as in your old system (yes you have to reenter every username, password, or even setup SMTP URL and port for advanced settings)
  4. By now you should already have the same account settings and Mail folders structure in your Outlook
  5. Finally, you can import your PST files from old system to your new Outlook. Select File > Import and export. Go through the wizard by opting to import PST files and in the final step choose the same folders for Import Items location

Please leave a comment if you need further guides or just to say thank you.

Fix No Bootable Partition in Table at start up

For the last 2 days in my Christmas holiday, I have struggled to accomplish one of my ambition that is having three operating systems dwell inside my new laptop. XP, Vista, and Ubuntu that was the most ideal installation sequence if you want turn your PC into triple boot device, but that is not an option in my case. My laptop come preinstalled with Vista and the stupid product recovery discs will erase all partitions, turn it back into Vista brick. At one point, I face this blank black screen with a message “No Bootable Partition In Table” when I try to boot the laptop.

How to fix this “No Bootable Partition Table” ? If your PC produce this kind of weird message, big chance you have modified your Master Boot Record (MBR) or your PC can’t find one. You don’t need to understand what is this, but it is record on your hard drive that contains boot instruction. These are options that you can do to fix this.

Have a look if you get the right device to boot. New Computers today are capable to boot from numerous devices including CD/DVD drive and Flash Drive/USB devices apart from HDD. if your computer try to boot from flash drive / disc without any master boot record, it will throw this error message. Try to remove any USB devices and CD/DVD from your PC. Try to make sure the boot sequence point to your HDD first in BIOS setting.

If the first step does not solve any problem, you have to recover, restore, or create new MBR by using your operating system disc. This task can be daunting for some people, you may want to get IT Savvy to get this done for you.
Windows Vista installation DVD can be used to fix master boot record of your Vista installation. Other option is installing other boot manager such as GRUB which is used by Linux Ubuntu. You can google “Fix master boot record” to get into detail of this.

How to Locate, search, find file via Linux terminal (Ubuntu)

I have been using Linux especially Ultimate Ubuntu (really cool Ubuntu distribution) for a while and I think I will share this basic tutorial series on Linux shell commands.

One of the crucial functions that we need on every system is how to search and find. To Locate file in Linux my favourite command is “Locate” which can be run via terminal (some sort of command prompt in Linux). Open your terminal (in Ubuntu it will be Applications → Accessories → Terminal) and type in the following commands.

sudo updatedb

Updatedb creates or updates a database used by locate. If the
database already exists, its data is reused to avoid rereading directories that have not changed. Locate will find files which match your pattern and display the list (for example: locate, locate *.mp3, locate lib*, etc.).

You should not execute “updatedb” everytime you need to find file, but if you have just installed, or added new files to your system then you will need “updatedb” to includes these files on your search.

To get more information, read the manual of Locate and Updatedb by executing “man COMMAND_NAME”. For examples:

man updatedb
man locate

(use arrows to scroll and type ‘q’ to exit)

Add custom Admin configuration field setting for Zencart

Have you created your own module for Zencart? And you would like to add configuration setting for your module, so that your client can configure your module via Admin area? Here is how to do that…

What I do usually is adding new group (with your module name) under Configuration in zencart administrator, then add fields under that group to be setup. Just like if you go to Configuration > My Store, you will find many settings there. All of this fields are declared inside your database, specifically inside zen_configuration_group and zen_configuration table (NB: zen_ is used as table prefix).

So let’s insert new row to your zen_configuration_group to create new group under “Configuration” menu. The following SQL script will add “My New Module” group under “Configuration” menu and position it in the last order. Use this script as template.

INSERT INTO configuration_group
(configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible)
VALUES (NULL, 'My New Module', 'My New Module Description....', '1', '1');
UPDATE configuration_group SET sort_order = last_insert_id() WHERE configuration_group_id = last_insert_id();

Secondly, to add config items under your new “Configuration > My New Module” use the following SQL

SET @last_id=0;
SELECT (@last_id:=configuration_group_id) AS last_id 
FROM configuration_group
WHERE configuration_group_title= 'My New Module';
INSERT INTO configuration 
(configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added)
('', 'Small Image Height', 'IMAGE_VIEWER_SMALL_IMAGE_HEIGHT','75','Description of Small Image Height Setting. Default 75.', @last_id, 1, now());

Note that to run this SQL smoothly without bothering with your zencart database table prefix, execute this script from zencart admin area Tools > Install SQL Patches.

Once you executed those SQL, you will find My New Module category under Configuration menu and Small Image Height setting inside that category. You can then access the value of this configuration from your module straight away by using configuration_key which you have set in your SQL (i.e. echo IMAGE_VIEWER_SMALL_IMAGE_HEIGHT). Please leave comment if you find any difficulties or feel grateful with this blog. Cheers.

Send HTML Newsletter Email to Admin Zencart 1.3.8

In my last project, I designed new newsletter template and created custom newsletter administration area. When I send newsletter to admin to test the email, it does not send HTML email but plain text mail. Scratching my head, I searched Zencart documentation as well as Google for couple hours to find the answer. Now, I will share the solution here, just in case you go through the same pain as me.

First of all, you need to configure your Zencart to use HTML type email. Login to your administrator area and go to configuration > E-mail options.

  1. Make sure your “E-Mail Transport Method” is set appropriately
  2. Use MIME HTML When Sending Emails = “true”
  3. Send E-Mails = true
  4. Email Admin Format? = HTML

Now try to send a newsletter to the admin, if it still sends plain text mail, do the following. Backup and open in your text editor includes/functions/functions_email.php. In your functions_email.php try to find these codes

if (ADMIN_EXTRA_EMAIL_FORMAT == 'TEXT' && substr($module,-6)=='_extra') {
        $email_html='';  // just blank out the html portion if admin has selected text-only

Just below that add the following codes

// if no customer email record found, and admin email format is set to HTML, and sending newsletter, and admin is logged in, use HTML:
if ($customers_email_format_read->RecordCount() == 0 && ADMIN_EXTRA_EMAIL_FORMAT == 'HTML' && in_array($module, array('newsletters', 'product_notification')) && isset($_SESSION['admin_id'])) {
     $customers_email_format = 'HTML';

Now, you should send email in HTML format. Leave comment if it does not work for you or if this post has helped you and save your time.

Add Start and End Date limit Joomla 1.5 Banners

On my recent project which uses Joomla v1.5, my client asks for banner management with ability to manage banner based on number of impression or date (period of time). Quick search on Joomla extension repositories show that there are many banner management component and module for Joomla 1.0 but not Joomla 1.5. Most of them which run on 1.5 are module to add animation or customize the display of your banner. At the time I write this blog, I found one component which does this, but it’s fairly plain and does not allow me to limit the banner based on number of impression made, categorize my banners, and keep track of clients.

Fortunately, the default Joomla 1.5 comes with com_banners and mod_banners core component and it has everything I need except start and end date setting to publish banner/ads. So let’s modify this core component to add this feature.

There are two files that you need to edit. First, open up \administrator\components\com_banners\views\banner.php with your favourite editor. Then insert the following codes on line 347 (between </tr> and <tr>).

<?php // BEGIN EDIT - Enable Start and End Date of Banner
	function formatToShortDate($date) {
		$date = substr($date,0,10);
		if ($date == '0000-00-00') return "";
		return $date;
		<td class="key">
			<?php echo JText::_( 'Start Date' ); ?>
	  <?php echo JHTML::_('calendar', formatToShortDate($row->publish_up) , 'publish_up', 'publish_up', '%Y-%m-%d', array('class'=>'inputbox', 'size'=>'25',  'maxlength'=>'19')); ?></td>		
		<td class="key">
			<?php echo JText::_( 'End Date' ); ?>
	  <?php echo JHTML::_('calendar', formatToShortDate($row->publish_down) , 'publish_down', 'publish_down', '%Y-%m-%d', array('class'=>'inputbox', 'size'=>'25',  'maxlength'=>'19')); ?></td>		
	// END EDIT - Enable Start and End Date of Banner

Secondly, locate and edit \components\com_banners\models\banner.php.
Try to find this line $wheres[] = ‘(imptotal = 0 OR impmade < imptotal)’;. On my file it’s located on line number 41, and below that add the following code:

// BEGIN EDIT - Enable Start and End Date of Banner
$wheres[] = "(publish_up = '0000-00-00 00:00:00' OR publish_up <= CURDATE())";
$wheres[] = "(publish_down = '0000-00-00 00:00:00' OR publish_down >= CURDATE())";
// END EDIT - Enable Start and End Date of Banner

It’s done. Now you will have start and end date field when you create new or edit your banners. The mod_banners will only display ads/banners which sit after the start date (if set) and before the end date (if set). You can leave start and end date field empty to ignore them. Please leave comments if you are satisfied or face any problem. Cheers.