Wednesday, 14 March 2012

10 points about Java Heap Space or Java Heap Memory

10 points about Java Heap Space or Java Heap Memory

When I started java programming I didn't know what is java heap or what is heap space in Java, I was even not aware of where does object in Java gets created, it’s when I started doing professional programming I came across error java.lang.outofmemoryerror then I realized What is Heap in Java or Java Heap Space. Its happens with most of programmer because learning language is easy but learning basics is difficult since there is no formal process which can teach you every basics of programming its experience and work which reveals the secret of programming. For Java developer knowledge of Heap in Java, setting size of java heap space, dealing with java heap space outofmemoryerror, analyzing heap dumps is very important. This Java Heap tutorial is for my beginner brothers who are new in programming and learning it. It makes too much difference if you know the basics and underlying, until you know that object is created in heap, you won't be able to think why OutOfMemoryError occurs in Heap. I am trying to provide as much information about Heap in Java as I know but would like you guys to contribute and share your knowledge about Heap in Java to benefit all.

What is Heap space in Java?
When a Java program started Java Virtual Machine gets some memory from Operating System. Java Virtual Machine or JVM uses this memory for all its need and part of this memory is call java heap memory. Heap in Java generally located at bottom of address space and move upwards. whenever we create object using new operator or by any another means object is allocated memory from Heap and When object dies or garbage collected ,memory goes back to Heap space in Java, to learn more about garbage collection see how garbage collection works in Java.


How to increase size of Java Heap?
Default size of Heap in Java is 128MB on most of 32 bit Sun's JVM but its highly varies from JVM to JVM e.g. default maximum and start heap size for the 32-bit Solaris Operating System (SPARC Platform Edition) is -Xms=3670K and -Xmx=64M and Default values of heap size parameters on 64-bit systems have been increased up by approximately 30%. Also if you are using throughput garbage collector in Java 1.5 default maximum heap size of JVM would be Physical Memory/4 and default initial heap size would be Physical Memory/16. Another way to find default heap size of JVM is to start an application with default heap parameters and monitor in using JConsole which is available on JDK 1.5 onwards, on VMSummary tab you will be able to see maximum heap size.

By the way you can increase size of java heap space based on your application need and I always recommend this to avoid using default JVM heap values. if your application is large and lots of object created you can change size of heap space by using JVM command line options -Xms and -Xmx. Xms denotes starting size of Heap while Xmx denotes maximum size of Heap in Java. There is another parameter called -Xmn which denotes Size of new generation of Java Heap Space. Only thing is you can not change the size of Heap in Java dynamically, you can only provide Java Heap Size parameter while starting JVM.

Java Heap and Garbage Collection
As we know objects are created inside heap memory and Garbage collection is a process which removes dead objects from Java Heap space and returns memory back to Heap in Java. For the sake of Garbage collection Heap is divided into three main regions named as New Generation, Old or Tenured Generation and Perm space. New Generation of Java Heap is part of Java Heap memory where newly created object allocated memory, during the course of application object created and died but those remain live they got moved to Old or Tenured Generation by Java Garbage collector thread on Major collection. Perm space of Java Heap is where JVM stores Meta data about classes and methods, String pool and Class level details. You can see How Garbage collection works in Java for more information on Heap in Java and Garbage collection.

OutOfMemoryError in Java Heap
When JVM starts JVM heap space is the initial size of Heap specified by -Xms parameter, as application progress objects creates and JVM expands Heap space in Java to accommodate new objects. JVM also run garbage collector to reclaim memory back from dead objects. JVM expands Heap in Java some where near to Maximum Heap Size specified by -Xmx and if there is no more memory left for creating new object in java heap , JVM throws java.lang.outofmemoryerror and your application dies. Before throwing OutOfMemoryError No Space in Java Heap, JVM tries to run garbage collector to free any available space but even after that not much space available on Heap in Java it results into OutOfMemoryError. To resolve this error you need to understand your application object profile i.e. what kind of object you are creating, which objects are taking how much memory etc. you can use profiler or heap analyzer to troubleshoot OutOfMemoryError in Java. "java.lang.OutOfMemoryError: Java heap space" error messages denotes that Java heap does not have sufficient space and cannot be expanded further while "java.lang.OutOfMemoryError: PermGen space" error message comes when the permanent generation of Java Heap is full, the application will fail to load a class or to allocate an interned string.

Java Heap dump
Java Heap dump is a snapshot of Java Heap Memory at a particular time. This is very useful to analyze or troubleshoot any memory leak in Java or any Java.lang.outofmemoryerror. There is tools available inside JDK which helps you to take heap dump and there are heap analyzer available tool which helps you to analyze java heap dump. You can use "jmap" command to get java heap dump, this will create heap dump file and then you can use "jhat - Java Heap Analysis Tool" to analyze those heap dumps.

10 Points about Java Heap Space
1. Java Heap Memory is part of Memory allocated to JVM by Operating System.

2. Whenever we create objects they are created inside Heap in Java.

3. Java Heap space is divided into three regions or generation for sake of garbage collection called New Generation, Old or tenured Generation or Perm Space.

4. You can increase or change size of Java Heap space by using JVM command line option -Xms, -Xmx and -Xmn. don't forget to add word "M" or "G" after specifying size to indicate Mega or Giga. for example you can set java heap size to 258MB by executing following command java -Xmx256m HelloWord.

5. You can use either JConsole or Runtime.maxMemory(), Runtime.totalMemory(), Runtime.freeMemory() to query about Heap size programmatic in Java.

6. You can use command "jmap" to take Heap dump in Java and "jhat" to analyze that heap dump.

7. Java Heap space is different than Stack which is used to store call hierarchy and local variables.

8. Java Garbage collector is responsible for reclaiming memory from dead object and returning to Java Heap space.

9. Don’t panic when you get java.lang.outofmemoryerror, sometimes its just matter of increasing heap size but if it’s recurrent then look for memory leak in Java.

10. Use Profiler and Heap dump Analyzer tool to understand Java Heap space and how much memory is allocated to each object.

Top 30 Eclipse Keyboard Shortcuts for Java Programmer

Top 30 Eclipse Keyboard Shortcuts for Java Programmer

This tutorial is about 30 Eclipse keyboard shortcuts, this list is by no means complete and I will suggest you guys to share eclipse shortcuts listed other than here to make this more useful.Eclipse is most used Java development IDE and knowing Eclipse shortcuts not only improve your productivity but also makes you more efficient, you will have more time for things you like to do. Using keyboard shortcuts also helps to impress colleagues and shows that you have good hold on tools you used for Java Development.


I was big fan of Netbeans IDE before coming across Eclipse because I was from J2ME background and Netbeans provide sophisticated IDE environment to enable you to build, debug and run your Java application in various emulator including some advanced processing options e.g. preprocessing, setting up Exception break-point etc. From that time I love to know keyboard shortcuts on IDE and other tools I used for development including Edit Plus, Microsoft Excel etc.

But when I join an investment bank I came across Eclipse IDE, since everybody in my team is using and Netbeans IDE was not available in company (don’t know why that was not allowed net-beans even though it was free) I have decided to go Eclipse way, later I found that Eclipse was most suited for those application given some of cool feature of eclipse e.g. Remote Debugging, Conditional Breakpoints, Exception breakpoints and Ctrl+T and Ctrl+R kind of shortcuts.

Here I am sharing list of 30 Eclipse keyboard shortcuts which I found most useful and using in my day to day life while writing code, reading code or debugging Java application in Eclipse.

Eclipse Keyboard Shortcuts

1) Ctrl + T for finding class even from jar

This keyboard shortcut in Eclipse is my most used and favorite shortcut. While working with high speed trading system which has complex code I often need to find classes with just blink of eye and this eclipse keyboard shortcut is just made for that. No matter whether you have class in your application or inside any JAR, this shortcut will find it.

2) Ctrl + R for finding any resource (file) including config xml files

This is similar to above Eclipse shortcut with only difference that it can find out not only Java files but any files including xml, configs and many others, but this eclipse shortcut only finds files from your workspace and doesn’t dig at jar level.

3) Ctrl + 1 for quick fix

This is another beautiful Eclipse shortcut which can fix up any error for you in Eclipse. Whether it’s missing declaration, missing semi colon or any import related error this eclipse shortcut will help you to quickly short that out.

4) Ctrl + Shift + o for organize imports

Another Eclipse keyboard shortcut for fixing missing imports. Particularly helpful if you copy some code from other file and what to import all dependencies.

Eclipse Shortcut for Quick Navigation
In this section we will see some eclipse keyboard shortcut which helps to quickly navigate within file and between file while reading and writing code in Eclipse.

7) Ctrl + o for quick outline going quickly to method
9) Alt + right and Alt + left for going back and forth while editing.
12) Alt + Shift + W for show in package explorer
13) Ctrl + Shift + Up and down for navigating from member to member (variables and methods)
15) Ctrl + k and Ctrl + Shift +K for find next/previous
24) Go to a type declaration: F3, This Eclipse shortcut is very useful to see function definition very quickly.


Eclipse Shortcut for Editing Code
These Eclipse shortcuts are very helpful for editing code in Eclipse.
5) Ctrl + / for commenting, un commenting lines and blocks
6) Ctrl + Shift + / for commenting, un commenting lines with block comment
8) Selecting class and pressing F4 to see its Type hierarchy
10) Ctrl + F4 or Ctrl + w for closing current file
11) Ctrl+Shirt+W for closing all files.
14) Ctrl + l go to line
16) Select text and press Ctrl + Shift + F for formatting.
17) Ctrl + F for find, find/replace
18) Ctrl + D to delete a line
19) Ctrl + Q for going to last edited place


Miscellaneous Eclipse Shortcuts
These are different Eclipse keyboard shortcuts which doesn’t fit on any category but quite helpful and make life very easy while working in Eclipse.

20) Ctrl + T for toggling between super type and subtype
21) Go to other open editors: Ctrl + E.
22) Move to one problem (i.e.: error, warning) to the next (or previous) in a file: Ctrl +. For next, and Ctrl +, for previous problem
23) Hop back and forth through the files you have visited: Alt + ← and Alt + →, respectively.
25) CTRL+Shift+G, which searches the workspace for references to the selected method or variable
26) Ctrl+Shift+L to view listing for all Eclipse keyboard shortcuts.
27) Alt + Shift + j to add javadoc at any place in java source file.
28) CTRL+SHIFT+P to find closing brace. Place the cursor at opening brace and use this.
29) Alt+Shift+X, Q to run Ant build file using keyboard shortcuts in Eclipse.
30) Ctrl + Shift +F for Autoformating.

Please post if you guys have some more useful Eclipse keyboard shortcuts as comments, I will include them in this list. These Eclipse shortcuts will mostly work almost all Eclipse versions e.g. 3.5, 3.6 Helios, Eclipse Ganymede and Indigo. Let me know if you face any issue while using these Eclipse shortcuts in any particular version of Eclipse IDE.

Friday, 9 March 2012

How to setup java remote debugging in eclipse?

How to setup java remote debugging in eclipse?

Remote debugging is not a new concept and many of you are aware of this just for who don’t know what is remote debugging? It’s a way of debugging any process could be Java or C++ running on some other location from your development machine. Since debugging is essential part of development and ability to debug your application not only saves time but also increase productivity. Local debugging is the best way in my opinion and should always be preferred over remote debugging but if local debugging is not possible and there is no way to debug your process then remote debugging is the solution.

Many of us work on a project which runs on Linux operating system and we do development mostly on Windows. Since I am working in Investment banking and finance domain I have seen use of Linux server for running electronic trading application quite a lot, which makes development difficult because you don't have code running on your development machine.

Some time we managed to run the project in windows itself which is essential for development and debugging purpose but many times its not possible due to various reason e.g. your project depends upon some of the platform dependent library or some Linux module whose windows version may not be available or your project is too big to run on windows and its heavily connected to upstream and downstream system its almost impossible to create same environment in your windows machine for development.
On such situation my approach to work is isolate the work I am doing and test that with the help of mock objects, Threads or by trying to run that module independently but this is also not a desired solution in some cases where you need to debug the project at run time to find out some subtle issues.


Eclipse provides us most useful feature called "Remote debugging" by using which you can debug your Linux running process from your windows machine. believe me this become absolutely necessary in some condition and knowing how to setup remote debugging and working of remote debugging in eclipse can greatly improve your productivity. In this Eclipse tutorial I will try to explain eclipse remote debugging or how to setup remote debugging in eclipse.

Now let's see how we can setup remote debugging in Eclipse:

1) First setup your java project in Eclipse.

2) Select your project, go to "Run" Menu option and select "Debug Configurations"

3) This will open Debug Configuration window select "Remote Java Application" icon on left side, Right click and say "New".4) After clicking on New, Eclipse will create Remote Java Application configuration for your selected project. Now next step is to setup host and port for remote debugging.



5) Now put the host name and port on which your process is listening for debugger in Linux machine. Check the "Allow termination of remote VM" check box if you would like to close java application running on Linux from eclipse.

6) Now you are all set to remote debug your project. but before starting to debug make sure your java process is started with java debug settings and listening on same host and port, otherwise eclipse will not able to connect successfully.

7) To debug just click the "Debug" button in last screen where we have setup host and port.

8) You can also debug by going to "Debug Configurations" selecting your project in "Remote Java Application” and clicking on "DEBUG".

Java remote debug setting and JVM debug options

In order to remote debug a java application, that application must be started with following JVM debug options:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y suspend=y -jar stockTradingGUI.jar

This will start java applicaiton stockTradingGUI into debug mode using Java Debug Wire Protocol (jdwp) protocol and it will listen on port 8001
suspend=y will ensure that that application will not start running until eclipse connect it on speicified debug port.It also important to note
That application must be start before eclipse tries to connect it other wise Eclipse will throw error "Failed to connect to remote VM. Connection refused" or "Connection refused: connect"


Enjoy remote debugging in Eclipse



Tip: In JVM DEBUG parameters there is a parameter called "suspend" which takes value as "y" or "n". so if you want to debug the process from start set this parameter as "suspend=y" and your Java application will wait until Eclipse remotely connect to it. Otherwise if you want to run your program and later want eclipse to be connected that set this as "suspend=n" so your java application will run normally and after eclipse remotely connected to it, it will stop on breakpoints.


Tip: Use start up script to put JVM debug parameter and use a variable e.g. isDebugEnabled and also REMOTE_DEBUG_PORT in the script export this variable when you want to remote debug your Java application. This will be very handy and will require just one time setup work.


Tip: if you get error "Failed to connect to remote VM. Connection refused" or "Connection refused: connect" then there might be two possibility one your java program is not running on remote host and other you are giving incorrect port or host name after verifying these two things if issue still persists then try giving full name of the host.

Tip: You also need to ensure that you run the same codebase in eclipse which is deployed in your remote machine so that what you debug and see in eclipse is true and real. you also need to ensure that your code is compile with debug option "-g" so that eclipse can easily gather debug info e.g. information about local variable. by default java only generate line numbers and source file information.with debug option -g your class file size might be more because it would contain some debug information.

How to solve Address or Port already in use error in java?

How to solve Address or Port already in use error in java?

java.net.BindException: Address already in use: JVM Bind is one of the most popular error among java developers and guys who do socket


programming in some other language too. But with respect to java this error is much familiar with socket programming and during web development. This error

happens for ports 80 (HTTP) , 1098 (RMI) when it is used by other applications that is running on the same PC or server. So I am going to explain how to debug and solve this problem.


Step I : Finding the ports that are in use:

1. You can use the tool CurrPorts to solve this problem. You can google about the tool. How to find open ports in your PC?

2. If you are using windows XP you can use the netstat command to view which processing is occupying the port. If you use Windows 2000 then you cannot use the ‘ netstat -o ‘ in your netstat command which tells you the process ID that is using the port. So in windows 2000 use the tool CurrPorts which is free.

eg) netstat -ano

Note:

If you have problem with port 1098 then check whether outlook or firefox is currently in use and close the same to free the port. This is just an example and for a better report you can use the tools mentioned above.

Step II : Free up the port:

You can free up the port by 3 ways,

1. If you use CurrPorts tool then you can find the application that is using it and you can close it down or kill the process by right clicking in the tool.

2. In windows you can use the command ‘ taskkill /PID 828 ‘ to kill the appropriate process.

3. Making your program to use a different port. For instance if you are encountering this error with JBOSS Application server for port 80, then you can go to server.xml in the appropriate directory say server/default/deploy/jbossweb-tomcatXX.sar/server.xml and change the port to 8080 to avoid the conflict. In case of Tomcat look for server.xml in the conf directory


Hope the above explanation helps. Feel free to comment.

Friday, 27 January 2012

Norton AntiVirus 2012 v19.1.1.3 (2 Years License)

Symantec's Norton AntiVirus 2012 - Winning protection against viruses, spyware, and other malicious threats! Heuristically detects Spyware threats, detects blocks Internet worm attacks, and protects email.

Norton AntiVirus blocks viruses and spyware with advanced protection. It helps protect your entire computer by stopping viruses, spyware, and other security risks.

Norton AntiVirus works in the background so you can surf the Internet, read the news, play games, and download software or music without disruption. It also scans and cleans all email and instant messaging (IM) attachments, preventing you from receiving viruses, or spreading them to others. With set-it and forget-it functionality, Norton AntiVirus checks for updates continuously and automatically blocks new and emerging threats from getting on your system. In addition to protection updates, Norton AntiVirus provides new product features as available throughout your service subscription

Norton AntiVirus 2012 v19.1.1.3 (2 Years License)

Instructions:

1. Install Norton Internet Security 2012.
2. Turn OFF the in the "General = Product Security".
3. Run the NIS-2012-Crack.
4. After installation turn ON .
5. Done.


Avid Media Composer 5.5.3 (Mac OSX)

Avid Media Composer 5.5.3 With Crack Mac OSX | 2.07 GB

High-speed video editing software-ideal for offline, file-based, and mobile editing


Overview:
Work Faster the Way You Want, with What You Want
Gain the speed, ease, and access you need to tell great stories using a powerful editing tool that works the way you want, with all the formats you need, and enables you to blaze through projects in ways you never thought possible. That’s the beauty of the Media Composer family-the most trusted video editing and finishing systems in the media and entertainment industry.

What's new:
Capture, monitor, and output video with support for the AJA Io Express interface
Natively access and edit Sony HDCAM SR Lite media through AMA (Avid Media Access)
Accelerate Panasonic AVC-Intra projects-and use multiple streams-with support for the new Nitris DX AVC-Intra hardware interface
Take hands-on control of your video and audio editing/mixing with EUCON support for Artist Control, Artist Mix, and Artist Transport control surfaces (watch the video)
Find the right clips fast with support for the new PhraseFind option (watch the video)
Directly manipulate transitions in the timeline with the expanded Smart Tool (watch the video)
Be more creative with updates to production suite (watch the video)
Quickly find files across local and shared storage bins using the improved Find tool
Capture and monitor audio in Media Composer projects using Pro Tools hardware
Specify audio track formats during import or through AMA, and expand your creative palette with 20 included AIR effects plug-ins
Be more creative with new updates to the included Production Suite (sold separately from download purchases)
Get more flexibility with audio signal routing when sending material to air (Send to Playback), with up to 16 audio output channels
View portions of the software interface in localized languages, including Japanese, Simplified Chinese, Korean, French, Spanish, German, and Italian
Get better Long GOP performance when using Send to Playback with AirSpeed servers
Use proxies of H.264 material in AirSpeed MultiStream environments for faster response time and increased stream counts
New format support with Matrox MX02 Mini now includes SD 23.976, 720p 23.98, 1080p 23.98, 1080p 24, 1080p 25, and 1080p 29.97 as well as the ability to select PsF or true P output in 1080p modes. Also MX02 Mini with Max acceleration has been qualified on Mac OS systems.


http://extabit.com/file/27au962urz75n/Avid.Media.Composer.v5.5.3.Incl.Crack.part1.rar
http://extabit.com/file/27au962uq2zej/Avid.Media.Composer.v5.5.3.Incl.Crack.part2.rar
http://extabit.com/file/27au9633rcvkr/Avid.Media.Composer.v5.5.3.Incl.Crack.part3.rar
http://extabit.com/file/27au962uv3kej/Avid.Media.Composer.v5.5.3.Incl.Crack.part4.rar
http://extabit.com/file/27au962uq3ux7/Avid.Media.Composer.v5.5.3.Incl.Crack.part5.rar

Mac OSX 10.6.3 Retail DVD Original & Installation Method

Mac OSX 10.6.3 Retail DVD Original & Installation Method | 6.25 GB

Very useful for New Mac Users with Details Screenshots + Guides Step by Step. Try ONE-TIME and you will never need support when install next version of Mac OS X or Lion. So Easy but Important for New Users

The Installation

Turn on the computer,Insert the Mac OS X Install DVD into the optical drive, or insert the MacBook Air Software Reinstall
Drive into the USB port.
Press and hold the "C" key while the computer starts up. The computer will start up using the Install media.
Alternatively, press and hold the Option key at startup to select the volume containing the installer.

More details to Completing the Mac OS X Setup Assistant

1) When the restart has completed, a welcome video plays, then country/region selection screen appears.

2) Select your country or region and click Continue.

3) Select a keyboard layout and click Continue.

4) A migration screen appears. If you wish to migrate your data from another Macintosh, see Migration tips and tricks. If you do not wish to migrate, or want to migrate later, select "Do not transfer my information now" and click Continue.

5) A Wireless Service screen appears if you have wireless services available within range of your computer. Select "On" and click Continue.

6) If the network is password protected, you be asked for a password when you select it. Type the password and click Continue.

7) An Apple ID screen appears. This is used to purchase content from the iTunes store. You can use MobileMe or .Mac usernames here as well. When complete, click Continue.

8) If you do not have an Apple ID or MobileMe account, click Continue to move to the next screen.

9) A Registration Information screen appears. You are not required to fill this out, but it is helpful if you do. When complete, click Continue and your product registration will be sent immediately.

10) If Mac OS X servers are available on your network, you'll be asked if you'd like to log on to them. If not, click Continue.

11) A Create Your Account screen appears. This will be used to create a User Account with Login ID and Password for you computer. You should remember this password. You'll be asked for it when you install new software or perform other administrative tasks on your computer. When complete, click Continue and your account will be created immediately.

12) A screen to select your user picture appears. Take a snapshot with the built-in camera or select a picture from your Library. When complete, click Continue.

13) A MobileMe screen appears. Select an option and click Continue.

14) A Thank You screen appears. Click Go to complete the Mac OS X Setup Assistant.

15) Eject the Mac OS X Install DVD by dragging its icon to the Trash.



http://bitshare.com/files/lp5pvqlm/Mac.OSX.10.6.3.Retail.DVD.part01.rar.html
http://bitshare.com/files/avi0tagj/Mac.OSX.10.6.3.Retail.DVD.part02.rar.html
http://bitshare.com/files/tdo9i4r0/Mac.OSX.10.6.3.Retail.DVD.part03.rar.html
http://bitshare.com/files/nrr899ok/Mac.OSX.10.6.3.Retail.DVD.part04.rar.html
http://bitshare.com/files/oj090cm0/Mac.OSX.10.6.3.Retail.DVD.part05.rar.html
http://bitshare.com/files/xvrhvxqf/Mac.OSX.10.6.3.Retail.DVD.part06.rar.html
http://bitshare.com/files/14f9zw0c/Mac.OSX.10.6.3.Retail.DVD.part07.rar.html
http://bitshare.com/files/eiadhoow/Mac.OSX.10.6.3.Retail.DVD.part08.rar.html
http://bitshare.com/files/yevoh8f5/Mac.OSX.10.6.3.Retail.DVD.part09.rar.html
http://bitshare.com/files/twcejskb/Mac.OSX.10.6.3.Retail.DVD.part10.rar.html
http://bitshare.com/files/npacc0eg/Mac.OSX.10.6.3.Retail.DVD.part11.rar.html
http://bitshare.com/files/9fjguy2i/Mac.OSX.10.6.3.Retail.DVD.part12.rar.html
http://bitshare.com/files/2owam166/Mac.OSX.10.6.3.Retail.DVD.part13.rar.html
http://bitshare.com/files/o8byrlz5/Mac.OSX.10.6.3.Retail.DVD.part14.rar.html
http://bitshare.com/files/1z73qc9q/Mac.OSX.10.6.3.Retail.DVD.part15.rar.html