<?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"><channel><title><![CDATA[Codepuran]]></title><description><![CDATA[Codepuran]]></description><link>https://www.codepuran.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1597423965443/FOxw8B6Ok.png</url><title>Codepuran</title><link>https://www.codepuran.com</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 19:50:23 GMT</lastBuildDate><atom:link href="https://www.codepuran.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[HTTP Status Code For Common REST API Responses]]></title><description><![CDATA[Have you ever discussed with your team which HTTP status code is most suitable for the XYZ scenario and then Google the correct status for the use case?
I did it a lot, so I thought to bring it to the table and document it. 
There are plenty of resou...]]></description><link>https://www.codepuran.com/http-status-code-for-common-rest-api-responses</link><guid isPermaLink="true">https://www.codepuran.com/http-status-code-for-common-rest-api-responses</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Postman]]></category><category><![CDATA[REST API]]></category><category><![CDATA[REST]]></category><category><![CDATA[APIs]]></category><dc:creator><![CDATA[Akshay Pethani]]></dc:creator><pubDate>Sun, 05 Jun 2022 15:10:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1654441665161/yb_RPeAx-.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever discussed with your team which HTTP status code is most suitable for the XYZ scenario and then Google the correct status for the use case?</p>
<p>I did it a lot, so I thought to bring it to the table and document it. </p>
<p>There are plenty of resources available over the internet which describes the meaning of HTTP status codes in a single line. But we aim to do reverse, state the use case first and then define the correct response status code for that use case. </p>
<p>There are a total of 41 HTTP status codes defined in HTTP/1.1 Specification [<a target="_blank" href="https://datatracker.ietf.org/doc/html/rfc7231#section-6.1">RFC 7231</a>], but in day-to-day development, we encounter few of them. </p>
<h3 id="heading-common-rest-api-respons-status">Common REST API Respons Status</h3>
<p>Here are a few use cases which you encounter most during development.</p>
<ul>
<li><p>Response of successful GET request, which returns some data.
<strong><em>200 OK</em></strong></p>
</li>
<li><p>Resource not available for GET Request to fetch single resource by id or other property. 
<strong><em>404 Not Found</em>
</strong></p>
</li>
<li><p>Resource not available for GET request to fetch multiple/list resources.
<strong><em>200 OK with Empty List/Array</em></strong></p>
</li>
<li><p>POST request, which successfully creates records and persists.
<strong><em>201 Created</em></strong></p>
</li>
<li><p>POST request which successfully executes some command/triggers some actions or changes state. 
<strong><em>200 OK</em></strong></p>
</li>
<li><p>GET/POST Request if parent resource does not exist.
<strong><em>404 Not Found</em></strong></p>
</li>
</ul>
<p>e.g., GET request to get student x of school y</p>
<pre><code>api<span class="hljs-operator">/</span>school<span class="hljs-operator">/</span>{school_id}<span class="hljs-operator">/</span>student<span class="hljs-operator">/</span>{student_id}
</code></pre><p>In this case, 409 (Conflict) or 412 (Precondition Failed) seem tempting. But, Conflicts are most likely to occur in response to a PUT request. For example, you may get a 409 response when uploading a file that is older than the existing one on the server, resulting in a version control conflict.</p>
<p><strong><em>404 (Not Found)</em></strong> seems to be an appropriate response because the schools with <code>school_id</code> does not exist. It's obvious to understand, and you are expecting the same response if <code>api/school/{school_id}</code> is called.</p>
<ul>
<li><p>If request-body / path-parameter / query-parameter is missing, any property of them is missing or provided invalid datatype -  <strong>400 Bad Request</strong></p>
</li>
<li><p>POST request triggers a long-running asynchronous operation and eventually produces the result.
<strong><em>202 Accepted</em></strong></p>
</li>
<li><p>Sometimes, considering security, Unauthorized or Forbidden access to some resources can return <strong><em>404 (Not Found)</em></strong>.</p>
</li>
<li><p>Any runtime error / uncaught error. <strong><em>500 (Internal Server Error) </em></strong></p>
</li>
<li><p>Following status codes are used by the Web Server, API Gateway, Proxy, or Load balancer. You should not use them in your code.</p>
</li>
</ul>
<p><strong><em>502 (Bad Gateway)</em></strong></p>
<p><strong><em>503 (Service Unavailable)</em></strong></p>
<p><strong><em>504 (Gateway Timeout)</em></strong></p>
<h3 id="heading-disclaimer">Disclaimer</h3>
<p><em>If your team uses some other convention and has used it throughout the existing project, I recommend you stick to it. Changing API conventions sometimes lead to inconsistency in the documentation and may introduce bugs. or if you are in a position to change the convention, you should communicate it with your team. </em></p>
<h3 id="heading-closing-notes">Closing Notes</h3>
<p>Though we briefly listed many everyday use cases, this list can go on. I would like to hear your opinion in the comments.</p>
]]></content:encoded></item><item><title><![CDATA[Manage Multiple JDKs In Windows]]></title><description><![CDATA[Since when Oracle Adopted 6 monthly release cycle for Java, It is most likely that Java developers have to deal with multiple versions of JDKs.
Considering the diversity of the Java community, most of the Java libraries and framework supports at leas...]]></description><link>https://www.codepuran.com/manage-multiple-jdks-in-windows</link><guid isPermaLink="true">https://www.codepuran.com/manage-multiple-jdks-in-windows</guid><category><![CDATA[Java]]></category><category><![CDATA[Windows]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Programming Tips]]></category><dc:creator><![CDATA[Akshay Pethani]]></dc:creator><pubDate>Sun, 03 Jan 2021 17:03:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1609689304089/o8iVV8W3X.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Since when Oracle Adopted 6 monthly release cycle for Java, It is most likely that Java developers have to deal with multiple versions of JDKs.</p>
<p>Considering the diversity of the Java community, most of the Java libraries and framework supports at least LTS versions of the Java. Still, there are many active Java open-source and commercial projects are using Java 8 and other Java version.</p>
<p>In this situation, you may have to manage multiple installations of the JDK in your system. In Linux, Handling multiple JDKs is fairly easy and there are tools available that can do this job for you. </p>
<p>For windows, the situation is different. There are no open-source free tools available that can seamlessly handle multiple JDK installations. I have spent several hours looking for available solutions, but no luck. </p>
<p>Finally, I have to write custom scripts that can handle multiple JDKs for me. Let me walk you through the installations of JDKs and Switching between them.</p>
<p>I have used 2 versions of Java (OpenJDK 8 and OpenJDK 15) in this article.</p>
<h3 id="setup-multiple-jdks-in-windows">Setup Multiple JDKs In Windows</h3>
<ul>
<li>Download Java 8 and Java 15 or any of the 2 JDK versions of your choice. Download OpenJDK zip files, which are easy to manage.</li>
<li>Extract the zip into the root of the <code>C</code> drive or in <code>C:\java</code> directory.</li>
</ul>
<h3 id="setup-javahome-environment-variable-and-java-in-system-path">Setup JAVA_HOME Environment Variable and Java In System Path</h3>
<p>Here I assume that you are aware of the windows environment variable settings.</p>
<ul>
<li>Setup JAVA_HOME user variable. For 1step use of any 1 JDK path. You can use the control panel or command prompt with the following command.</li>
</ul>
<pre><code><span class="hljs-attribute">setx</span> JAVA_HOME C:\tools\java\jdk-<span class="hljs-number">15</span>
</code></pre><p>Note: This path is just for reference. Use your java installation path instead.</p>
<p>Notice that JAVA_HOME does not contains <code>/bin</code> directory. Many build tools like maven and Gradle require JAVA_HOME in this format.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1609690902517/K15DL1FBp.png" alt="setup-java-home-environment-variable-windows.png" /></p>
<ul>
<li>Now let's set up <code>java</code> and <code>javac</code> in the path environment variable. Here, we will reference the JAVA_HOME value in the path variable. </li>
</ul>
<p>Note: As updating system variables need administrative privileges, I have setup JAVA_HOME and path variable in user variables.</p>
<pre><code>%JAVA_HOME%\bin
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1609691087501/uJ90wuzx2.png" alt="setup-java-path-windows.png" /></p>
<ul>
<li>To test the java installation, run the following command in the new command prompt window.</li>
</ul>
<pre><code>java <span class="hljs-comment">--version</span>
</code></pre><p>You should get output similar to this.</p>
<pre><code><span class="hljs-attribute">openjdk</span> <span class="hljs-number">15</span> <span class="hljs-number">2020</span>-<span class="hljs-number">09</span>-<span class="hljs-number">15</span>
<span class="hljs-attribute">OpenJDK</span> Runtime Environment (build <span class="hljs-number">15</span>+<span class="hljs-number">36</span>-<span class="hljs-number">1562</span>)
<span class="hljs-attribute">OpenJDK</span> <span class="hljs-number">64</span>-Bit Server VM (build <span class="hljs-number">15</span>+<span class="hljs-number">36</span>-<span class="hljs-number">1562</span>, mixed mode, sharing)
</code></pre><h3 id="setup-batch-scripts-to-switch-jdks">Setup Batch Scripts to Switch JDKs</h3>
<p>After successfully setting up one version of java, now it's time to write one-liner batch scripts to switch the JDK versions.</p>
<ul>
<li>Create <code>open-jdk-15.bat</code> file and your Java installation path.</li>
</ul>
<pre><code><span class="hljs-attribute">SETX</span> JAVA_HOME <span class="hljs-string">"C:\tools\java\jdk-15"</span>
</code></pre><ul>
<li>Create another batch file <code>open-jdk-8</code> and use your Java 8 installation path in the script.</li>
</ul>
<pre><code><span class="hljs-attribute">SETX</span> JAVA_HOME <span class="hljs-string">"C:\tools\java\java-se-8u41-ri"</span>
</code></pre><p>Similarly, you can create many batch files. One per JDK.</p>
<h3 id="switch-between-jdks">Switch Between JDKs</h3>
<p>Now I guess you guys get my idea. You just need to execute the batch file of the JDK which you want to use and re-open the command prompt windows and check the java version.</p>
<pre><code>java <span class="hljs-comment">--version</span>
</code></pre><p>You should able to see different Java versions now. </p>
<h3 id="conclusion">Conclusion</h3>
<p>We have discussed the strategy to manage multiple JDK in Windows OS. The idea is simple. We have set up the JAVA_HOME variable and referenced it in the path. And by switching the JAVA_HOME value using the batch script we can easily switch the JDK version.</p>
<p>Let me know your way to handle multiple JDKs in windows or If you liked this article then please feel free to share it with your team and community.</p>
<p>Until Next Article, Happy Coding...</p>
]]></content:encoded></item></channel></rss>