R Pidugu

Solution for the Error : An internal error occured during: "reload maven project"


You might have faced this issue after changing the project name or may be changing project name in pom.xml. When you restart your eclipse it may not launch due to project metadata file is corrupted due to your .project name changes and Maven can not laod your project properly and will displays this error shown above and eclipse console will not be opened. To get rid off this issue follow the solution given below
Read More
R Pidugu

DOM Parser Vs. SAX Parser


Many developers sometimes confuse which is better to parse the XML document. Ofcourse myself also got doubt which parser I can use for this situation.  Since I have read about DOM and SAX very long back. Just refreshing it again

DOM (Document Object Model) Parser:
  • Tree model parser(Object based) (Tree of nodes).
  • DOM loads the file into the memory and then parse the file.
  • Has memory constraints since it loads the whole XML file before parsing.
  • DOM is read and write (can insert or delete the node).
  • If the XML content is small then prefer DOM parser.
  • Backward and forward search is possible for searching the tags and evaluation of the information inside the tags. So this gives the ease of navigation.
  • Slower at run time.
Read More
R Pidugu

How Java Garbage Collector Works?


The Java runtime environment deletes objects when it determines that they are no longer being used. This process is known as garbage collection. The Java runtime environment supports a garbage collector that periodically frees the memory used by objects that are no longer needed. The Java garbage collector is a mark-sweep garbage collector that scans Java's dynamic memory areas for objects, marking those that are referenced. After all possible paths to objects are investigated, those objects that are not marked (i.e. are not referenced) are known to be garbage and are collected. (A more complete description of our garbage collection algorithm might be "A compacting, mark-sweep collector with some conservative scanning".)

The garbage collector runs synchronously when the system runs out of memory, or in response to a request from a Java program. Your Java program can ask the garbage collector to run at any time by calling System.gc(). The garbage collector requires about 20 milliseconds to complete its task so, your program should only run the garbage collector when there will be no performance impact and the program anticipates an idle period long enough for the garbage collector to finish its job.
Read More
R Pidugu

HTTP + REST Vs. AMQP + RPC

  • REST, RPC - architecture patterns, AMQP - wire-level and HTTP - application protocol which run on top of TCP/IP
  • AMQP is a specific protocol when HTTP - general-purpose protocol, thus, HTTP has damn high overhead comparing to AMQP
  • AMQP nature is asynchronous where HTTP nature is synchronous
  • Both REST and RPC use data serialization, which format is up to you and it depends of infrastructure. If you are using python everywhere I think you can use python native serialization - pickle which should be faster than JSON or any other formats.
  • Both HTTP+REST and AMQP+RPC can run in heterogeneous and/or distributed environment
So if you are choosing what to use: 
HTTP+REST or AMQP+RPC, the answer is really subject of infrastructure complexity and resource usage. Without any specific requirements both solution will work fine, but i would rather make some abstraction to be able switch between them transparently.
Read More
R Pidugu

How To Decompile Android APK file(.apk) and Get Source Code


Sometimes you may be amazed to see beautiful android apps with great design and simplicity. You may want to look into the source code of that app and to design the same way they have done. Usually APK file is not readable because its in dex format (Dalvik excutable file) which can be read by dalvik compiler. So there is a trick I found on stackoverflow to decompile any apk file. Just follow the below steps to get source code of any android app, if you have got .apk file

Step 1:

  1. Create a new folder in your pc and copy over the .apk file that you want to decode.
  2. Now rename the extension of this .apk file to .zip (e.g. rename from filename.apk to filename.zip) and save it. 
  3. Now you can access the classes.dex files, etc. At this stage you are able to see drawables but not xml and java files, so continue.

Step 2:

  1. Now extract this .zip file in the same folder (or NEW FOLDER).
  2. Download dex2jar and extract it to the same folder (or NEW FOLDER).
  3. Move the classes.dex file into the dex2jar folder.
  4. Now open command prompt and change directory to that folder (or NEW FOLDER). Then write d2j-dex2jar classes.dex (for mac terminal or ubuntu write ./d2j-dex2jar.sh classes.dex) and press enter. You now have the classes.dex.dex2jar file in the same folder. 
  5. Download java decompiler, double click on jd-gui, click on open file, and open classes.dex.dex2jar file from that folder: now you get class files.
  6. Save all of these class files (In jd-gui, click File -> Save All Sources) by src name. At this stage you get the java source but the .xml files are still unreadable, so continue.

Step 3:

Now open another new folder
  1. Put in the .apk file which you want to decode
  2. Download the latest version of apktool AND apktool install window (both can be downloaded from the same link) and place them in the same folder.
  3. Open a command window.
  4. apktool d myApp.apk (where myApp.apk denotes the filename that you want to decode)
Now you get a file folder in that folder and can easily read the apk's xml files.

Step 4:

It's not any step just copy contents of both folder(in this case both new folder)to the single one
and enjoy the source code...
Source: stackoverflow.com
Read More