Increasing Heap Size While Building With Ant

February 12, 2008 at 11:54 am (Java)

Things are easy to manage memory while building applications using java.exe.

But while using ant for building big codes, we need to set the memory limit using a parameter ANT_OPTS

just set the above thing in environment variables and give the size as the value in the following fashion to get things going.


eg. set ANT_OPTS =-Xmx512m

in unix – setenv ANT_OPTS -Xmx768m

Permalink 1 Comment

Using Assertions In Java

December 12, 2007 at 2:26 pm (Java)

Java’s new assertion mechanism, allows programmers to increase the robustness of their code by sprinkling it liberally with assert statements. The new assertion feature is easy to use, but any language feature, no matter how simple, can be used well or poorly. Here I’ll explain how to use Java’s assertion facility, and how not to misuse it.

Using assertions couldn’t be easier. Anywhere you can put a statement in Java, you can now write

assert boolExpr;

where boolExpr is any Boolean expression. If the expression is true, execution continues as if nothing happened. If it’s false, an exception is thrown. You can disable assertions at runtime if you wish, effectively removing them from your code.

Permalink Leave a Comment

Monitor Performance Of Your Java Programs Using Verbose

December 9, 2007 at 5:54 am (Java, Tips n Tricks)

Concerned about the memory usage of your java development ? Here is an option that allows you to monitor the performance. Garbage collection is performed automatically in java when the heap size exceeds a threshold percentage of available heap. Verbose comes in two parts – GC verbose and JNI Verbose. which allows us to monitor the internal functioning.

java -verbose:gc <class name>

java -verbose:jni <class name>

This even helps us to set the heap sizes of our application for best and efficient utilization of JVM. ( Setting heap sizes is also available in previous posts ) This may not work for light programs.

Note: Verbose was introduced in J2SE so it is not available in previous versions.

Permalink Leave a Comment

Increase Heap Memory For Java Applications

December 5, 2007 at 12:10 am (Java, Study Refers, Tips n Tricks)

Many times you may crack out with an error like
Out Of Memory…
while running your java application. This is because of your jvm’s bounded heap size. You can alter this heap size by adding an argument to the command
java -Xms
java -Xmx
java -Xss

eg. java -Xmx32m will set the maximum heap size as 32MB.

Java Compiler has also some defaults for heap. These are initially set to 1GB so there is no need to worry about that. Moreover compiler job is not rigorous till we run a big set of code.
Launcher has 128MB as the maximum heap size and is generally reconfigured for biggies.
So, adjust your heap size according to your hardware capacity for optimized performance. 🙂

Permalink Leave a Comment

RSA encyption using Java

September 11, 2007 at 4:03 am (Java, languages, Security)

The most difficult implementation faced Java Cryptographic Extension comes in asymmetric key algorithms. The problem is to generate a key and use them after distribution. The answer to the question is to make the keys persistent as soon as they are generated in separate files. Once files for all the (public and private) keys are made, our issue gets over. Doing this is not a simple job because key generation comes from a lots of hidden packages. Attached here are examples of asymmetric key generation and their use.

Key generation Key generator

Encryption RSA Encryption

Permalink 2 Comments

Defining DSN on the fly in java

September 10, 2007 at 1:20 pm (Java, languages)

Talking about the traditional way of connecting to database involves.. Defining a driver making a dsn in the administrator console etc. Here is a short way in which you don’t need to worry about setting a dsn everytime project location gets shifted.

You can use the JDBC-ODBC but define your DSN “on the fly” by passing all ODBC configuration params inside the connect string:

// example for db test1.mdb, user dba, pw sql
con = DriverManager.getConnection(
"jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};

Look out: 1 blank before (*.mdb) !!!
Don’t forget the Class.forName() before!

Permalink Leave a Comment

New Features of JDK 1.5

September 10, 2007 at 1:12 pm (Java, languages)

One most common question which I faced in 4/7 interviews for my campus recruitment drive was the topic of this post.

The most prolific feature that comes as an advancement over previous version is “generics and collections”. This feature allows us to come in new era of data structures. It includes enhanced packages for arraylists, vectors, linkedlists etc. and even provides a lots of support for variance in enterprise environment.

Permalink Leave a Comment

New Features in JDK 1.5 Virtual Machine

September 10, 2007 at 1:08 pm (Compilers and Virtual Machines, Java, languages)

JDK 1.5 garbage collector comes with a unique capability called ergonomics over previous version. This gives a set of tuners or command line options for the programmer to tune the garbage collector without peeping into the code itself. This includes a lots of new profilers and type setters.

Permalink Leave a Comment

JVM 1.5 Open Source

September 10, 2007 at 9:59 am (Compilers and Virtual Machines, Java, Uncategorized)

In the last year, I got the opportunity to work on virtual machine for java. As mentioned, it is really hard to compile the code for proceeding on to the work. The source code needs a lots of specified preinstallations for making every part of it compiled. This includes gcc, gnumake, alsa, etc. Another problem arises in getting the matching specifications available. So, the next way is to parse through the make files. (Make files hold the key to the compilation flow and specifications). The make files of deploy, comtrol and j2se modules hold the specifications callings. So, we can change the specifications as per our requirements. There is a risk of upcoming errors because of this but they are less hazardous then these..

It takes 6-8 hrs for compilation of code on a linux machine with good configuration.

Permalink Leave a Comment