How to set java heap size in JavaEE SDK/J2EE SDK/Glassfish/Sun Java System Application Server

Stop the application server, edit
$GLASSFISH_HOME/domains/domain1/config/domain.xml, search for XML element name java-config and jvm-options. For example,

You can also change these settings in the web-based admin console, typically at http://localhost:4848/, or https://localhost:4848/. Go to Application Server near the top of the left panel, and then on the right panel, click JVM Settings -> JVM Options, and you will see a list of existing JVM options. You can add new ones and modify existing ones there.

Yet another option is to use its Command Line Interface (CLI) tool command, such as:
./asadmin help create-jvm-options
./asadmin help delete-jvm-options
They may be a bit hard to use manually, but are well suited for automated scripts.

How to set java heap size in jEdit?

jEdit is a java application, and basically you need to set minimum/maximum heap size JVM options when you run java command. jEdit by default runs with a default maximum heap size 64m. When you work on large files, you are likely to get these errors:
java.lang.OutOfMemoryError: Java heap space
at java.lang.String.concat(
at org.gjt.sp.jedit.buffer.UndoManager.contentInserted(
at org.gjt.sp.jedit.Buffer.insert(
at org.gjt.sp.jedit.textarea.JEditTextArea.setSelectedText(
at org.gjt.sp.jedit.textarea.JEditTextArea.setSelectedText(
at org.gjt.sp.jedit.Registers.paste(

How to fix it? If you click a desktop icon, or Start menu item to start jEdit: right-click the icon or menu item, view its property, and you can see its target is something like:
C:\jdk6\bin\javaw.exe -jar "C:\jedit\jedit.jar"
You can change that line to:
C:\jdk6\bin\javaw.exe -Xmx128m -Xms128m -jar "C:\jedit\jedit.jar"
If you run a script to start jEdit: just add these JVM options to the java line inside the script file:
java -Xmx128m -Xms128m -jar jedit.jar
If you start jEdit by running java command: just add these JVM options to your java command:
java -Xmx128m -Xms128m -jar jedit.jar
Note that when you run java with -jar option, anything after -jar jar-file will be treated as application arguments. So you should always put JVM options before -jar. Otherwise, you will get error:
C:\jedit>java -jar jedit.jar -Xmx128m
Unknown option: -Xmx128m
Usage: jedit [] []

How to set java heap size in Apache Ant

Set environment variable ANT_OPTS. Look at the file $ANT_HOME/bin/ant or %ANT_HOME%\bin\ant.bat, for how this variable is used by Ant runtime.
set ANT_OPTS=-Xms512m -Xmx512m  (Windows)
export ANT_OPTS="-Xms512m -Xmx512m"  (ksh/bash)
setenv ANT_OPTS "-Xms512m -Xmx512m"  (tcsh/csh)

java.lang.OutOfMemoryError: Java heap space Error in JVM

 Heap size is larger than your computer's physical memory. For example,

java -Xmx2g BigAppError occurred during initialization of VMCould not reserve enough space for object heapCould not create the Java virtual machine.
The fix is to make it lower than the physical memory: java -Xmx1g BigApp

Incorrectly use mb as the unit, where m or M should be used instead.

java -Xms256mb -Xmx256mb BigAppInvalid initial heap size: -Xms256mbCould not create the Java virtual machine.
The heap size is larger than JVM thinks you would ever need. For example,

java -Xmx256g BigAppInvalid maximum heap size: -Xmx256gThe specified size exceeds the maximum representable size.Could not create the Java virtual machine.
The fix is to lower it to a reasonable value: java -Xmx256m BigApp

The value is not expressed in whole number. For example,

java -Xmx0.9g BigAppInvalid maximum heap size: -Xmx0.9gCould not create the Java virtual machine.
The correct command should be java -Xmx928m BigApp

How to set java heap size in NetBeans?

Open the configuration file etc/netbeans.conf (in the directory where NetBeans is installed) in a text editor and modify the options in netbeans_default_options setting. You can change or add following options: -J-Xmx... (e.g. -J-Xmx256m) or -J-XX:MaxPermSize=... (e.g. -J-XX:MaxPermSize=96m). Save the file and restart the IDE.
Bear in mind that UI responsiveness may be affected when the heap utilization gets close to its limit. Should you encounter an OutOfMemoryError, you need to increase Xmx or XX:MaxPermSize back to the default, or even higher.
NetBeans 6.x
Since NetBeans version 6.0, the default limit for heap size (-J-Xmx) is determined automatically, with respect to the amount of memory available on the system. There is no -J-Xmx option specified in netbeans.conf. However, if you specify the heap size limit (i.e. you add the -J-Xmx... option to netbeans.conf), then the limit given by you will be respected.
Similarly when running on a machine with more memory it might be useful to increase the maximum size of the heap, especially when working with larger projects.

How to set java heap size in Eclipse?

You have 2 options:
1. Edit eclipse-home/eclipse.ini to be something like the following and restart Eclipse.
2. Or, you can just run eclipse command with additional options at the very end. Anything after -vmargs will be treated as JVM options and passed directly to the JVM. JVM options specified in the command line this way will always override those in eclipse.ini. For example,
eclipse -vmargs -Xms64m -Xmx256m

How do I increase the heap size available to Eclipse?

Some JVMs put restrictions on the total amount of memory available on the heap. If you are getting OutOfMemoryErrors while running Eclipse, the VM can be told to let the heap grow to a larger amount by passing the -vmargs command to the Eclipse launcher. For example, the following command would run Eclipse with a heap size of 256MB

eclipse [normal arguments] -vmargs -Xmx256M [more VM args]
The arguments after -vmargs are directly passed to the VM. Run java -X for the list of options your VM accepts. Options starting with -X are implementation-specific and may not be applicable to all VMs.
You can also put the extra options in eclipse.ini.
Here is an example;
-startup plugins/org.eclipse.equinox.launcher_1.0.100.v20080501.jar --launcher.library plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.0.100.v20080428-1330 -showsplash org.eclipse.platform -vm /usr/lib/jvm/java-1.5.0-sun/jre/bin/java -vmargs -Xms512m -Xmx1024m -XX:+UseParallelGC -XX:PermSize=256M -XX:MaxPermSize=512M

Oracle Apps:Report Layout: Conditional Formatting

About conditional formatting

It is often useful to highlight certain parts of your report when particular conditions are met. For example, you can change the color of a value to red when it is greater than 5000. Report Builder provides two ways of adding conditional formatting to your report:

The Conditional Formatting and Format Exception dialog boxes lets you specify multiple conditions and formatting attributes (font, text color, border, and fill color) for a selected layout object. You don't write any code with this method.

The Format Trigger property allows you to code your own PL/SQL functions to perform conditional formatting. Because you write the code yourself, you have more flexibility and complete control when compared to using the Conditional Formatting and Format Exception dialog boxes alone.

For many conditions, you often can do what you need using the Conditional Formatting and Format Exception dialog boxes. For other conditions, you may want to use the dialog boxes to get started, and then modify the generated code by editing the Format Triggers.

To apply conditional formatting to a layout object:
1        Click the object, and then choose Format Conditional Formatting.  Tip
2        In the Conditional Formatting dialog box, click New to display the Format Exception dialog box.
3        Specify the conditions and formatting attributes to be applied when the condition(s) evaluate to TRUE.
4        Click OK.

Using the Conditional Formatting and Format Exception dialog boxes, you can specify output formatting attributes (font and/or color) for a selected layout object based on conditions that exist.  The conditions that you define are called format exceptions.
You can display the Conditional Formatting dialog box from the Live Previewer view or Layout Model view in any of the following ways:

  • Double-click the object to display the Property Palette.  Under the General Layout node, click the Conditional Formatting value field (labeled ¼).
  • Display the pop-up menu (right-click in Windows) for the object.
  • Click the object, then choose FormatConditional Formatting.
After you specify conditions and formatting for the current layout object in the Format Exception dialog box, the entire definition is exported to a PL/SQL format trigger automatically.

In the below screen shot, you can see that we are hiding an object based on certain condition.
(:sal Between '100' and '1000')

After creating a format exception in conditional formatting dialog box, a piece of code will be automatically generated in the format trigger of that object. 

function F_SalFormatTrigger return boolean is

  -- Automatically Generated from Report Builder.
  if (:sal BETWEEN '100' and '1000')
    return (FALSE);
  end if;

  return (TRUE);

If a format trigger already exists for the layout object, the definition in the Format Exception dialog box overwrites the existing trigger code when you confirm the Report Builder prompt.

You can edit the format trigger manually via the PL/SQL Editor; however, if you subsequently modify the definition using the Format Exception dialog box, Report Builder displays a prompt to overwrite the existing format trigger.

Installing SQL Server 2005 for use with WebSphere Portal.

This section provides information on how to install SQL Server 2005 for use with WebSphere Portal.
Before you begin this task, complete the following prerequisites:
  • You should have completed reviewing the Planning for SQL Server 2005 topic.
  • You must install SQL Server 2005 separately from WebSphere Portal.
  • WebSphere Portal requires Microsoft® SQL Server Enterprise Edition 2005 Service Pack 2
  • WebSphere Portal requires either the DataDirect Connect for JDBC 3.7 JDBC driver or the Microsoft SQL Server 2005 JDBC Driver.
    • You can obtain the DataDirect Driver from DataDirect Technologies. The JDBC driver consists of two parts: the JDBC driver libraries and JTA libraries. The JDBC driver libraries must be put on the WebSphere Portal system, while the JTA libraries are intended for SQL Server 2005.
    • You can obtain the Microsoft SQL Server 2005 JDBC Driver from Microsoft. See the Microsoft SQL Server product documentation for installation details
The following section provides instructions for installing SQL Server 2005 for use with IBM® WebSphere® Application Server and WebSphere Portal. These steps are the same for both the DataDirect and Microsoft drivers unless noted.
  1. Install SQL Server 2005 and all required patches.
  2. Select SQL Server Authentication as the authentication mode during the installation.
  3. Complete the installation using SQL Server documentation as a guide.
  4. Enable TCP/IP connectivity in the SQL Server Configuration Manager.
  5. Install the JDBC driver using one of these methods:
    • Installing DataDirect Connect for JDBC drivers on UNIX
    • Installing DataDirect Connect for JDBC drivers on Windows
    • Installing Microsoft SQL Server 2005 JDBC drivers and enabling XA connections
  6. Network the connections for MSDTC in the Windows Component Services as described in Microsoft Help and Support.
  7. Start SQL Server 2005.
Check the Steps For Installation here 

Source :IBM

ApacheTomcat PerformanceTuning, with Timeouts and Thread Settings

The maximum number of threads should also be tweaked to suit the application load profile. If the application has high CPU usage set the max threads lower as Tomcat will accept connections but the CPU will be unable to service them. If CPU utilisation is low this can be set higher.  For the blocking io connector, maxThreads is the maximum number of concurrent connections that can be accepted, for the APR connector this is limited by available memory.

It is not possible to give any hard and fast rules when it comes to performance tuning though as it is highly dependent on your load profile, even in the case of a common load profile you will need to see what works in practice.

Tomcat Connector Implementations

In general the APR (Apache Portable Runtime) library is the most efficient connector, as it is a non-blocking C implementation. The Java based, blocking IO implementation, know as Cototye, is considered more stable, but due to its blocking nature is usually not great for high traffic sites. The NIO (New IO) implementation is generally not used, unless you don't have access to the APR library. Tomcat comes with the blocking IO implementation by default.
Once you have chosen the best library to use you can then start tweaking the timeout and keep alive request settings in sever.xml. The general rule of thumb is that for high concurrency sites without SSL use low time outs and keep-alive requests setting and for low concurrency sites or sites with SSL set the time outs  and max requests higher. You should always change the default time out of 20 seconds on the HTTP connector to a lower value.
When using AJP you should set the keep-alive and timeouts to off as usually the web server and Tomcat are on the same machine, making the time to set up and create connections between the two almost irrelevant. Also use Apache to do the SSL in this case and not Tomcat!

Tomcat Performance and Tomcat Connectors

if you are looking to squeeze some extra performance out of Tomcat  one of the places to look is at the connectors and their settings. Connectors are the mean by which external applications gain access to the output of Tomcat's servlet (Catalina) and JSP(Jasper) engines. By default Tomcat comes with two connectors already setup, the HTTP connector on port 8080 and the AJP connector on port 8009.
AJP is a binary protocol that should be faster for front-end web servers to access than verbose text based protocols such as HTTP. It is really intended for binary access to Tomcat by web servers such as Apache HTTP. The AJP connector is different to the HTTP connector in that there are two places to tune the settings. Both the HTTP and AJP connector can be tune in server.xml, but the AJP connector can also be tune in apache.conf for example. These are the "client" setting for the AJP connector such as mod_jk and mod_proxy.
Just to confuse issues, Tomcat has three implementations of connectors that implement the HTTP and AJP protocol. In fact there seems to be multiple uses of the term "connectors" in Tomcat documentation. A connector is both a port and protocol, as well as a code library that implements the connectors. So besides changing the settings for a connector you also need to choose the most appropriate implementation.

Apache Tomcat Performance Tuning

The proper Tomcat JVM configuration is essential for getting the most out of your server.  
Before you start changing any settings, you should make sure that you have chosen the most logical JVM for your site's needs.  There are a growing number of JVM vendors, and if you do not require any JDK-specific functionality, it is a good idea to run some benchmarks and see which solution gives you the best performance.  Also, make sure to upgrade to the latest stable release of your JVM, as this may give you a sizable performance boost right away. 
Next, consider experimenting with your JVM threading configuration.  If your JVM supports both green and native threads, you should try both models to determine the best choice for your site.  If you are running I/O bound applications, the native thread model should offer you improved performance.  However, green threads will decrease the load placed on your machine.  If you are unsure which option to choose, native threads are usually a good choice.
Certain JVM processes, such as garbage collection and memory reallocation, can be a drain on your server.  You can reduce the frequency with which these processes occur by using the -Xmx and -Xms switches to control how JVM handles its heap memory.
JVM garbage collection can use up valuable CPU power that you want being used to serve web requests.  To reduce the frequency with which JVM invokes garbage collection, Use the -Xmx switch to start the JVM with a higher maximum heap memory.  This will free up CPU time for the processes you really care about.

Glassfish Connection Pool setup

downloaded the 2005 JDBC divers for UNIX. You have to agree to a licence before doing so. I didn't read it. I hope I still own my soul :) On glassfish I copied the jar to  /lib/ext. I then setup a connection pool with the following properties:
  • DataSource Classname:
  • Resource Type: javax.sql.XADataSource
  • Additional Properties:
    • instanceName : SQLEXPRESS (or whatever you named your instance)
    • password : super-secret-password
    • user: database user
    • portNumber : dynamic port number(1123)
    • serverName: name or ip address of the server
After the I was successful in pining the remote MS SQL 2005 server and setup the relevant JNDI entries. What a relief! 

SQL Server 2005 Jdbc connection|MSSQL 2005 -JDBC Connection

Connecting to a version of MS SQL post 2000 requires a few extra pieces of knowledge these days.
  • By default MS SQL does not listen on anyTCP/IP socket. You have to go to MS SQL configuration manager console and enable tcp/ip for the instance under Network Configuration. You need to restart SQL for this to take effect. It also appears that enabling TCP/IP does not enable it on a specific ip address. I had to set the specific ip address under "SQL Server 2005 Network Configuration"=>TCP/IP Protocol=>(right click) Properties=>IP Addresses to enabled = yes.
  • Instances do not run on port 1433 anymore. They use dynamic ports. If you right click on the tcp/ip protocol for your instance under "SQL Server 2005 Network Configuration" you should be able to force this to change by changing the setting on the "IP Addresses "tab but this didn't work for me.You can pick up the dynamic port it is using with netstat or from the "IP Addesses" tab. Since it is a dev environment I didn't care much as long as I could connect.
  • Don't foget to allow the windows firewall to let external request to the port through.