<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Lahiru Sandaruwan</title>
    <description>The latest articles on Forem by Lahiru Sandaruwan (@lahiru01).</description>
    <link>https://forem.com/lahiru01</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1777640%2Fdbf66a7e-7b76-4739-98db-adf6231300d5.jpg</url>
      <title>Forem: Lahiru Sandaruwan</title>
      <link>https://forem.com/lahiru01</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/lahiru01"/>
    <language>en</language>
    <item>
      <title>No Screen, No Problem: Turning a "Dead" S10 into a Headless Minecraft Server</title>
      <dc:creator>Lahiru Sandaruwan</dc:creator>
      <pubDate>Tue, 27 Jan 2026 07:34:04 +0000</pubDate>
      <link>https://forem.com/lahiru01/no-screen-no-problem-turning-a-dead-s10-into-a-headless-minecraft-server-3k26</link>
      <guid>https://forem.com/lahiru01/no-screen-no-problem-turning-a-dead-s10-into-a-headless-minecraft-server-3k26</guid>
      <description>&lt;p&gt;&lt;strong&gt;The "Paperweight"&lt;/strong&gt;&lt;br&gt;
I had this decent hardware (Samsung S10 with 8GB RAM) sitting in a drawer doing nothing, just because the display died. I wanted to run a 24/7 Minecraft server without paying monthly fees for a VPS, but I faced a massive "Chicken and Egg" problem: &lt;strong&gt;How do you unlock a phone and enable USB Debugging if you can't see the screen?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The "Blind" Heist&lt;/strong&gt; &lt;br&gt;
For me, the "Ghost Finger" method worked. Blindly typed my password.&lt;/p&gt;

&lt;p&gt;Once it unlocked, DeX let me see the screen on my monitor just enough to go into Settings and &lt;strong&gt;enable USB Debugging&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: If you are stuck on the lock screen and blind typing isn't working for you, check out this &lt;a href="https://www.reddit.com/r/SamsungDex/comments/x5m5qe/how_do_i_get_out_of_this_screen_when_the_phone/" rel="noopener noreferrer"&gt;Reddit thread&lt;/a&gt; for help.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once debugging was enabled, I could finally connect the phone to my PC and use &lt;a href="https://github.com/Genymobile/scrcpy" rel="noopener noreferrer"&gt;scrcpy&lt;/a&gt; to remove the screen locks and fingerprints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Software Stack&lt;/strong&gt;&lt;br&gt;
I turned the phone into a Linux server,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Termux&lt;/strong&gt;: The terminal emulator.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proot-Distro&lt;/strong&gt;: To run Ubuntu.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Server&lt;/strong&gt;: I installed Java and dropped the Minecraft server .jar file in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Networking&lt;/strong&gt;: I used playit.gg to tunnel out so my friends could join without me needing to mess with port forwarding.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cutting the Cord (Going Headless)&lt;/strong&gt;&lt;br&gt;
The last hack I needed was a way to start the server without ever plugging the phone into a PC again.&lt;/p&gt;

&lt;p&gt;The solution was &lt;strong&gt;Termux:Boot + sshd.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I installed the Termux:Boot app and created a script at ~/.termux/boot/start-sshd so it runs automatically every time the phone turns on.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#!/data/data/com.termux/files/usr/bin/sh&lt;br&gt;
termux-wake-lock&lt;br&gt;
sshd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Result&lt;/strong&gt; &lt;br&gt;
Now, the workflow is seamless:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Plug the phone into a wall charger.&lt;/li&gt;
&lt;li&gt;Wait 60 seconds for it to boot and the script to run.&lt;/li&gt;
&lt;li&gt;SSH into it from my PC.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It lives in the drawer permanently. The real pro here is that it uses barely any electricity (unlike a PC) and it's completely free. Plus, it was a great way to learn about ADB.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What ancient hardware do you have sitting in a drawer that deserves a second life?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>termux</category>
      <category>prootdistro</category>
      <category>linux</category>
      <category>networking</category>
    </item>
    <item>
      <title>Interfaces in Java for Loose Coupling</title>
      <dc:creator>Lahiru Sandaruwan</dc:creator>
      <pubDate>Wed, 24 Jul 2024 20:02:30 +0000</pubDate>
      <link>https://forem.com/lahiru01/interfaces-in-java-for-loose-coupling-4je3</link>
      <guid>https://forem.com/lahiru01/interfaces-in-java-for-loose-coupling-4je3</guid>
      <description>&lt;p&gt;Why Interfaces, Interfaces are used in Java to achieve &lt;strong&gt;loose coupling&lt;/strong&gt;. which is a design principle whose aim is to reduce the dependencies that exist between many parts of the system.&lt;/p&gt;

&lt;p&gt;how interfaces enable loose coupling:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Abstraction: An interface provides a way to define any kind of behavior without defining how it will be implemented. This enables components to communicate with interface without having to know the details of the implementation.&lt;/li&gt;
&lt;li&gt;Flexibility: With interfaces, one implementation is replaced by another without any change in the dependent code. This makes a system easier for maintenance.&lt;/li&gt;
&lt;li&gt;Modularity: Because interfaces can provide for different components developed and tested independently, they foster modularity. Each component can be developed to conform to the interface, making sure that it can integrate with other components seamlessly.&lt;/li&gt;
&lt;li&gt;Dependency Injection: In Spring and similar frameworks, this is used in association with Dependency Injection, which injects the dependencies at runtime. Components are thereby more decoupled, and flexibility of a system is higher when change is required.&lt;/li&gt;
&lt;li&gt;Testing: Interfaces let you create unit tests that allow one to mock or stub out the dependencies easily. You can then test each element independently.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example of Loose Coupling Using Interfaces&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CreditCardPaymentService&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;PaymentService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Process payment using credit card&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PayPalPaymentService&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;PaymentService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Override&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// payment processing via PayPal&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;PaymentService&lt;/span&gt; &lt;span class="n"&gt;paymentService&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;OrderService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PaymentService&lt;/span&gt; &lt;span class="n"&gt;paymentService&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;paymentService&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;paymentService&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;placeOrder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;paymentService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;processPayment&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="nc"&gt;PaymentService&lt;/span&gt; &lt;span class="n"&gt;paymentService&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CreditCardPaymentService&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;OrderService&lt;/span&gt; &lt;span class="n"&gt;orderService&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OrderService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;paymentService&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;orderService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;placeOrder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;100.0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as shown by the example, OrderService depends on the interface PaymentService, not on its implementation. This allows you to switch between multiple different ways of implementing payments without having to change the OrderService code.&lt;/p&gt;

</description>
      <category>java</category>
      <category>oop</category>
    </item>
  </channel>
</rss>
