<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Java on Daniel Pomfret</title>
    <link>https://pomfret.uk/tags/java/</link>
    <description>Recent content in Java on Daniel Pomfret</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>© Daniel Pomfret</copyright>
    <lastBuildDate>Wed, 08 Feb 2023 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://pomfret.uk/tags/java/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Optimizing Java for AWS Lambda</title>
      <link>https://pomfret.uk/posts/optimizing-java-for-aws-lambda/</link>
      <pubDate>Wed, 08 Feb 2023 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/optimizing-java-for-aws-lambda/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://aws.amazon.com/lambda/&#34;&gt;AWS Lambda&lt;/a&gt; is a serverless computing platform that lets you run your code without provisioning or managing servers. Java is one of the supported programming languages for AWS Lambda, which makes it a great choice for many applications. However, to get the best performance from your Java-based AWS Lambda functions, you&amp;rsquo;ll need to follow a few best practices. In this blog post, I&amp;rsquo;ll go over some of the most important optimisation techniques for Java on AWS Lambda.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Disable tests when using AWS SAM Build</title>
      <link>https://pomfret.uk/posts/disable-tests-when-using-aws-sam-build/</link>
      <pubDate>Mon, 09 Jan 2023 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/disable-tests-when-using-aws-sam-build/</guid>
      <description>&lt;p&gt;Before I start, disabling tests as part of your build pipeline is bad - I don&amp;rsquo;t recommend it. However, in this scenario, sam builds, especially when running &lt;code&gt;sam sync --watch&lt;/code&gt; can take a bit of time, and the feedback loop (write some code, and quickly see it running) can be several minutes, rather than seconds (which you would normally see when running unit tests etc).&lt;/p&gt;&#xA;&lt;p&gt;So, when running &lt;code&gt;sam sync --watch&lt;/code&gt; you may want to disable running of unit/integration tests to make things faster. I&amp;rsquo;d recommend ensuring unit tests and integration tests are ran somewhere else in your build pipeline.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Install GraalVM and Native-Image on an M1 Mac (Java11)</title>
      <link>https://pomfret.uk/posts/install-graalvm-and-native-image-on-an-m1-mac-java11/</link>
      <pubDate>Fri, 04 Mar 2022 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/install-graalvm-and-native-image-on-an-m1-mac-java11/</guid>
      <description>&lt;p&gt;This is a quick guide on installing GraalVM on your M1 Mac - this guide also works for x86_64 Macs also.&lt;/p&gt;&#xA;&lt;p&gt;This will install GraalVM for Java11 - different Java versions are available here: &lt;a href=&#34;https://github.com/graalvm/graalvm-ce-builds/releases&#34;&gt;https://github.com/graalvm/graalvm-ce-builds/releases&lt;/a&gt;&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;h3 id=&#34;install-graalvm-using-homebrew&#34;&gt;Install GraalVM using Homebrew&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;brew install &lt;span style=&#34;color:#f92672&#34;&gt;--&lt;/span&gt;cask graalvm&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;tap&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;graalvm&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;ce&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;java11&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; JAVA_HOME&lt;span style=&#34;color:#f92672&#34;&gt;=$&lt;/span&gt;HOME&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;Library&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;Java&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;JavaVirtualMachines&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;graalvm&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;ce&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;java11&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;22.0&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0.2&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;Contents&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;Home&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;give-graalvm-permission-to-run&#34;&gt;Give GraalVM permission to run&lt;/h4&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;xattr -r -d com.apple.quarantine /Library/Java/JavaVirtualMachines/graalvm-ce-java11-22.0.0.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;&#xA;&lt;h3 id=&#34;install-using-sdkman&#34;&gt;Install using sdkman&lt;/h3&gt;&#xA;&lt;p&gt;SDKMAN is a brilliant tool, you can install it here: &lt;a href=&#34;https://sdkman.io/install&#34;&gt;https://sdkman.io/install&lt;/a&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sdk install java &lt;span style=&#34;color:#ae81ff&#34;&gt;22.0&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0.2&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;r17&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;grl&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; JAVA_HOME&lt;span style=&#34;color:#f92672&#34;&gt;=$&lt;/span&gt;HOME&lt;span style=&#34;color:#f92672&#34;&gt;/.&lt;/span&gt;sdkman&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;candidates&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;java&lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;22.0&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;0.2&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;r17&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;grl&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;&#xA;&lt;h3 id=&#34;install-native-image-plugin&#34;&gt;Install native-image plugin&lt;/h3&gt;&#xA;&lt;h4 id=&#34;firstly-update-your-path&#34;&gt;Firstly update your path&lt;/h4&gt;&#xA;&lt;p&gt;Brew version:&lt;/p&gt;</description>
    </item>
    <item>
      <title>R1Soft : GC overhead limit exceeded</title>
      <link>https://pomfret.uk/posts/r1soft-gc-overhead-limit-exceeded/</link>
      <pubDate>Tue, 01 Nov 2016 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/r1soft-gc-overhead-limit-exceeded/</guid>
      <description>&lt;p&gt;I encountered this issue on the R1Soft Web Interface last week, which I had to open a support ticket for with R1Soft&amp;rsquo;s brilliant support.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;images/r1soft-300x95.jpg&#34; alt=&#34;r1soft&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;When trying to run tasks like a backup, run, or restore I would encounter the error messages as seen above.&lt;/p&gt;&#xA;&lt;p&gt;The error was down to the maximum amount of memory which was assigned to the Java Heap and PermGen. After contacting R1Soft&amp;rsquo;s support, I was pointed to a config file where you can adjust the java heap and permgen values.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Knapsack Problem (0-1 solution) - Dynamic Algorithm</title>
      <link>https://pomfret.uk/posts/knapsack-problem-0-1-solution-dynamic-algorithm/</link>
      <pubDate>Tue, 27 Sep 2016 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/knapsack-problem-0-1-solution-dynamic-algorithm/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve recently dug up old code from my University days, which I thought I&amp;rsquo;d share for the benefit/misfortune of others.&lt;/p&gt;&#xA;&lt;p&gt;There&amp;rsquo;s a common problem in programming called the knapsack problem. Here was my solution based on the dynamic algorithm.&lt;/p&gt;&#xA;&lt;p&gt;# Math is used to floor/round the floats to an interger and back!&#xA;import math&lt;/p&gt;&#xA;&lt;h1 id=&#34;total-allowed-weight&#34;&gt;Total allowed weight&lt;/h1&gt;&#xA;&lt;p&gt;totalWeight = 2392;&lt;/p&gt;&#xA;&lt;h1 id=&#34;define-the-items-name-weight-profit&#34;&gt;Define the items name, Weight, Profit&lt;/h1&gt;&#xA;&lt;p&gt;items = ((&amp;ldquo;Weapon and Ammunition&amp;rdquo;,    4.13, 1.4),&#xA;(&amp;ldquo;Water&amp;rdquo;, 2.13, 2.74),&#xA;(&amp;ldquo;Pith Helmet&amp;rdquo;, 3.03, 1.55),&#xA;(&amp;ldquo;Sun Cream&amp;rdquo;, 2.26, 0.82),&#xA;(&amp;ldquo;Tent&amp;rdquo;, 3.69, 2.38),&#xA;(&amp;ldquo;Flare Gun&amp;rdquo;, 3.45, 2.93),&#xA;(&amp;ldquo;Olive Oil&amp;rdquo;, 1.09, 1.77),&#xA;(&amp;ldquo;Firewood&amp;rdquo;, 2.89, 0.53),&#xA;(&amp;ldquo;Kendal Mint Cake&amp;rdquo;, 1.08, 2.77),&#xA;(&amp;ldquo;Snake Repellant Spray&amp;rdquo;, 3.23, 4.29),&#xA;(&amp;ldquo;Bread&amp;rdquo;, 2.29, 2.85),&#xA;(&amp;ldquo;Pot Noodles&amp;rdquo;, 0.55, 0.34),&#xA;(&amp;ldquo;Software Engineering Textbook&amp;rdquo;, 2.82, -0.45),&#xA;(&amp;ldquo;Tinned Food&amp;rdquo;, 2.31, 2.17),&#xA;(&amp;ldquo;Pork Pie&amp;rdquo;, 1.63, 1.62))&lt;/p&gt;</description>
    </item>
    <item>
      <title>Knapsack Problem (0-1 solution) - Greedy Algorithm</title>
      <link>https://pomfret.uk/posts/knapsack-problem-0-1-solution-greedy-algorithm/</link>
      <pubDate>Tue, 27 Sep 2016 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/knapsack-problem-0-1-solution-greedy-algorithm/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve recently dug up old code from my University days, which I thought I&amp;rsquo;d share for the benefit/misfortune of others.&lt;/p&gt;&#xA;&lt;p&gt;There&amp;rsquo;s a common problem in programming called the knapsack problem. Here was my solution based on the greedy algorithm.&lt;/p&gt;&#xA;&lt;p&gt;# Name, Weight and Value of Items&#xA;items = [(&amp;ldquo;Weapon and Ammunition&amp;rdquo;,    4.13, 1.4),&#xA;(&amp;ldquo;Water&amp;rdquo;, 2.13, 2.74),&#xA;(&amp;ldquo;Pith Helmet&amp;rdquo;, 3.03, 1.55),&#xA;(&amp;ldquo;Sun Cream&amp;rdquo;, 2.26, 0.82),&#xA;(&amp;ldquo;Tent&amp;rdquo;, 3.69, 2.38),&#xA;(&amp;ldquo;Flare Gun&amp;rdquo;, 3.45, 2.93),&#xA;(&amp;ldquo;Olive Oil&amp;rdquo;, 1.09, 1.77),&#xA;(&amp;ldquo;Firewood&amp;rdquo;, 2.89, 0.53),&#xA;(&amp;ldquo;Kendal Mint Cake&amp;rdquo;, 1.08, 2.77),&#xA;(&amp;ldquo;Snake Repellant Spray&amp;rdquo;, 3.23, 4.29),&#xA;(&amp;ldquo;Bread&amp;rdquo;, 2.29, 2.85),&#xA;(&amp;ldquo;Pot Noodles&amp;rdquo;, 0.55, 0.34),&#xA;(&amp;ldquo;Software Engineering Textbook&amp;rdquo;, 2.82, -0.45),&#xA;(&amp;ldquo;Tinned Food&amp;rdquo;, 2.31, 2.17),&#xA;(&amp;ldquo;Pork Pie&amp;rdquo;, 1.63, 1.62)]&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
