Wednesday, January 20, 2010

Increasing Memory For Servers in Netbeans 6.8

A frequent problem that developers working with Java web applications face is running out of heapspace while testing their applications. This is mainly due to the fact that the amount of heap memory reserved by the JVM for the application is quickly consumed by repeated undeploy/deploy cycles. The onmly work around that I know to date is to increase the available heap space. This gives you at least temporary relief since you are only postponing the inevitable out of memory error.

In Netbeans 6.8 it is very simple to increase the memory available for a server.

Step1.
On the Services tab expand the Servers node. Right click on the name of the server that you are using and select Properties.


Figure 1: Selecting Server Properties Window

Step 2
Select the Platform tab and enter the following under VM Options:

-Xms512M -Xmx512M

These options specify that there will be a minimum of 512 MB available for the server and a maximum of 512 MB available. You can of course use different numbers to suit your needs. Other VM Options can be found here.


Figure 2: The VM OPtions for the Server

Now you need to restart the server for the settings to take effect.



Thursday, January 07, 2010

Making 2 jQuery UI DatePickers Interact

Using the jQuery DatePicker is easy and provides a very functional calendar popup. What if you want to have two datepickers but you want the second one to respond to the selections in the first one? So every time you select a date in datepicker1, then datepicker2 immediately selects a date that is 7 days ahead.

Using the built in Date functions in JavaScript you can obtain the Date from the first picker when it is changed and set the date on the second picker after adding the required number of days.

<!DOCTYPE html>
    <html>
        <head>
            <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
            <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
            <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
            <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
            <script type="text/javascript">
           $(document).ready(function(){
              $("#datepicker1").datepicker();
              $("#datepicker2").datepicker();
              $("#datepicker1").change(function() {
              var date2 = $("#datepicker1").datepicker("getDate");
              date2.setDate(date2.getDate()+7);
              $("#datepicker2").datepicker("setDate", date2);
              });
                            });
             </script>
        </head>
         <body style="font-size:62.5%;">

              <div type="text" id="datepicker1"></div>
              <div type="text" id="datepicker2"></div>

          </body>
     </html>