Monday, December 31, 2012

Technoladder Wishes All Readers A Very Happy New Year 2013!

2012 has been a wonderful starting year for this technoladder.blogspot.com blog and there has been a good response in the initial year. The blog is going to bring more technical articles, tips and tricks that are really essential for people in information and internet technologies in the coming years. Hope you enjoyed all the technical articles in this blog in 2012 and the blog assures that you'll do enjoy reading more technical articles, personal experiences, tips & tricks in the coming years and technoladder wishes you a very happy and prosperous new year 2013!
 

Sunday, December 30, 2012

Useful Tips For Using Google Nexus 7 Tablet - Reported Common problems with Nexus 7

Some of the features of Google Nexus 7 tablet are not very intuitive at least when you first time start using it. Following are some tips to get started using the brand new Google Nexus 7 table.

How To Start the Camera in Google Nexus 7 Tablet

The nexus 7 tablet does not provide an icon or a shortcut to launch its front camera. The camera starts when you actually use Google Hangouts etc. So in order to launch the Camera, you require an android developed exclusively to launch the nexus 7 front Camera. In Google Play, just search for the app "Nexus 7 Camera Starter" and install the same and there you go with Nexus 7 camera. Though its low resolution one, the picture and video qualities look just fine on Nexus 7.

How to turn on the Auto-Rotate of Nexus 7 Screen for playing widescreen videos.

When you buy brand new Nexus 7, by default the screen rotation feature is turned off, so the tablet does not play your videos in full screen, to turn on this, from left top corner, scroll the screen down and you will see an option called 'Rotation Locked', just click on that to turn on auto rotation of the screen and there you go playing full screen videos!

How to get rid of Nexus7 screen flicker problem

It is noticed commonly that the Nexus7 Screen flickers at low ambient conditions. Hopefully Google fixes this problem in their next version of Android OS versions. However there are workarounds to get rid of this problem. The work around is to change the brightness of your display and disable the auto brightness under your display settings.

Nexus 7 Gets Locked when you forget your password

Some users have reported that you password protect their Nexus 7 and by chance if they forget the password, then the tablet is locked. To recover this issue, you may need to provide your Google Account Details and if this also does not help in any way and the final solution is to go for restoring the tablet to Factory Settings which you will erase all your stored data. Use this fix with your own risk and responsibility.

Some more tips adding up...

Saturday, December 29, 2012

How To Detect DeadLocks In Java Programs/Applications usin JConsole Java Utility (A Quicker Way)

DeadLock is a situation where two or more threads are blocked forever waiting for each other. So your Java program or Java Application freezes and you need to force close or kill the application by yourself. Since not all the times the dead Lock causes your application to freeze, we need to first identify if the application has crashed is really due to deadLock or some other reason. To find out if your application is caused due to deadlock situation, its fairly simple. The JDK (Java Development Kit) already provides a Utility called jConsole which is a Monitoring Tool and a management console which has ability to connect to remote VMs and analyze the thread dumps of your running java application. jConsole also gives the summary of the usages of heap memory, Eden Space, Survivor, Tenured Gen, etc usage in graphical format.  It also gives information about number of classes loaded, threads loaded and other important data of your application including the deadlock situations amongst threads if any.

I'll show you how we can use jConsole application and connect to a sample java program that has encountered deadlock and thus has blocked.

1. Open the jConsole application which is present in your %JAVA_HOME%\bin directory (Your Java installation directory) using command prompt or just double clicking on jConsole.exe program
2. When you open jConsole, it displays the name and process IDs of the running applications, choose your java application name that is suffering from deadlock situation as shown in the following screenshot (DeadLockTest is my Java Application which is blocked forever due to deadlock in below image)

  

3. Once selected your application, click Connect.
4. Click on the 'Threads' tab and then on 'Detect DeadLock' button at the bottom of the screen as shown in the following screen shot.

 
5. Once you click on Detect Deadlock button in red color in above screenshot, the threads that are 'dead locked' will be displayed with complete stack trace as shown in the following screen shot.
6. By selecting a particular thread, the stack trace is displayed in the right side of the screen which can be used to analyze the deadlock situation and resolve the issue.
 In above example, I have two threads Thread-1, Thread-0 that are waiting for each other.

If there are no deadlocks, then under 'DeadLock' No threads will be listed.

jConsole really comes handy while debugging java prorams, it could be debugging deadlocks, or doing memory optimizations, etc.

Wednesday, December 19, 2012

How To Resolve java.lang.OutOfMemoryError: Java heap space (The system is out of resources)

This  Java Heap Error is observed in different situations such as while running a Java Application, while executing Ant Scripts to run java projects, dealing with Java based web servers such as tomcat or while working with Java programs in Eclipse, Netbeans or intellij etc. The typical error on the console looks as shown below

[javac] The system is out of resources.
[javac] Consult the following stack trace for details.
[javac] java.lang.OutOfMemoryError: Java heap space
[javac] at com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:1486)
[javac] at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1586)

....

The first being if you have a much bigger Java Application and if there are any memory leaks in the application code (memory is allocated for objects but never released once the objects are no more required by the application), then JVM throws java.lang.OutOfMemoryError: Java heap space. In this situation, the java application must be analysed to identify the memory leaks (may be using memory profiling) and fix the memory leaks in the code. This is going to be performance improvement task.

The error is thrown when JVM is asked to use a limitted memory space for java objects but in fact more memory is required than the default or specified heap space. Note that in this case there are no memory leaks. This can be resolved by allocating more heap memory while executing the java program by using VM command line parameters -Xms (initial memory size) and -Xmx the maximum memory.

java -Xms128m -Xmx512m

The java heap error may also be thrown while executing certain ant targets. Ant uses the javac command to compile and execute java programs and user can tell the ant tool how much heap memory has to be used. To achieve this, ant gives a environmnet variable called ANT_OPTS. The command line arguments that are required to be passed to the JVM such as setting the maximum Java heap space can be specified as a value to the environment variable ANT_OPTS.

Variable Name : ANT_OPTS
Variable Value: -Xms128m -Xmx512m -XX:MaxPermSize=256m

The value of ANT_OPTS is used by the Ant tool while dealing with your java programs. If you look at above example, multiple arguments can be specified, here MaxPermSize is also specified (just to demonstrate multiple arguments can be speicified using ':') If you are interested to know about PermGenSpace have a look at Prevent OutOfPermGenSpace Java Error.

How to set the environment Variables under Windows?

Its advisable to define the environment variables under My Computer->Right Click->Properties->Advanced System Settings->Enviroment Variables... and then do not forget to restart the command line prompt for new environment variable to take effect.
The environment variables can also be set in the command prompt such DOS prompt by using SET command. Example: Set ANT_OPTS=-Xms128m -Xmx512m -XX. However the environment variable set like above will go away once you close the command prompt so its temporary.

Related Posts Plugin for WordPress, Blogger...