<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Madhu Cynix on Medium]]></title>
        <description><![CDATA[Stories by Madhu Cynix on Medium]]></description>
        <link>https://medium.com/@madhucynixit?source=rss-8178ed0d22ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MdoZ26wr6XcjN1tA.jpg</url>
            <title>Stories by Madhu Cynix on Medium</title>
            <link>https://medium.com/@madhucynixit?source=rss-8178ed0d22ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:25:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madhucynixit/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[10 Top Selenium WebDriver Commands For Test Automation]]></title>
            <link>https://medium.com/@madhucynixit/10-top-selenium-webdriver-commands-for-test-automation-7a435693732f?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a435693732f</guid>
            <category><![CDATA[selenium-test-automation]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Thu, 30 Jan 2020 06:06:25 GMT</pubDate>
            <atom:updated>2020-01-30T06:06:25.015Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*EQTfXFNWV9knwcAaRUR7Vg.jpeg" /></figure><p><strong>Basic Commands List for Selenium Web driver</strong></p><ol><li>To Select Multiple Items in a Drop down</li><li>get() commands</li><li>Use of linkText() and partialLinkText() command</li><li>Form Submission Command</li><li>Using quit() and close() Commands</li><li>Command to handle Multiple Frames</li><li>findElements(By,by) and click() Command</li><li>isEnabled() Command</li><li>Using findElements(By, by) with sendKeys() Command</li><li>Using findElements(By, by) with getText() Command</li></ol><h4><strong>1. To Select Multiple Items in a Drop down</strong></h4><p>There are two options which you can use to select items in a drop-down i.e. single select dropdown and multi-select drop-down. <strong>Single select dropdown </strong>allows the user to select only one item from the drop-down whereas <strong>Multiple-select dropdown </strong>allows the user to select multiple items from the dropdown list.</p><p>To get in-Depth knowledge on Selenium you can enroll for live <a href="https://onlineitguru.com/selenium-training.html"><strong>Selenium Online Training</strong></a></p><p>You can use this code to generate a list in which you can select multiple items in a drop-down.</p><pre>&lt;select name=”Country” multiple size=”6”&gt;</pre><pre>&lt;option value=”India”&gt;India&lt;/option&gt;</pre><pre>&lt;option value=”Belgium”&gt;Belgium&lt;/option&gt;</pre><pre>&lt;option value=”England”&gt;England&lt;/option&gt;</pre><pre>&lt;option value=”France”&gt;France&lt;/option&gt;</pre><pre>&lt;option value=”Italy”&gt;Italy&lt;/option&gt;</pre><pre>&lt;/select&gt;</pre><p>When a form is submitted the value has to be sent to a server, this value is sent specifically by the <strong>value</strong> attribute. Content will pass as a value if the value attribute is not specified.</p><p>Syntax- &lt;option value=”<em>value</em>”&gt; where ‘<em>value’ </em>is the value which has to be sent o the server.</p><h4><strong>2. get() commands</strong></h4><ul><li><strong>get(): </strong>This command is used to launch a new browser with the specific URL in the browser. This command uses a single string type which is generally the URL of the application under test. The syntax of the command can be given as driver.get(<a href="https://facebook.com/">http://facebook.com</a>)</li><li><strong>getCurrentUrl(): </strong>The command is used to fetch the current URL of the webpage which user is accessing. It returns a string value and doesn’t need any external parameters. The syntax of the command is given as driver.getCurrentURL();</li><li><strong>getTitle(): </strong>This command fetches the title of the webpage which user is currently using. This command doesn’t require any external parameters and returns a string value. If the webpage doesn’t have any title it will return a null string. The syntax of the command is given as String new = driver.getTitle();</li><li><strong>getAttribute(): </strong>This command is used to fetch the value of the specific attribute. This command uses a string which refers to an attribute whose value we want to know and returns a string value. The syntax of the command is given as driver.findElements(By.name(“x”)).getAttribute(“value”);</li><li><strong>getText(): </strong>This command is used fetch the inner text of the element including sub-elements. This command returns a string value and doesn’t need any external parameters. This command is often used for verification or errors in the message or content in the web pages. The syntax of the command is given as String new = driver.findElements(By.name(“Inner_text”)).getText();</li><li><strong>getClass(): </strong>This command is used to fetch the class object. The syntax of the command is given as driver.getClass();</li><li><strong>getPageSource(): </strong>This command is used to fetch the page of the web page which user is currently working on. This command returns a string value and doesn’t require any other parameters. The syntax of the command is given as String new = driver.getPageSource();</li></ul><h4><strong>3. Use of linkText() and partialLinkText() command</strong></h4><p>These commands are used to access the hyperlinks which are available on a webpage. By using these commands user is redirected to another page.</p><p>Let us consider there are two links mentioned in the webpage Google and Yahoo.</p><ul><li><strong>linkText(): </strong>Twitter and Yahoo links can be accessed using the command driver.findElements(By.linkText(“Twitter”)).click();</li></ul><p>driver.findElements(By.linkText(“Yahoo”)).click();</p><p>This command finds the element by using linkText() and then click on that link. The user is then redirected to the page followed by the link.</p><ul><li><strong>partialLinkText():</strong> Links can be accessed by using command driver.findElements(By.partialLinkText(“Twitt”)).click();</li></ul><p>driver.findElements(By.partialLinkText(“Yaho”)).click();</p><p>This command finds the element partially by using partialLinkText() and then clicks on it.</p><h4><strong>4. Form Submission Command</strong></h4><p>Almost every webpage contain forms which have to be filled by the user. There are various types of forms like login, registration, file upload or new signup etc. While testing of the website the command submit() is used. It triggers the submit button without clicking on the submit button. The code for the form submission is as follows:</p><pre>//First Name</pre><pre>&lt;input type=”text” name=”FirstName”&gt;</pre><pre>//Last Name</pre><pre>&lt;inpur type=”text” name=”LastName”&gt;</pre><pre>//Email ID</pre><pre>&lt;input type=”text” name=”EmailID”&gt;</pre><pre>//Mobile Number</pre><pre>&lt;input type=”text” name=”MobileNo”&gt;</pre><pre>&lt;input type=”submit” value=”submit”&gt;</pre><h4><strong>5. Using quit() and close() Commands</strong></h4><p>These commands are used to close the web pages which are currently used by the user.</p><ul><li><strong>quit(): </strong>The quit() command is used to close down all the web pages in the web browser. All the web pages which are being opened by the users are closes down instantly. The syntax of the command is given as driver.quit(); This command doesn’t need any other parameters and doesn’t return any value.</li><li><strong>close(): </strong>the close() command is used to close down the current webpage which is being opened by the user. This command only closes a single webpage unlike quit(). This command doesn’t need any other parameters and doesn’t return any value. The syntax of the command is given as driver.close();</li></ul><p>To get in-Depth knowledge on Selenium you can enroll for live <a href="https://onlineitguru.com/selenium-training.html"><strong>Selenium Training</strong></a></p><h4><strong>6. Command to handle Multiple Frames</strong></h4><p>There are scenarios where the users have to work on various frames and iframes. The script tester verifies the working of the frames through script code. The illustration of the code is given below where there are different frames in the webpage.</p><pre>&lt;html&gt;</pre><pre>&lt;head&gt;</pre><pre>&lt;title&gt;Window handle&lt;/title&gt;</pre><pre>&lt;/head&gt;</pre><pre>&lt;body&gt;</pre><pre>&lt;div&gt;</pre><pre>&lt;iframe id=”FirstFrame”&gt;</pre><pre>&lt;iframe id=”SecondFrame”&gt;</pre><pre>&lt;input type=”text” id=”Name”&gt;FirstName&lt;/input&gt;</pre><pre>&lt;input type=”text” id=”Name”&gt;LastName&lt;/input&gt;</pre><pre>&lt;/iframe&gt;</pre><pre>&lt;button id=”Submit”&gt;Submit&lt;/button&gt;</pre><pre>&lt;/iframe&gt;</pre><pre>&lt;/div&gt;</pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>In this HTML code, two iframes are present. Thus to access the second frame user has to navigate through the first frame. Only by dealing first frame user are allowed to navigate to the second frame. It is impossible for the user to access directly the second frame without using the first frame.</p><ul><li><strong>Frame(index): </strong>swtichTo().frame(0);</li><li><strong>Frame(frame name):</strong>switchTo().frame(Frame name”);</li><li><strong>Frame(Web element):</strong>switchTo().defaultContent();</li></ul><p>These commands can be used by the user to return back to the main window.</p><ul><li><strong>Selecting iframe by ID: </strong>switchTo().frame(“Frame ID”);</li></ul><h4><strong>7. findElements(By,by) and click() Command</strong></h4><p>This command is used by the user to search or locate the first element on the webpage. The parameters which are used in the syntax fetch the element on the current working page. Click, submit or another type of actions are mainly used by this command. The syntax of this command is given as driver.findElements(By.Name(”login”)).click();</p><h4><strong>8. isEnabled() Command</strong></h4><p>This command is used to check whether the element in the selenium webdriver is enabled or not. The syntax of this command is given as</p><p>Boolean check = driver.findElements(By.xpath(“Name”)).isEnabled();</p><p>This command finds the element and checks whether the element is enabled or disabled.</p><h4><strong>9. Using findElements(By, by) with sendKeys() Command</strong></h4><p>This command is typically used for filling in forms. The general syntax for this command is given as driver.findElements(By.name(“FirstName”)).sendkeys(“Tony”);</p><p>This command will search for the first name field and then enter the value “Tony” in it.</p><h4><strong>10. Using findElements(By, by) with getText() Command</strong></h4><p>With the help of the getText() command, it will get the inner element of the webpage. By using this command we can store the value of the element into the string object. The syntax for this command can be given as</p><p>String new = driver.findElements(By.TagName(“NewFile”)).getText();</p><p>This command will look for the field name “new file” then take its inner file and stores it into the string name “new”.</p><p>Take your career to new heights of success with an <a href="https://onlineitguru.com/selenium-training.html"><strong>Selenium Certification</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a435693732f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Rules about Catching Exceptions in Java]]></title>
            <link>https://medium.com/@madhucynixit/5-rules-about-catching-exceptions-in-java-8aee0697b747?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/8aee0697b747</guid>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java8]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 04:38:21 GMT</pubDate>
            <atom:updated>2020-01-23T04:38:21.932Z</atom:updated>
            <content:encoded><![CDATA[<p>This article dives deeply into catching exceptions in order to help you understand more about exception handling in Java. for more <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Learn Java Online</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*gdX4Bdqqbe487Y3hZiHhgg.jpeg" /></figure><h4>1. Catching multiple exceptions</h4><p>There are as many catch blocks as the number of exceptions which can be thrown from the code safeguarded by the try block. Here’s an example:</p><pre><strong>try</strong> {</pre><pre>LineNumberReader lineReader = <strong>new</strong> LineNumberReader(<strong>new</strong> FileReader(&quot;hello.txt&quot;));</pre><pre>String line = lineReader.readLine();</pre><pre>lineReader.close();</pre><pre>System.out.println(line);</pre><pre>} <strong>catch</strong> (FileNotFoundException ex) {</pre><pre>System.err.println(&quot;Find not found&quot;);</pre><pre>} <strong>catch</strong> (IOException ex) {</pre><pre>System.err.println(&quot;Error reading file&quot;);</pre><pre>}</pre><p>In the above code, the first line in the tryblock can throw FileNotFoundException if the specified file could not be located on disk; and the next two lines can throw IOException if an error occurred during the reading and closing the file. Hence there are two catch blocks for handling both exceptions.</p><p>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></p><h4>2. The order of catch blocks does matter</h4><p>If the protected code can throw different exceptions which are not in the same inheritance tree, i.e. they don’t have parent-child relationship, the catch blocks can be sorted any order.</p><p>However, keep in mind this rule: if the exceptions have parent-child relationship, the catch blocks must be sorted by the most specific exceptions first, then by the most general ones.</p><p>In the above example, FileNotFoundException is a child of IOException so its catch block must come first. If we try to catch the IOException before FileNotFoundException, the compiler will issue an error like this:</p><p>error: exception FileNotFoundException has already been caught</p><p>Why? It’s because if we handle the most general exceptions first, the more specific exceptions will be omitted, which is not good, as Java encourages handling exceptions as much specific as possible.</p><h4>3. Catching one exception for all</h4><p>If we catch the most general exception first, then we also catch other exceptions which are subtypes of the general exception. For example, the above example can be re-written to catch only the IOException which is also parent of FileNotFoundException:</p><pre><strong>try</strong> {</pre><pre>LineNumberReader lineReader = <strong>new</strong> LineNumberReader(<strong>new</strong> FileReader(&quot;hello.txt&quot;));</pre><pre>String line = lineReader.readLine();</pre><pre>lineReader.close();</pre><pre>System.out.println(line);</pre><pre>} <strong>catch</strong> (IOException ex) {</pre><pre>System.err.println(&quot;Error reading file&quot;);</pre><pre>}</pre><p>Let’s see another example. Consider the following code:</p><pre><strong>public</strong> <strong>static</strong> <strong>void</strong> doCrypto(<strong>int</strong> cipherMode, String key, File inputFile,</pre><pre>File outputFile) <strong>throws</strong> CryptoException {</pre><pre><strong>try</strong> {</pre><pre>Key secretKey = <strong>new</strong> SecretKeySpec(key.getBytes(), &quot;AES&quot;);</pre><pre>Cipher cipher = Cipher.getInstance(&quot;AES&quot;);</pre><pre>cipher.init(cipherMode, secretKey);</pre><pre>FileInputStream inputStream = <strong>new</strong> FileInputStream(inputFile);</pre><pre><strong>byte</strong>[] inputBytes = <strong>new</strong> <strong>byte</strong>[(<strong>int</strong>) inputFile.length()];</pre><pre>inputStream.read(inputBytes);</pre><pre><strong>byte</strong>[] outputBytes = cipher.doFinal(inputBytes);</pre><pre>FileOutputStream outputStream = <strong>new</strong> FileOutputStream(outputFile);</pre><pre>outputStream.write(outputBytes);</pre><pre>inputStream.close();</pre><pre>outputStream.close();</pre><pre>} <strong>catch</strong> (NoSuchPaddingException ex) {</pre><pre>System.err.println(&quot;no padding&quot;);</pre><pre>} <strong>catch</strong> (NoSuchAlgorithmException ex) {</pre><pre>System.err.println(&quot;no algorithm&quot;);</pre><pre>} <strong>catch</strong> (InvalidKeyException ex) {</pre><pre>System.err.println(&quot;invalid key&quot;);</pre><pre>} <strong>catch</strong> (BadPaddingException ex) {</pre><pre>System.err.println(&quot;bad padding&quot;);</pre><pre>} <strong>catch</strong> (IllegalBlockSizeException ex) {</pre><pre>System.err.println(&quot;illegal block&quot;);</pre><pre>} <strong>catch</strong> (IOException ex) {</pre><pre>System.err.println(&quot;error reading file&quot;);</pre><pre>}</pre><pre>}</pre><p>Here, there are 6 catch blocks to handle each exception individually. We can catch all these exception by only one catch block as following:</p><pre><strong>public</strong> <strong>static</strong> <strong>void</strong> doCrypto(<strong>int</strong> cipherMode, String key, File inputFile,</pre><pre>File outputFile) <strong>throws</strong> CryptoException {</pre><pre><strong>try</strong> {</pre><pre>Key secretKey = <strong>new</strong> SecretKeySpec(key.getBytes(), &quot;AES&quot;);</pre><pre>Cipher cipher = Cipher.getInstance(&quot;AES&quot;);</pre><pre>cipher.init(cipherMode, secretKey);</pre><pre>FileInputStream inputStream = <strong>new</strong> FileInputStream(inputFile);</pre><pre><strong>byte</strong>[] inputBytes = <strong>new</strong> <strong>byte</strong>[(<strong>int</strong>) inputFile.length()];</pre><pre>inputStream.read(inputBytes);</pre><pre><strong>byte</strong>[] outputBytes = cipher.doFinal(inputBytes);</pre><pre>FileOutputStream outputStream = <strong>new</strong> FileOutputStream(outputFile);</pre><pre>outputStream.write(outputBytes);</pre><pre>inputStream.close();</pre><pre>outputStream.close();</pre><pre>} <strong>catch</strong> (Exception ex) {</pre><pre>System.err.println(&quot;error&quot;);</pre><pre>}</pre><pre>}</pre><p>It’s easy to understand because Exception is the supertype of all exceptions. However, this practice is not recommended, as it makes the programmers lazy: catching one is obviously quicker than catching many. That means the programmers do not take responsibility to handle exceptions carefully. The good practice recommends catching specific exceptions so the program can handle different situations well. Java doesn’t prohibit you from catching one for all, but when doing so, you should have good reasons to do that.</p><p>Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java certification course</strong></a></p><h4>4. Grouping multiple exceptions in one catch</h4><p>Since Java 7, we can combine multiple exceptions in a single catch clause. This becomes very handy in case we want to apply the same handling for those exceptions. For example, the above code can be re-written using a multi-catch statement like this:</p><pre><strong>public</strong> <strong>static</strong> <strong>void</strong> doCrypto(<strong>int</strong> cipherMode, String key, File inputFile,</pre><pre>File outputFile) <strong>throws</strong> CryptoException {</pre><pre><strong>try</strong> {</pre><pre>Key secretKey = <strong>new</strong> SecretKeySpec(key.getBytes(), “AES”);</pre><pre>Cipher cipher = Cipher.getInstance(“AES”);</pre><pre>cipher.init(cipherMode, secretKey);</pre><pre>FileInputStream inputStream = <strong>new</strong> FileInputStream(inputFile);</pre><pre><strong>byte</strong>[] inputBytes = <strong>new</strong> <strong>byte</strong>[(<strong>int</strong>) inputFile.length()];</pre><pre>inputStream.read(inputBytes);</pre><pre><strong>byte</strong>[] outputBytes = cipher.doFinal(inputBytes);</pre><pre>FileOutputStream outputStream = <strong>new</strong> FileOutputStream(outputFile);</pre><pre>outputStream.write(outputBytes);</pre><pre>inputStream.close();</pre><pre>outputStream.close();</pre><pre>} <strong>catch</strong> (NoSuchPaddingException | NoSuchAlgorithmException</pre><pre>| InvalidKeyException | BadPaddingException</pre><pre>| IllegalBlockSizeException | IOException ex) {</pre><pre>System.err.println(&quot;error&quot;);</pre><pre>}</pre><pre>}</pre><p>Note that we can group only un-related exceptions together. That means it’s illegal to group exceptions which have parent-child relationship. For example, it’s illegal to write a multi-catch statement like this:</p><pre><strong>try</strong> {</pre><pre>LineNumberReader lineReader = <strong>new</strong> LineNumberReader(<strong>new</strong> FileReader(&quot;hello.txt&quot;));</pre><pre>String line = lineReader.readLine();</pre><pre>lineReader.close();</pre><pre>System.out.println(line);</pre><pre>} <strong>catch</strong> (FileNotFoundException | IOException ex) {</pre><pre>System.err.println(&quot;Find not found&quot;);</pre><pre>}</pre><p>The compiler will complain:</p><pre>error: Alternatives in a multi-catch statement cannot be related by subclassing</pre><h3>5. What should you do in the catch blocks?</h3><p>It’s up to you to write anything inside the catch blocks. Remember the main purpose of the catch blocks is to recover the program from the exceptions and continue execution, such as notifying the user about the error, ask he or she to wait, try again or exit, etc.</p><p>Typically, you can do the following things in the catch blocks (not limited to):</p><ul><li>Print out the exception details via System.err class’ methods, then exit the method:</li></ul><pre>System.err.println(ex);</pre><pre>System.err.println(ex.getMessage());</pre><ul><li>Print the full stack trace of the exception and exit the method:</li></ul><p>ex.printStackTrace();</p><ul><li>Log the exceptions then exit the method. You can use Java’s built-in logging functionalities or a third-part library like log4j.</li><li>Display an error message dialog in case the program is a desktop application (Swing or JavaFX).</li><li>Redirect the user to an error page in case the program is a web application (Servlets &amp; JSP).</li></ul><h4>Related Articles</h4><ul><li><a href="https://medium.com/@madhucynixit/top-10-java-applications-722029e7e936"><strong>Top 10 Java Applications</strong></a></li><li><a href="https://medium.com/@madhucynixit/core-java-interview-questions-f8291d978de2"><strong>Core Java Interview Questions</strong></a></li><li><a href="https://medium.com/@madhucynixit/the-best-java-tools-for-testing-and-integration-ac5e6a37fb7c"><strong>The Best Java Tools for Testing and Integration</strong></a></li></ul><h4>This Article Source From</h4><p><a href="https://www.codejava.net/java-core/exception/5-rules-about-catching-exceptions-in-java">5 Rules about Catching Exceptions in Java</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aee0697b747" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 10 Java Applications]]></title>
            <link>https://medium.com/@madhucynixit/top-10-java-applications-722029e7e936?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/722029e7e936</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[java-applications]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Wed, 22 Jan 2020 04:52:01 GMT</pubDate>
            <atom:updated>2020-01-22T04:52:01.309Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*DDOq8arDOd-rbywSZ3YUaw.jpeg" /></figure><p>Java is the wonder programming language that is widely used for most of the modern day computing jobs, from designing websites to game applications to preparing interactive video to any other application jobs. Here are our picks on top 10 Java applications.</p><blockquote>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></blockquote><p><strong>Java</strong> is the wonder programming language that is widely used for most of the modern day computing jobs, from designing websites to game applications to preparing interactive video to any other application jobs. Without <strong>java applications</strong> we just cannot think of any sleazy, smart computer applications that day in day out serve multiple audio visual and interactive purposes over the internet space. There are great array of top java applications that are popular among the developers and web designers and there are applications that work as utility services on our devices or there are applications that can work as a superb application developer right on your existing mobile platform. Here are our picks on <strong>top 10 Java applications</strong>.</p><p><a href="https://onlineitguru.com/tutorial/applications-of-java">Java Applications and program stuctures | OnlineITGuru</a></p><ol><li><strong>Nimbuzz Messenger:- Nimbuzz</strong> is the smartest candidate among the dedicated <strong>Java applications</strong> for instant massaging or chat purpose on multiple domains. Like many similar applications on its category it provides single window chat facility on multiple chat domains like Yahoo, MSN, Google Talk, Facebook, MySpace, ICQ and many more. Nimbuzz is smarter because it lets the user create his or her own chat buddy using Nimbuzz API, drive users to your site and hugely popular with coverage of 200+ countries and 100 million users. Nimbuzz is free and supports all major platforms including iPhone, Symbian, Blackberry, Android, Mac, J2ME, PC and Web.</li><li><strong>NewsHunt:- </strong>It is practically a newspaper vendor on your mobile screen offering all sorts of news publications for free of cost. From regional local news publications to international ones, from local daily in the local language to the international language dailies, the news is served from all categories, languages and publications as per your choice. With more than 85 publications and multiple language options this is the most complete local language application.</li><li><strong>EQO:- </strong>Among the loads of <strong>Java applications</strong> for different array of utilities on your handheld devices and phones <strong>EQO</strong> is truly a wonder with cheapest international calls, cheap text messages and access to all instant messenger services and chat rooms for real time chat. This free application let you make international calls at a rate which is as low as 2.3 cents per minute. It supports all chat and massage services like Yahoo, MSN, Google Talk, ICQ, AIM and many more. On top of that the application is remarkably simple for any user and is free.</li><li><strong>Java Call Recorder:- </strong>Call recording can sometimes be needed for handling security issues and unsolicited calls from unknown and fishy sources, but all phones do not support a good call recording option even though they are smarter enough to offer all multimedia play options, chatting and internet. This dedicated Java application for call recording can be a handy choice for the particular need. Phones that do not have in built call recorder can have one with this easy to use application. The application is free and just after the installation all you have to do is to access the menu and click on the ‘record’ option as and when you would be requiring to record calls.</li><li><strong>E Buddy Messenger:- </strong>Some <strong>Java applications</strong> are hugely popular these days thanks to widespread use of mobile computing and mobile devices. This smooth chat application let you chat on different chatting platforms or domains without requiring you to log in separately with every one of them. Message chat and photo uploading right from your phone on different popular chat domains including MSN, Google Talk, Facebook, AIM, ICQ, MySpace, Yahoo and many more just with the same application window. Take your career to new heights of success with an<strong> </strong><a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Course</strong></a></li><li><strong>Komik Reader:- </strong>Though this hugely popular Java application was specifically built for Android phones and tablets, this is irreplaceable from a list of <strong>top 10 Java applications</strong> simply due to its merit for providing a dedicated comic book reading application for the first time. Some of the key features that make this application a fun among its adherents and recipients include, CBZ, CBR and other image directory support, smooth bookmarking on continuous basis, zoom in feature for better readability, comic collection browser support and many more. It’s a java powered fun destination for the comic enthusiasts on their Android devices.</li><li><strong>jQuery:- </strong>This open source <strong>JavaScript library</strong> is a must pick choice in relation to naming a few application for the web designers or programmers. <strong>jQuery</strong> is a JavaScript library that was long championed among the web designers and developers for its simplified client side scripting support. But <a href="https://www.roseindia.net/ajax/jquery/index.shtml"><strong>jQuery</strong></a> is more than just smart JavaScript library with array of features like Ajax application tools, event management, animation creating, creating additional plugins, DOM element selection, etc. Already being the most popular Java tool in US and being integrated as part of standard Microsoft and Nokia specifications, you can hardly ignore this formidable Java candidate.</li><li><strong>JavaFX Script:- </strong>This compiled java based scripting language application can let you create user friendly interfaces like Adobe Flash. The java application is in a developing mode and a lot of new developments are about to come in near future. For instance, graphical designer tool which is in the process of being developed can make the application function like Adobe Illustrator plugin. Key Frame Animation just been added with this Java application very recently.</li><li><strong>ThinkFree:- </strong>You cannot name a lot of <strong>java applications</strong> that provides such a wide range of compatibility with the stalwart operating programs like Microsoft. Yes, with word processing, spread sheet and presentation application all put together this great Java tool is really an all round gem. Just in the fashion of Microsoft you can create, edit and update your documents smoothly on any device.</li><li><strong>Opera Mini:- </strong>This smart java application is really a hot favorite for the mobile internet users since it is known to make more rooms and make page speed faster by compressing the unwanted graphics of the web page. Still there are so many websites that are not mobile ready to support all types of handheld devices in the same way and for them this beautiful little java tool can really be smooth like honey with the capability of reformatting the HTML content as per the viewable requirement of the device.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=722029e7e936" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core Java Interview Questions]]></title>
            <link>https://medium.com/@madhucynixit/core-java-interview-questions-f8291d978de2?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8291d978de2</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-programming]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Tue, 21 Jan 2020 03:49:00 GMT</pubDate>
            <atom:updated>2020-01-21T03:49:00.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*TZ1tjfUmQNKRBF9t9BkN1A.png" /></figure><h4>1. What is Java?</h4><p><a href="https://onlineitguru.com/blog/what-is-java"><strong>Java</strong></a><strong> </strong>is the high-level, object-oriented, robust, secure programming language, platform-independent, high performance, Multithreaded, and portable programming language. It was developed by James Gosling in June 1991. It can also be known as the platform as it provides its own JRE and API.</p><h4><strong>2. What do you mean by Object?</strong></h4><p>An object consists of methods and class which represent it’s formal and perform operations. A java program covers a lot of objects initiating each other their jobs. This concept is a like part of core java. To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></p><h4><strong>3. What do you understand by Java virtual machine?</strong></h4><p>Java Virtual Machine is a virtual machine that enables the computer to run the Java program. JVM acts like a run-time engine which calls the main method present in the Java code. JVM is the specification which must be implemented in the computer system. The Java code is compiled by JVM to be a Bytecode which is machine independent and close to the native code.</p><h4><strong>4. Why Java is platform independent?</strong></h4><p>Java is called platform independent because of its byte codes which can run on any system irrespective of its underlying operating system.</p><h4><strong>5. What are wrapper classes in Java?</strong></h4><p>Wrapper classes convert the Java primitives into the reference types (objects). Every primitive data type has a class dedicated to it. These are known as wrapper classes because they “wrap” the primitive data type into an object of that class. Refer to the below image which displays different primitive type, wrapper class and constructor argument.</p><h4><strong>6. What is JIT compiler?</strong></h4><p>Just-In-Time(JIT) compiler: It is used to improve the performance. JIT compiles parts of the bytecode that have similar functionality at the same time, and hence reduces the amount of time needed for compilation. Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU. To get in-Depth knowledge on JIT compiler you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></p><h4><strong>7. What if I write static public void instead of public static void?</strong></h4><p>The program compiles and runs correctly because the order of specifiers doesn’t matter in Java.</p><h4><strong>8. What is the default value of the local variables?</strong></h4><p>The local variables are not initialized to any default value, neither primitives nor object references.</p><h4><strong>9. What is the purpose of static methods and variables?</strong></h4><p>The methods or variables defined as static are shared among all the objects of the class. The static is the part of the class and not of the object. The static variables are stored in the class area, and we do not need to create the object to access such variables. Therefore, static is used in the case, where we need to define variables or methods which are common to all the objects of the class.</p><p>For example, In the class simulating the collection of the students in a college, the name of the college is the common attribute to all the students. Therefore, the college name will be defined as static.</p><h4><strong>10. What is the constructor?</strong></h4><p>The constructor can be defined as the special type of method that is used to initialize the state of an object. It is invoked when the class is instantiated, and the memory is allocated for the object. Every time, an object is created using the new keyword, the default constructor of the class is called. The name of the constructor must be similar to the class name. The constructor must not have an explicit return type.</p><p>Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java online course</strong></a></p><p>Learn More <a href="https://onlineitguru.com/interviewquestions/java-interview-questions"><strong>Java Interview Questions</strong></a></p><h3>Java Tutorials for Beginners</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLCdhMAaeNLVypGSjrEOS0bo5xoCBwgF2A&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DSJgqjRKB6r4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FSJgqjRKB6r4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a5f97069fb88389be260ce705db96b3/href">https://medium.com/media/5a5f97069fb88389be260ce705db96b3/href</a></iframe><p><a href="https://onlineitguru.com/tutorial/java-introduction">Java Introduction Tutorial | Java Online Tutorial | Online IT Guru</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8291d978de2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Best Java Tools for Testing and Integration]]></title>
            <link>https://medium.com/@madhucynixit/the-best-java-tools-for-testing-and-integration-ac5e6a37fb7c?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac5e6a37fb7c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jdk]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Mon, 20 Jan 2020 04:38:13 GMT</pubDate>
            <atom:updated>2020-01-20T04:38:13.910Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7y9dZ1TWImgCO6QMweX3xA.png" /></figure><p>Whether you’re just starting out or you’ve been at it for a while, programming with the right tools can make a huge difference in a project’s success. The proper tools allow you to write better code and to quickly identify bugs. All of this makes your code better.</p><p>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></p><p>If your programming language of choice is Java, there is no shortage of tools to cover every aspect of Java development, from coding and testing to server integration and documentation. Let’s explore the best of the best.</p><h3>Java Editors and Development</h3><h3>1. Java Development Kit (JDK)</h3><p>JDK is a must-have tool for anyone who plans on developing applets and applications. It includes the Java Runtime Environment, Java compiler, and Java APIs. In other words, it has everything you need to get started, from beginners to experienced programmers new to Java. To get in-Depth knowledge on Java Development Kit (JDK) you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java online course</strong></a></p><h3>2. NetBeans</h3><p>When it comes to Java, NetBeans is one of the most popular IDEs. It’s open-source and comes with powerful features including:</p><ul><li>Support for multiple languages</li><li>A rich set of plugins such as ResinTemplateModule for Java and PHP; a plugin to develop native Java apps for iOS, Android, and Windows; CSS minifier; and more</li><li>Out-of-the-box Git and Maven integration</li><li>Debugger and Profiles to help analyze and fix bugs in your code</li></ul><h3>3. Eclipse IDE</h3><p>Eclipse IDE, another favorite, is used by 54% of Java developers. Like NetBeans, it’s open-source and comes with a wide array of plugins and a customizable interface too. Among a slew of other features, it comes with code completion assistance, syntax checking, and refactoring.</p><h3>4. Groovy</h3><p>Groovy is not an editor but rather a programming language that extends Java’s capabilities by adding new keywords along with auto-importing commonly used classes and optionally typed variable declarations. It also comes with powerful scripting capabilities that allow you to compile classes as Java bytecode or execute them dynamically via the Groovy Shell.</p><h3>Testing</h3><h3>1. Mockito</h3><p>Mockito serves as mocking framework that allows you to create and use simplified versions of objects and procedures for the purposes of automated unit testing. Thanks to its simple and clean API — as well as the fact that you can ask questions after the execution of the program — many programmers consider Mockito a favorite. Mockito can also:</p><ul><li>Mock concrete classes as well as interfaces</li><li>Provide clean verification errors</li><li>Allow flexible verification in the order you specify</li><li>Support exact-number-of-times and at-least-once verification</li></ul><h3>2. JRat</h3><p>JRat (Java Runtime Analysis Toolkit) is a performance profiler for the Java platform. It monitors an application’s execution and persists performance measurements, and then allows you to view and analyze the data using the JRat Desktop application. Use it to identify potential problem areas that may impact the performance of your application.</p><h3>3. JUnit</h3><p>JUnit is a unit testing tool that lets you test your code one block at a time. In other words, you don’t have to wait until you’re completely done writing the code to test it. Features include:</p><ul><li>Assertions for testing expected results</li><li>Test fixtures for sharing common test data</li><li>Test runners for running tests</li></ul><h3>Integration</h3><h3>1. Apache Ant</h3><p>Developed by Apache, this tool supplies you with built-in tasks that not only help develop and compile Java applications but also test them, and help automate repetitive tasks.</p><h3>2. Apache Maven</h3><p>Maven, favored by 68% of Java developers, is a project management build tool that provides a uniform build system, quality project information, and guidelines for best practices development. The main features of Maven include:</p><ul><li>Simple project setup that follows best practices</li><li>Superior dependency management, including automatic updating and dependency closures</li><li>Ability to easily work with multiple projects at the same time</li><li>A large and growing repository of libraries and metadata</li><li>Extensible via plugins written in Java or scripting languages</li></ul><h3>3. Gradle</h3><p>Gradle is a build automation system that among other functions automates the building, testing, and deployment of software packages as well as other types of projects. It combines the best features of ANT with the superior dependency management of Maven, giving you the best of both worlds and a better way to code.</p><h3>Security</h3><h3>1. FindBugs</h3><p>Like the name suggests, this tool helps identify bugs in your code by matching your document against a database of known bugs. It can be used as a standalone GUI or as a plugin for many code editors, including Eclipse and NetBeans.</p><h3>2. SonarQube</h3><p>SonarQube gives you access to an entire platform to analyze your code for bugs and vulnerabilities. Features include:</p><ul><li>Reports on duplicated code, coding standards, unit tests, code coverage, complex code, potential bugs, and more</li><li>Integration with most continuous integration tools</li><li>Multi-language support</li></ul><h3>Servers</h3><h3>1. Apache Tomcat</h3><p>Apache Tomcat is one of the most popular web servers. It implements a number of Java EE specifications such as Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket. It also gives you an HTTP server environment in which to run your code.</p><h3>2. WildFly</h3><p>Another popular server is WildFly, which was developed by Red Hat. It implements the Enterprise Edition of the Java Platform, giving you access to enterprise capabilities on any platform.</p><h3>Improve Your Java Skills</h3><p>Programming can be a lot of fun when you have the right tools for the job. Take your Java skills to the next level by learning to use the most popular tools in the field. Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java certification course</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac5e6a37fb7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why String is Immutable in Java]]></title>
            <link>https://medium.com/@madhucynixit/why-string-is-immutable-in-java-986490912c24?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/986490912c24</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[java8]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Tue, 14 Jan 2020 04:41:02 GMT</pubDate>
            <atom:updated>2020-01-14T04:41:02.035Z</atom:updated>
            <content:encoded><![CDATA[<p>This is an old yet still popular question. There are multiple reasons that String is designed to be immutable in Java. A good answer depends on good understanding of memory, synchronization, data structures, etc. In the following, I will summarize some answers.</p><p><strong>1. Requirement of String Pool</strong></p><p>String pool (String intern pool) is a special storage area in Java heap. When a string is created and if the string already exists in the pool, the reference of the existing string will be returned, instead of creating a new object and returning its reference.</p><p>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></p><p>The following code will create only one string object in the heap.</p><pre>String string1 = &quot;abcd&quot;;<br>String string2 = &quot;abcd&quot;;</pre><p>Here is how it looks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*0oaHKttfDpY8HYzo.jpeg" /></figure><p>If string is not immutable, changing the string with one reference will lead to the wrong value for the other references.</p><p><strong>2. Allow String to Cache its Hashcode</strong></p><p>The hashcode of string is frequently used in Java. For example, in a HashMap. Being immutable guarantees that hashcode will always the same, so that it can be cashed without worrying the changes.That means, there is no need to calculate hashcode every time it is used. This is more efficient.</p><p><strong>3. Security</strong></p><p>String is widely used as parameter for many java classes, e.g. network connection, opening files, etc. Were String not immutable, a connection or file would be changed and lead to serious security threat. The method thought it was connecting to one machine, but was not. Mutable strings could cause security problem in Reflection too, as the parameters are strings.</p><p>Here is a code example:</p><pre>boolean connect(string s){<br>    if (!isSecure(s)) { <br>throw new SecurityException(); <br>}<br>    //here will cause problem, if s is changed before this by using other references.    <br>    causeProblem(s);<br>}</pre><p>Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java online course</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=986490912c24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Factors and Beyond in Java]]></title>
            <link>https://medium.com/@madhucynixit/10-factors-and-beyond-in-java-60855a6a2c44?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/60855a6a2c44</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Mon, 13 Jan 2020 05:01:29 GMT</pubDate>
            <atom:updated>2020-01-13T05:01:29.408Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*VDHe3t_AbuHO1KH5uLliFA.jpeg" /></figure><h3>1. One Codebase</h3><p>While less of a Java-specific concept, this factor generally refers to getting to a single code base managed in source control or a set of repositories from a common root. Getting to a single codebase makes it cleaner to build and push any number of immutable releases across various environments. The best example of violating this is when your app is composed of a dozen or more code repositories. While using one code repository to produce multiple applications can be workable, the goal is a 1:1 relationship between apps and repos. Operating from one codebase can be done but is not without its own challenges. Sometimes one application per repository is the simplest thing that works for a team or organization.</p><h3>2. Dependency Management</h3><p>Most Java (and Groovy) developers can take advantage of facilities like Maven (and Gradle), which provide the means to declare the dependencies your app requires for proper build and execution. The idea is to allow developers to declare dependencies and let the tool ensure those dependencies are satisfied and packaged into a single binary deployment artifact. Plugins like Maven Shade or Spring Boot enable you to bundle your application and its dependencies into a single “uberjar” or “fat jar” and thus provide the means to isolate those dependencies.</p><p>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></p><p>Figure 1 is a portion of an example Spring Boot application Maven build file, pom.xml. This shows the dependency declarations as specified by the developer.</p><pre>&lt;parent&gt;</pre><pre>&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</pre><pre>&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;</pre><pre>&lt;version&gt;1.3.7.RELEASE&lt;/version&gt;</pre><pre>&lt;relativePath/&gt; &lt;!-- lookup parent from repository</pre><pre>--&gt;</pre><pre>&lt;/parent&gt;</pre><pre>&lt;dependencies&gt;</pre><pre>&lt;dependency&gt;</pre><pre>&lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</pre><pre>&lt;artifactId&gt;spring-cloud-starter-config&lt;/artifactId&gt;</pre><pre>&lt;/dependency&gt;</pre><pre>&lt;dependency&gt;</pre><pre>&lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</pre><pre>&lt;artifactId&gt;spring-cloud-starter-eureka&lt;/artifactId&gt;</pre><pre>&lt;/dependency&gt;</pre><pre>&lt;dependency&gt;</pre><pre>&lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</pre><pre>&lt;artifactId&gt;spring-cloud-starter-zipkin&lt;/artifactId&gt;</pre><pre>&lt;/dependency&gt;</pre><p>Figure 2 is a portion of listed dependencies within the same application, showing JARs bundled into the application’s uberjar, which isolates those dependencies from variations in the underlying environment. The application will rely upon these dependencies rather than potentially conflicting libraries present in the deployment target.</p><pre>[INFO] Scanning for projects...</pre><pre>[INFO]</pre><pre>[INFO] ------------------------------------------------------------------------</pre><pre>[INFO] Building quote-service 0.0.1-SNAPSHOT</pre><pre>[INFO] ------------------------------------------------------------------------</pre><pre>[INFO]</pre><pre>[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @quote-service ---</pre><pre>[INFO] com.example:quote-service:jar:0.0.1-SNAPSHOT</pre><pre>[INFO] +- org.springframework.cloud:spring-cloud-starterconfig:jar:1.1.3.RELEASE:compile</pre><pre>[INFO] | +- org.springframework.cloud:spring-cloud-starter:jar:1.1.1.RELEASE:compile</pre><pre>[INFO] | | +- org.springframework.cloud:spring-cloud-context:jar:1.1.1.RELEASE:compile</pre><pre>[INFO] | | | \- org.springframework.security:springsecurity-crypto:jar:4.0.4.RELEASE:compile</pre><pre>[INFO] | | +- org.springframework.cloud:spring-cloud-commons:jar:1.1.1.RELEASE:compile</pre><pre>[INFO] | | \- org.springframework.security:spring-securityrsa:jar:1.0.1.RELEASE:compile</pre><pre>[INFO] | | \- org.bouncycastle:bcpkixjdk15on:jar:1.47:compile</pre><pre>[INFO] | | \- org.bouncycastle:bcprovjdk15on:jar:1.47:compile</pre><pre>[INFO] | +- org.springframework.cloud:spring-cloud-configclient:jar:1.1.2.RELEASE:compile</pre><pre>[INFO] | | \- org.springframework.boot:spring-boot-autoconfigure:jar:1.3.7.RELEASE:compile</pre><pre>[INFO] | \- com.fasterxml.jackson.core:jacksondatabind:jar:2.6.7:compile</pre><pre>[INFO] | \- com.fasterxml.jackson.core:jacksoncore:jar:2.6.7:compile</pre><pre>[INFO] +- org.springframework.cloud:spring-cloud-startereureka:jar:1.1.5.RELEASE:compile</pre><pre>[INFO] | +- org.springframework.cloud:spring-cloud-netflixcore:jar:1.1.5.RELEASE:compile</pre><pre>[INFO] | | \- org.springframework.boot:springboot:jar:1.3.7.RELEASE:compile</pre><h3>3. Build, Release, Run</h3><p>A single codebase is taken through a build process to produce a single artifact; then merged with configuration information external to the app. This is then delivered to cloud environments and run. Never change code at runtime! The notion of Build leads naturally to continuous integration (CI), since those systems provide a single location that assemble artifacts in a repeatable way.</p><p>Modern Java frameworks can produce uberjars, or the more traditional WAR file, as a single CI-friendly artifact. The Release phase merges externalized configuration (see Configuration below) with your single app artifact and dependencies like the JDK, OS, and Tomcat. The goal is to produce a release that can be executed, versioned, and rolled back. The cloud platform takes the release and handles the Run phase in a strictly separated manner.</p><h3>4. Configuration</h3><p>This factor is about externalizing the type of configuration that varies between deployment environments (dev, staging, prod). Configuration can be everywhere: littered among an app’s code, in property sources like YAML, Java properties, environment variables (env vars), CLI args, system properties, JNDI, etc. There are various solutions — refactor your code to look for environment variables.</p><blockquote>Learn <a href="https://onlineitguru.com/interviewquestions/java-interview-questions"><strong>Java Interview Questions</strong></a></blockquote><p>For simpler systems, a straightforward solution is to leverage Java’s System.getenv() to retrieve one or more settings from the environment, or a Map of all keys and values present. Figure 3 is an example of this type of code.</p><pre>private String userName = System.getenv(“BACKINGSERVICE_UID”);</pre><pre>private String password = System.getenv(“BACKINGSERVICE_PASSWORD”);</pre><h3>5. Logs</h3><p>Logs should be treated as event streams: a time-ordered sequence of events emitted from an application. Since you can’t log to a file in a cloud, you log to stdout/stderr and let the cloud provider or related tools handle it. For example, Cloud Foundry’s loggregator will turn logs into streams so they can be aggregated and managed centrally. stdout/stderr logging is simple in Java:</p><pre>Logger log = Logger.getLogger(MyClass.class.getName());</pre><pre>log.setLevel(Level.ALL);</pre><pre>ConsoleHandler handler = new ConsoleHandler();</pre><pre>handler.setFormatter(new SimpleFormatter());</pre><pre>log.addHandler(handler);</pre><pre>handler.setLevel(Level.ALL);</pre><pre>log.fine(“This is fine.”);</pre><h3>6. Disposability</h3><p>If you have processes that take a while to start up or shut down, they should be separated into a backing service and optimized to accelerate performance. A cloud process is disposable — it can be destroyed and created at any time. Designing for this helps to ensure good uptime and allows you to get the benefit of features like auto-scaling.</p><h3>7. Backing Services</h3><p>A backing service is something external your app depends on, like a database or messaging service. The app should declare that it needs a backing service vi$$anonymous$$n external config, like YAML or even a source-controlled config server. A cloud platform handles binding your app to the service, ideally attaching and reattaching without restarting your app. This loose coupling has many advantages, like allowing you to use the circuit breaker pattern to gracefully handle an outage scenario.</p><h3>8. Environmental Parity</h3><p>Shared development and QA sandboxes have different scale and reliability profiles from production, but you can’t make snowflake environments! Cloud platforms keep multiple app environments consistent and eliminate the pain of debugging environment discrepancies.</p><h3>9. Administrative Processes</h3><p>These are things like timer jobs, one-off scripts, and other things you might have done using a programming shell. Backing Services and other capabilities from cloud platforms can help run these, and while Java doesn’t (currently) ship with a shell like Python or Ruby, the ecosystem has lots of options to make it easy to run one-off tasks or make a shell interface.</p><h3>10. Port Binding</h3><p>In the non-cloud world, it’s typical to see several apps running in the same container, separating each app by port number and then using DNS to provide a friendly name to access. In the cloud you avoid this micromanagement — the cloud provider will manage port assignment along with routing, scaling, etc.</p><p>Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java online course</strong></a></p><p>While it is possible to rely upon external mechanisms to provide traffic to your app, these mechanisms vary among containers, machines, and platforms. Port binding provides you full control over how your application receives and responds to requests made of it, regardless of where it is deployed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60855a6a2c44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Node.js for Java Developers?]]></title>
            <link>https://medium.com/@madhucynixit/what-is-node-js-for-java-developers-13effde9b903?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/13effde9b903</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Sat, 11 Jan 2020 03:53:29 GMT</pubDate>
            <atom:updated>2020-01-11T03:53:29.741Z</atom:updated>
            <content:encoded><![CDATA[<p>We all know that Node.js is getting all the attention nowadays. Everyone is interested in learning Node.js and wants to work on it. It would be good to understand the concepts behind a technology before starting work on it. But for beginners, it might be confusing with different definitions used by different people. What exactly is Node.js? Is it a new language or a new framework or a new tool or just a simple JavaScript file? Even for experienced Java developers, it’s little difficult to quickly get an idea about Node.js. Hence, in this article, I will try to explain Node.js for a Java developer.</p><h3>The Runtime Environment</h3><p>We know that Java needs a runtime environment called JRE for running a Java program. The JRE has a virtual machine called Java Virtual Machine (JVM). The JVM has many components like <em>Garbage Collector(GC)</em>, <em>Just-In-Time(JIT) compiler</em>, <em>Interpreter</em>, <em>Class Loader, Thread Manager</em>, <em>Exception Handler</em> for performing different tasks at different times.</p><p>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></p><p>In addition to JVM, the JRE has set of libraries (e.g., rt.jar) to help a Java program at runtime. We have separate JREs for different platforms like <em>Windows</em>, <em>Macintosh</em>, and <em>Linux</em> and hence the JVM.</p><p>Alright, just try to remember how a Java program is compiled and executed. We have the source code (.java), which is compiled by the Java Compiler into an intermediate code called Bytecode (.class). This Bytecode is given to the JVM for execution on a given target platform. The JVM converts the Bytecode into machine code specific to the target platform before execution. learn <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java Training</strong></a> by Real Experts.</p><p>The execution of a Java program is explained in the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHRdz5QK878H0F1b7E5aWw.jpeg" /></figure><h3>The Web Application Architecture</h3><p>The typical Java web application architecture has four layers: Client, Presentation, Service/Business, and Data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*wYYR1RglI3M2ssrNy03Mig.png" /></figure><p>The Client layer may use libraries like <em>jQuery</em> for supporting AJAX functionality and for having some client-side validations and <em>DOM</em> manipulations.</p><p>The Presentation layer is the one that normally interacts with the Client layer. This layer would generally have implemented the MVC pattern for request and response handling. Frameworks like <em>Spring MVC</em> are used here. Also, there would be a template engine like <em>Velocity</em> to render the view dynamically based on a predefined layout.</p><blockquote>Learn More <a href="https://onlineitguru.com/interviewquestions/java-interview-questions"><strong>Java Interview Questions</strong></a></blockquote><p>The Service or Business layer is responsible for having business logic and communicates with the other layers. In the event of an AJAX request, this layer serves the data directly to the Client layer. This layer executes the business logic and responds back to the Presentation layer to update the model. The Service layer is the one that communicates with the Data layer to fetch or update required data. The service layer may have SOAP or REST service implementations using any framework, like <em>Spring</em>.</p><p>The Data layer normally uses some ORM frameworks, like <em>Hiberate</em>, or any JDBC-based libraries/templates (Spring JDBC Template) to communicate with any RDBMS, like Oracle.</p><h3>The Deployment Architecture</h3><p>The Java web application deployment architecture includes Apache HTTP server, which acts as a proxy server as well as serving static content. Dynamic content is served by a web container, which is actually an engine that processes the Java files.</p><p>The below diagram will explain the Java web application deployment architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*ISr1f1BLhTUgND83alahcA.png" /></figure><h3>How Do I Understand Node.js?</h3><h3>The Runtime Environment</h3><p>The reason we discussed the JRE in the above section was to compare it directly with Node.js. Yes, you got it! Node.js is not a language; not a framework; not a tool. It is a runtime environment for running JavaScript-based applications.</p><p>Similar to JRE, the Node.js has a virtual machine called JavaScript Virtual Machine (JsVM?). It generates machine code for JavaScript-based applications to enable it on different platforms.</p><p>Node.js also has a set of libraries which may otherwise be known as Node API or Node Modules to help run JavaScript applications at runtime, similar to Java Libraries within the JRE. We have separate Node.js requirements for different platforms like Windows, Macintosh, and Linux and hence the JsVM.</p><p>The JavaScript Virtual Machine is nothing but the V8, the open source JavaScript engine from Google. Like the Java Virtual Machine, the JsVM (V8 engine) also has main components like JIT and GC for performing tasks, runtime compilation, and memory management respectively.</p><p>Now, let’s try to understand how the JavaScript program is compiled and executed. The source code is written in JavaScript (.js). There is no intermediate code generated before giving it to JsVM, the V8 engine. The JsVM takes this source code directly and compiles it to machine code specific to the given target platform for execution.</p><p>The above explanation can be understood easily in the below picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*slhJHq8xbvK2TKMDMDkx3Q.jpeg" /></figure><h3>Web Application Architecture</h3><p>A Node.js-based web application mostly follows the Java web application architecture. The main difference is in the client request processing. The client requests will be handled by a single thread, but asynchronously in the case of a Node.js application. With Java, each client request will be handled by a separate thread synchronously, and hence it is multi-threaded.</p><p>Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java online course</strong></a></p><p>There are many frameworks/libraries available for Node.js-based web application development. The interesting point to note here is that all the frameworks/libraries are JavaScript based.</p><p>You can quickly understand the different layers and the framework/libraries used in those layers of Node.js application from the below picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*MTnRKckQmCvLKr9N5vnWRg.png" /></figure><p>The Client layer uses Angular.js, a client-side MVC framework. The Presentation layer, as well as the Service layer, can be developed by using Express.js, a JavaScript-based web application framework. This also comes with a standalone server for running Node.js applications. The Data layer uses an Object Data Modelling module (e.g. Mongoose.js) for communicating with NoSQL databases like MongoDB.</p><p>This particular stack is called <em>MEAN</em> , which consists of <strong>M</strong>ongoDB, <strong>E</strong>xpress.js, <strong>A</strong>ngular.js, the client side MVC framework and <strong>N</strong>ode.js, the runtime environment.</p><h3>The Deployment Architecture</h3><p>Node.js-based web application deployment architecture follows Java’s web application deployment architecture. It has an NGINX server, which acts like an HTTP proxy server, as well as serves the static content. The dynamic content is served by a Node.js server, which contains an engine to process the JavaScript files.</p><p>Below is the diagram that explains the Node.js based web application’s deployment architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*nRq34jk99Ao7t6jX5I-Y0w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13effde9b903" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ExecutorService vs ExecutorCompletionService in Java]]></title>
            <link>https://medium.com/@madhucynixit/executorservice-vs-executorcompletionservice-in-java-ec49f7830de7?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec49f7830de7</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[java8]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Fri, 10 Jan 2020 04:18:29 GMT</pubDate>
            <atom:updated>2020-01-10T04:18:29.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKqq7GcK6DCBwP-4o_0Hag.png" /></figure><p>Suppose we have list of four tasks: Task A, Task B, Task C and Task D which perform some complex computation and result into an integer value. These tasks may take random time depending upon various parameters. <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Learn Java online</strong></a> with this tutorial. This Java course provides training for beginners We can submit these tasks to executor as:</p><pre>ExecutorService executorService = Executors.newFixedThreadPool(4);<br>List&lt;Future&gt; futures = new ArrayList&lt;Future&lt;Integer&gt;&gt;();<br>futures.add(executorService.submit(A));<br>futures.add(executorService.submit(B));<br>futures.add(executorService.submit(C));<br>futures.add(executorService.submit(D));<br><br>Then we can iterate over the list to get the computed result of each future:<br>for (Future future:futures) {<br>    Integer result = future.get();<br>    // rest of the code here.<br>}</pre><p>Now the similar functionality can also be achieved using ExecutorCompletionService as:</p><pre>ExecutorService executorService = Executors.newFixedThreadPool(4);<br>CompletionService executorCompletionService= new ExecutorCompletionService&lt;&gt;(executorService );<br>Then again we can submit the tasks and get the result like:<br>List&lt;Future&gt; futures = new ArrayList&lt;Future&lt;Integer&gt;&gt;();<br>futures.add(executorCompletionService.submit(A));<br>futures.add(executorCompletionService.submit(B));<br>futures.add(executorCompletionService.submit(C));<br>futures.add(executorCompletionService.submit(D));<br><br>for (int i=0; i&lt;futures.size(); i++) {<br>    Integer result = executorCompletionService.take().get();<br>    // Some processing here<br>}</pre><p><strong>Now what is the difference between the two?</strong></p><p>Suppose task B finished first followed by task C. But task A was still going on. In that case when using ExecutorService the for loop would be waiting for the result of task A to be available. So in case of ExecutorService tasks will be processed in the same order in which they were submitted.</p><blockquote>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></blockquote><p>But in later case the tasks will be processed in order the result becomes available, the order tasks are completed. One interesting example is where we want to download some file which can be downloaded from various mirrors. In that case we can quickly get the response from the server which is located closest to us. In that case we can get the first available result and discard the others. Consider the following example from Java Doc:</p><pre>void solve(Executor e, Collection&lt;Callable&lt;Result&gt;&gt; solvers) <br>      throws InterruptedException {<br>        CompletionService&lt;Result&gt; ecs = new ExecutorCompletionService&lt;Result&gt;(e);<br>        int n = solvers.size();<br>        List&lt;Future&lt;Result&gt;&gt; futures = new ArrayList&lt;Future&lt;Result&gt;&gt;(n);<br>        Result result = null;<br>        try {<br>            for (Callable&lt;Result&gt; s : solvers)<br>                futures.add(ecs.submit(s));<br>            for (int i = 0; i &lt; n; ++i) {<br>                try {<br>                    Result r = ecs.take().get();<br>                    if (r != null) {<br>                        result = r;<br>                        break;<br>                    }<br>                } catch(ExecutionException ignore) {}<br>            }<br>        }<br>        finally {<br>            for (Future&lt;Result&gt; f : futures)<br>                f.cancel(true);<br>        }<br><br>        if (result != null)<br>            use(result);<br>    }</pre><p>In the above example the moment we get the result we break out of the loop and cancel out all the other futures. One important thing to note is that the implementation of ExecutorCompletionService contains a queue of results. We need to remember the number of tasks we have added to the service and then should use take or poll to drain the queue otherwise a memory leak will occur. Some people use the Future returned by submit to process results and this is <strong>NOT </strong>correct usage. Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java online course</strong></a></p><p><strong>Peeking into ExecutorCompletionService </strong><br>When we look inside the code for this we observe that it makes use of Executor,AbstractExecutorService (default implementations of ExecutorService execution methods) and BlockingQueue (actual instance is of class LinkedBlockingQueue&lt;Future&lt;V&gt;&gt;).</p><pre>public class ExecutorCompletionService&lt;V&gt; implements CompletionService&lt;V&gt; {<br>    private final Executor executor;<br>    private final AbstractExecutorService aes;<br>    private final BlockingQueue&lt;Future&lt;V&gt;&gt; completionQueue;<br>    // Remaining code..<br>}</pre><p>Another important thing to observe is class QueueingFuture which extends FutureTaskand in the method done() the result is pushed to queue.</p><pre>private class QueueingFuture extends FutureTask&lt;Void&gt; {<br>        QueueingFuture(RunnableFuture&lt;V&gt; task) {<br>            super(task, null);<br>            this.task = task;<br>        }<br>        protected void done() { completionQueue.add(task); }<br>        private final Future&lt;V&gt; task;<br>    }</pre><p>For the curios ones, class FutureTask is base implementation of Future interface with methods to start and cancel a computation, query to see if the computation is complete, and retrieve the result of the computation. And constructor takes RunnableFuture as parameter which is again an interface which extends Future interface and adds only one method run as:</p><pre>public interface RunnableFuture&lt;V&gt; extends Runnable, Future&lt;V&gt; {<br>    /**<br>     * Sets this Future to the result of its computation<br>     * unless it has been cancelled.<br>     */<br>    void run();<br>}</pre><p><a href="https://onlineitguru.com/blog/10-reasons-why-java-is-best-platform">10 Reasons Why Java is Best Platform | Java blog | OnlineITGuru</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec49f7830de7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[11 Simple Java Performance Tuning Tips]]></title>
            <link>https://medium.com/@madhucynixit/11-simple-java-performance-tuning-tips-19d4a116b7a3?source=rss-8178ed0d22ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/19d4a116b7a3</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Madhu Cynix]]></dc:creator>
            <pubDate>Thu, 09 Jan 2020 04:11:03 GMT</pubDate>
            <atom:updated>2020-01-09T04:11:03.170Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*137OBHJi1xl6-ZW-tn7mUw.png" /></figure><p>Most developers expect that performance optimization is a complicated topic that requires a lot of experience and knowledge. Okay, that’s not entirely wrong. Optimizing an application to get the best performance possible isn’t an easy task. But that doesn’t mean that you can’t do anything if you haven’t acquired that knowledge. There are several easy to follow recommendations and best practices which help you to create a well-performing application.</p><p>Most of these recommendations are Java-specific. But there are also several language-independent ones, which you can apply to all applications and programming languages. Let’s talk about some of these generic ones before we get to the Java-specific performance tuning tips.</p><blockquote>To get in-Depth knowledge on Java you can enroll for live <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>Java Online Training</strong></a></blockquote><h3>1. Don’t Optimize Before You Know It’s Necessary</h3><p>That might be one of the most important performance tuning tips. You should follow common best practices and try to implement your use cases efficiently. But that doesn’t mean that you should replace any standard libraries or build complex optimizations before you proved that it’s necessary.</p><p>In most cases, premature optimization takes up a lot of time and makes the code hard to read and maintain. And to make it even worse, these optimizations most often don’t provide any benefits because you’re spending a lot of time optimizing non-critical parts of your application.</p><p>So, how do you prove that you need to optimize something?</p><p>First of all, you need to define how fast your application code has to be, e.g., by specifying a maximum response time for all API calls or the number of records that you want to import within a specified time frame. After you’ve done that, you can measure which parts of your application are too slow and need to be improved. And when you’ve done that, you should take a look at the second tip.</p><h3>2. Use a Profiler to Find the Real Bottleneck</h3><p>After you followed the first recommendation and identified the parts of your application you need to improve, ask yourself where to start?</p><p>You can approach this question in two ways:</p><ul><li>You can take a look at your code and start with the part that looks suspicious or where you feel that it might create problems.</li><li>Or you use a profiler and get detailed information about the behavior and performance of each part of your code.</li></ul><p>I hope I don’t need to explain why you should <em>always</em> follow the second approach.</p><p>It should be obvious that the profiler-based method gives you a better understanding of the performance implications of your code and allows you to focus on the most critical parts. And if you ever used a profiler, you will remember a few situations in which you were surprised by which parts of your code created the performance issues. More than once my first guess would have led me in the wrong direction.</p><h3>3. Create a Performance Test Suite for the Whole Application</h3><p>This is another general tip that helps you avoid a lot of unexpected problems that often occur after you have deployed your performance improvement to production. You should always define a performance test suite that tests the whole application, and run it before and after you worked on a performance improvement.</p><p>These additional test runs will help you to identify the functional and performance side effects of your change and make sure that you don’t ship an update that caused more harm than good. That is especially important if you work on components that are used by several different parts of your application, like databases or caches.</p><h3>4. Work on the Biggest Bottleneck First</h3><p>And after you have created your test suite and analyzed your application with a profiler, you have a list of issues you want to address to improve the performance. That’s good, but it still doesn’t answer the question where you should start. You could focus on the quick wins, or start with the most significant issue.</p><p>It might be tempting to start with the quick wins because you will be able to show first results soon. Sometimes, that might be necessary to convince other team members or your management that the performance analysis was worth the effort.</p><p>But in general, I recommend starting at the top and begin work on the most significant performance problem first. That will provide you with the biggest performance improvement, and you might not need to fix more than a few of these issues to fulfill your performance requirements.</p><p>Enough about general performance tuning tips. Let’s take a closer look at some Java-specific ones.</p><p><a href="https://onlineitguru.com/blog/difference-between-java-64-bit-and-32-bit">Difference between Java 64 bit and 32 bit | Java Blog | OnlineITGuru</a></p><h3>5. Use StringBuilder to Concatenate Strings Programmatically</h3><p>There are lots of different options to concatenate <em>String</em>s in Java. You can, for example, use a simple <em>+</em> or <em>+=</em>, the good old <em>StringBuffer</em> or a<a href="https://docs.oracle.com/javase/9/docs/api/java/lang/StringBuilder.html"> <em>StringBuilder</em></a>.</p><p>So, which approach should you prefer?</p><p>The answer depends on the code that concatenates the <em>String</em>. If you’re programmatically adding new content to your <em>String</em>, e.g., in a for-loop, you should use the <em>StringBuilder</em>. It’s easy to use and provides better performance than <em>StringBuffer</em>. But please keep in mind, that the <em>StringBuilder</em>, in contrast to <em>StringBuffer</em>, is not thread-safe and might not be a good fit for all use cases.</p><p>You just need to instantiate a new <em>StringBuilder</em> and call the <em>append</em> method to add a new part to the <em>String</em>. And when you’ve added all parts, you can call the <em>toString()</em> method to retrieve the concatenated <em>String</em>.</p><p>The following code snippet shows a simple example. During each iteration, this loop converts <em>i</em> into a <em>String</em> and adds it together with a space to the <em>StringBuilder sb</em>. So, in the end, this code writes “This is a test0 1 2 3 4 5 6 7 8 9” to the log file.</p><pre>StringBuilder sb = new StringBuilder(“This is a test”);</pre><pre>for (int i=0; i&lt;10; i++) {</pre><pre>sb.append(i);</pre><pre>sb.append(” “);</pre><pre>}</pre><pre>log.info(sb.toString());</pre><p>As you can see in the code snippet, you can provide the first element of your <em>String</em> to the constructor method. That will create a new <em>StringBuilder</em> containing the provided <em>String</em> and a capacity for 16 additional characters. When you add more characters to the <em>StringBuilder</em>, your JVM will dynamically increase the size of the <em>StringBuilder</em>.</p><p>If you already know how many characters your <em>String</em> will contain, you can provide that number to different constructor method to instantiate a <em>StringBuilder</em> with the defined capacity. That improves its efficiency even further because it doesn’t need to dynamical extend its capacity.</p><h3>6. Use + to Concatenate Strings in in One Statement</h3><p>When you implemented your first application in Java, someone probably told you that you shouldn’t concatenate <em>String</em>s with <em>+</em>. And that’s correct if you’re concatenating <em>String</em>s in your application logic. <em>String</em>s are immutable, and the result of each <em>String</em> concatenation is stored in a new <em>String</em> object. That requires additional memory and slows down your application, especially if you’re concatenating multiple <em>String</em>s within a loop.</p><p>In these cases, you should follow tip number 5 and use a <em>StringBuilder</em>.</p><p>But that’s not the case if you’re just breaking a <em>String</em> into multiple lines to improve the readability of your code.</p><pre>Query q = em.createQuery(“SELECT a.id, a.firstName, a.lastName ”</pre><pre>+ “FROM Author a ”</pre><pre>+ “WHERE a.id = :id”);</pre><p>In these situations, you should concatenate your <em>String</em>s with a simple <em>+</em>. Your Java compiler will optimize this and perform the concatenation at compile time. So, at runtime, your code will just use 1 <em>String</em>, and no concatenation will be required.</p><h3>7. Use Primitives Where Possible</h3><p>Another quick and easy way to avoid any overhead and improve the performance of your application is to use primitive types instead of their wrapper classes. So, it’s better to use an <em>int</em> instead of an <em>Integer,</em> or a <em>double</em> instead of a <em>Double</em>. That allows your JVM to store the value in the stack instead of the heap to reduce memory consumption and overall handle it more efficiently.</p><h3>8. Try to Avoid BigInteger and BigDecimal</h3><p>As we’re already talking about data types, we should also take a quick look at <em>BigInteger</em> and <em>BigDecimal</em>. Especially the latter one is popular because of its precision. But that comes at a price.</p><p><em>BigInteger</em> and <em>BigDecimal</em> require much more memory than a simple <em>long</em> or <em>double</em> and slow down all calculations dramatically. So, better think twice if you need the additional precision, or if your numbers will exceed the range of a <em>long</em>. This might be the only thing you need to change to fix your performance problems, especially if you’re implementing a mathematical algorithm.</p><h3>9. Check the Current Log Level First</h3><p>This recommendation should be obvious, but unfortunately, you can find lots of code that ignores it. Before you create a debug message, you should always check the current log level first. Otherwise, you might create a <em>String</em> with your log message that will be ignored afterward.</p><p>Here are two examples of how you should NOT do it.</p><pre>// don’t do this</pre><pre>log.debug(“User [” + userName + “] called method X with [” + i + “]”);</pre><pre>// or this</pre><pre>log.debug(String.format(“User [%s] called method X with [%d]”, userName, i));</pre><p>In both cases, you will perform all required steps to create the log message without knowing if your logging framework will use the log message. It’s better to check the current log level first before you create the debug message.</p><pre>// do this</pre><pre>if (log.isDebugEnabled()) {</pre><pre>log.debug(“User [” + userName + “] called method X with [” + i + “]”);</pre><pre>}</pre><h3>10. Use Apache Commons StringUtils.Replace Instead of String.replace</h3><p>In general, the <em>String.replace</em> method works fine and is pretty efficient, especially if you’re using Java 9. But if your application requires a lot of replace operations and you haven’t updated to the newest Java version, it still makes sense to check for faster and more efficient alternatives. Take your career to new heights of success with an <a href="https://onlineitguru.com/core-java-online-training-placement.html"><strong>java certification course</strong></a></p><p>One candidate is Apache Commons Lang’s <em>StringUtils.replace</em> method. As Lukas Eder described in one of his recent blog posts, it dramatically outperforms Java 8’s <em>String.replace method</em>.</p><p>And it just requires a minimal change. You need to add a Maven dependency for the Apache’s <em>Commons Lang</em> project to your application pom.xml, and replace all calls of the <em>String.replace</em> method with the <em>StringUtils.replace</em> method.</p><pre>// replace this</pre><pre>test.replace(“test”, “simple test”);</pre><pre>// with this</pre><pre>StringUtils.replace(test, “test”, “simple test”);</pre><h3>11. Cache Expensive Resources, Like Database Connections</h3><p>Caching is a popular solution to avoid the repeated execution of expensive or frequently used code snippets. The general idea is simple: Reusing such resources is cheaper than creating a new one over and over again.</p><p>A typical example is caching database connections in a pool. The creation of a new connection takes time, which you can avoid if you reuse an existing connection.</p><p>You can also find other examples in the Java language itself. The <em>valueOf</em> method of the <em>Integer</em> class, for example, caches the values between -128 and 127. You might say that the creation of a new <em>Integer</em> isn’t too expensive, but it’s used so often that the caching of the most used values provides a performance benefit.</p><p>But when you think about caching, please keep in mind that your caching implementation also creates an overhead. You need to spend additional memory to store the reusable resources, and you might need to manage your cache to make the resources accessible or to remove outdated ones.</p><p>So, before you start caching any resources, make sure that you use them often enough to outweigh the overhead of your cache implementation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19d4a116b7a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>