Thursday, February 7, 2013

Maximum size of a method in Java


The maximum size of a method in java is 64k. If it exceeds, we'll get a compiler warning like "Code too large to compile" . It's not a bug but known limitation found in Java 1.3. It was requested as an enhancement on 12-Aug-1999 by the engineers of Sun Microsystem. The information was updated on 09-Oct-2012 but there is no news so far that the issue is fixed or not.

Have a look at this http://bugs.sun.com/view_bug.do?bug_id=4262078 

In well structured code, each method is a manageable length and is much smaller than this limit. Large pieces of data, to be loaded into arrays, can be read from a non Java files like a text or binary file.

But  the 64KB limit is only a problem for generated code especially  when initializing large arrays.

Monday, February 4, 2013

GUI is not coming in SuSE Linux, only CLI

I faced this weird problem in my SuSE Linux machines. After booting only the CLI is coming instead of GUI. So to bring back the GUI as a root user type: sax2 -m 0=vesa

After that a GUI window will appear and will ask you to manage the resolution. Change that according to your need and reboot.

BINGO !!!

Eclipse Error : Failed to load JNI shared library



You are facing this error means eclipse is not able to locate the jvm.dll so check the <Java installation dir>/jdkxxx/jre/bin/server/jvm.dll path is proper or not. Also check the Java path settings.
 If you google for it, then you can get some solutions but they are confusing and might not work for all machines. 

But in the most cases you can face this problem if your eclipse is 32 bit and you have installed a 64 bit Java. I have many applications which required a 64 bit Java so I upgraded it from 32 to 64 bit without knowing that my eclipse is 32 bit. So I got this error. Now you can't change the Java path for 32 bit Java, because other applications are using 64 bit Java.

Solution:

Step 1:
Install both 32 bit and 64 bit Java . Set the environment varibale path for 64 bit Java So that all other applications can use it. Now right click on the eclipse shortcut icon and click Properties In the Target text field add the jvm.dll location with the -vm arg. So It should look like this :

Target:
"D:\eclipse_indigo\eclipse\eclipse2.exe" -vm "C:\eclipseJava7\jdk1.7.0_13\jre\bin\server\jvm.dll"

Step 2:
Now click Open file location and edit the eclipse.ini file with the same -vm arg and its value. Given below is my eclipse.ini
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
-vm
C:\eclipseJava7\jdk1.7.0_13\jre\bin\server\jvm.dll
-vmargs
-Xms512m
-Xmx1024m

So now your eclipse will use the 32 bit Java and all other applications will use 64 bit java as it is set as the Java path.