Student.dat
Records Size (kB)
50 51
100 502
150 771
200 1038
250 1305
300 1571
Tuesday, February 24, 2009
Java Out of Memory Error - Solution
How to fix Java out of Memory Error:
http://wiki.netbeans.org/FaqOutofMemoryOnCompile
http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html
How to set java heap size in NetBeans?
Exit NetBeans, edit the file
For example,
http://wiki.netbeans.org/FaqOutofMemoryOnCompile
You need to increase the memory allocated to the compiler. In order to do this:
- Right click on the project node in the Projects window and select Properties
- In the project properties dialog, click on Build | Compiling
- In the Additional Compiler Options text box, enter the -Xmx and optionally -Xms switches as needed (for example, -J-Xms=128m -J-Xmx=512m). For JDK 6, refer to http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html.
- Click OK in the dialog
- Make sure the external javac compiler will be used, by adding the following line to nbproject/project.properties from the Files tab:
build.compiler=extJavac
That should resolve the issue.
http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html
How to set java heap size in NetBeans?
Exit NetBeans, edit the file
netbeans-install/etc/netbeans.conf. For example,
netbeans_default_options="-J-Xms512m -J-Xmx512m
-J-XX:PermSize=32m -J-XX:MaxPermSize=128m -J-Xverify:none
Sunday, February 22, 2009
SRS: Student Record System Project Launched
To create a Student Record System to supplement COMAS.
Not to replace it.
Problem Statement:
COMAS is unable to calculate GPA and CGPA
(except for ADTP).
Scope:
1. To enter student records only from Jan 2009 onwards. But
COMAS will still be used to enter student records. From Jan 2009,
two systems will be used to manage student records, COMAS and
this new System.
2. Limited only to new Student records from Jan 2009.
3. Limited only to GPA and CGPA calculation.
4. Not intended to replace COMAS, but only to supplement COMAS
solely for purpose of calculating GPA and CGPA.
5. Report printing limited only to GPA and CGPA results.
6. All other modules not listed above are implicitly excluded from this
project. Eg, COMAS is still needed to do Student Application
and Enrolment, to generate fees payable and all other functionalities
that has been done by COMAS all along.
7. This system is only to be used for about 2 semesters - Jan and April, 2009.
Laureate (or other) system is expected to replace COMAS.
Not to replace it.
Problem Statement:
COMAS is unable to calculate GPA and CGPA
(except for ADTP).
Scope:
1. To enter student records only from Jan 2009 onwards. But
COMAS will still be used to enter student records. From Jan 2009,
two systems will be used to manage student records, COMAS and
this new System.
2. Limited only to new Student records from Jan 2009.
3. Limited only to GPA and CGPA calculation.
4. Not intended to replace COMAS, but only to supplement COMAS
solely for purpose of calculating GPA and CGPA.
5. Report printing limited only to GPA and CGPA results.
6. All other modules not listed above are implicitly excluded from this
project. Eg, COMAS is still needed to do Student Application
and Enrolment, to generate fees payable and all other functionalities
that has been done by COMAS all along.
7. This system is only to be used for about 2 semesters - Jan and April, 2009.
Laureate (or other) system is expected to replace COMAS.
Saturday, February 21, 2009
Friday, February 20, 2009
SCJP: Generics Type must be declared before use
Consider this code:

Text version:
The strangest thing about generic methods is that you must declare the type
variable BEFORE the return type of the method:
public static <k,v> mangle(Map <k,v> in)
<K,V> is the type you are going to use. But the return type is:
Map<K,V> . Even if you are not going to return anything you still
need to declare the type before use, eg:
public static <K,V> void mangle(Map in)
What happens if you change this line :
out.put(entry.getValue(), entry.getKey())
to
out.put(entry.getKey(), entry.getValue()) ?
There will be a compiler error!
This is because when you declare a new HashMap:
Map <V,K> out = new HashMap <V,K> ();
the new HashMap treats the Key as V and the Value as K,
reversing the values and keys.
It then returns the new object to the reference out which
also expects V, K, in that order.
As such when you call out.put( ), the out object expects
the V to come before the K.
Text version:
The strangest thing about generic methods is that you must declare the type
variable BEFORE the return type of the method:
public static <k,v> mangle(Map <k,v> in)
Map<K,V> . Even if you are not going to return anything you still
need to declare the type before use, eg:
public static <K,V> void mangle(Map in)
What happens if you change this line :
out.put(entry.getValue(), entry.getKey())
to
out.put(entry.getKey(), entry.getValue()) ?
There will be a compiler error!
This is because when you declare a new HashMap:
Map <V,K> out = new HashMap <V,K> ();
the new HashMap treats the Key as V and the Value as K,
reversing the values and keys.
It then returns the new object to the reference out which
also expects V, K, in that order.
As such when you call out.put( ), the out object expects
the V to come before the K.
Thursday, February 19, 2009
How to strip HTML Tags

The output is:
Honolulu Tue 5:05 AM
Washington DC Tue 10:05 AM
Oslo Tue 4:05 PM
The important parts:
String stripH = dataH.replaceAll("<.*?>"," ");
The method replaceAll("<.*?>"," ") strips out all HTML tags
by searching for anything with angle brackets ( < > ) and replace it
with a blank space ( " ").
The regular expression <.*?> means match anything within
the angle brackets once. The dot ( . ) means any character.
The quantifier ( * ) means zero or more. The ( ? ) qualifies
the quantifier ( * ) by saying match it once only. The ( *? ) is
also called a 'reluctant' quantifier.

and replaces each one with a blank space.
For J2ME, use this:

Assuming :

Call the method as follows:
String stripped = doStripHtml(data);
Note that you will still need to modify the code before
you can use it in your HTML Parser application. But I
leave that to you to do.
Below is yet another version:

Subscribe to:
Posts (Atom)