Saturday, November 14, 2026

Debian 13: troubleshooting HP 415 inktank scanner on wifi

symptom: not scan full image

install wifi scanner

# apt install sane-airscan

check you are in group scan and print

$ groups
... scanner lp lpadmin 

scan your hp 415 inktank 

$ airscan-discover
[devices]
  HP Ink Tank Wireless 410 series [1BAF5D] = http://[2404:8000:1012:60ae::1]:8080/eSCL/, eSCL
  HP Ink Tank Wireless 410 series [1BAF5D] = https://[2404:8000:1012:60ae::1]:443/eSCL/, eSCL
  HP Ink Tank Wireless 410 series [1BAF5D] = http://192.168.18.201:8080/eSCL/, eSCL
  HP Ink Tank Wireless 410 series [1BAF5D] = https://192.168.18.201:443/eSCL/, eSCL
  HP Ink Tank Wireless 410 series [1BAF5D] = http://192.168.18.201:53048, WSD
  HP Ink Tank Wireless 410 series [1BAF5D] = http://[FE80::E270:EAFF:FE1B:AF5D%253]:53048, WSD

rerun your xsane and select "eSCL HP Ink Tank Wire ip=...."

Follow these to install hplip

  1. https://dedetoknotes.blogspot.com/2023/07/debian-bookworm-configure-printer-and.html
  2. https://dedetoknotes.blogspot.com/2021/07/debian-buster-install-all-in-one-hp-ink.html 

Friday, November 13, 2026

Java: using argon2 hash password in netbeans 31

JDK doesn't have argon2 library, we need external library e.g. de.mkammerer (using JNI) and pure java org.springframework.security (uses Bouncy Castle library).

Here is the way to use argon2 in netbeans maven project e.g project name testargon2 package com.dedetok.testargon2, main class TestArgon2.

edit your pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.dedetok</groupId>
    <artifactId>TestArgon2</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>21</maven.compiler.release>
        <exec.mainClass>com.dedetok.testargon2.TestArgon2</exec.mainClass>
    </properties>
    
    <dependencies>
        <!-- Spring Security Crypto -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-crypto</artifactId>
            <version>6.2.8</version>
            <type>jar</type>
        </dependency>
        
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.3.5</version>
    </dependency>
    
    <!-- Bouncy Castle Argon2 provider -->
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk18on</artifactId>
        <version>1.78.1</version>
    </dependency>
                
    </dependencies>
    
    <build>
        <plugins>

            <!-- Executable Fat JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>
                                false
                            </createDependencyReducedPom>
                            <transformers>
                                <transformer implementation=
                                  "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>
                                        com.dedetok.testargon2.TestArgon2
                                    </mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
    
</project> 

Create class Argon2Util.java


package com.dedetok.testargon2;

import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;

public final class Argon2Util {

    private static final Argon2PasswordEncoder ENCODER =
        new Argon2PasswordEncoder(
            16,       // Salt length
            32,       // Hash length
            1,        // Parallelism
            65536,    // Memory in KB
            3         // Iterations
        );

    private Argon2Util() {
    }

    public static String hash(String password) {
        return ENCODER.encode(password);
    }

    public static boolean verify(
            String password, String encodedPassword) {
        return ENCODER.matches(password, encodedPassword);
    }

    public static boolean needsRehash(String encodedPassword) {
        return ENCODER.upgradeEncoding(encodedPassword);
    }
}

Edit your main java i.e. TestArgon2

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 */

package com.dedetok.testargon2;

/**
 *
 * @author dedetok
 */
public class TestArgon2 {

    public static void main(String[] args) {
        String password = "Admin123!";

        // Generate Argon2id hash
        String hash = Argon2Util.hash(password);

        System.out.println("Password hash:");
        System.out.println(hash);

        // Verify correct password
        boolean valid = Argon2Util.verify(password, hash);

        System.out.println("Valid: " + valid);

        // Verify incorrect password
        boolean invalid = Argon2Util.verify(
            "WrongPassword", hash
        );

        System.out.println("Wrong password: " + invalid);

        // Check whether hash needs upgrading
        System.out.println(
            "Needs rehash: " +
            Argon2Util.needsRehash(hash)
        );
    }
}

Run it

Password hash:
$argon2id$v=19$m=65536,t=3,p=1$SKMWhg5HU4KdbuDFVpEezg$KNrdlqtz7AmAymyafWNvjZRaW3a3EwidxKb8C0WdE54
Valid: true
Wrong password: false
Needs rehash: false

the hash may different on your computer.

this code will uses 64MB of your ram to generate the password, this is general purpose and lighter argon configuratoin

    /*
    // uses 64MB Ram
    private static final Argon2PasswordEncoder ENCODER =
        new Argon2PasswordEncoder(
            16,       // Salt length
            32,       // Hash length
            1,        // Parallelism
            65536,    // Memory in KB
            3         // Iterations
        );
    */

    // uses 19MB
    private static final Argon2PasswordEncoder ENCODER =
    new Argon2PasswordEncoder(
        16,       // Salt: 16 bytes
        32,       // Hash: 32 bytes
        1,        // Parallelism
        19456,    // Memory: 19 MiB
        3         // Iterations
    );

You can adjust to balance security and hardware load.


Monday, November 9, 2026

Laptop board manufacture and name

From Debian 13 output

# cat /sys/devices/virtual/dmi/id/board_name
AKN79C-140P-IMR
# cat /sys/devices/virtual/dmi/id/board_vendor
SU
 

No Type Board Manufacture Board Type
1 Lenovo IdeaPad Gaming 3 15ARH7 LENOVO LNVNB161216
2 Advan Workplus AI Heritage (Model: L26B-R72S1) SU AKN79C-140P-IMR

Know your laptop hardware (advan heritage ai 7 255)

To find out manufacture model of your main board

windows PowerShell

C:\windows\system32> Get-CimInstance Win32_BaseBoard | Format-List Manufacturer, Product, Version


Manufacturer : SU
Product      : AKN79C-140P-IMR
Version      : Version 1.0

Debian

# cat /sys/devices/virtual/dmi/id/board_name
AKN79C-140P-IMR
# cat /sys/devices/virtual/dmi/id/board_vendor
SU

SU stands for Sixunited (Shanghai Sixunited Intelligent Technology Co.

To find out NVME model

Debian

# apt install nvme-cli
...
# nvme id-ctrl /dev/nvme0 | grep -E 'mn|fr'
mn        : HS-SSD-WAVE(P) 256G                     
fr        : SN17027 
frmw      : 0x1a
mntmt     : 373
mnan      : 0
mnsudmq   : 0

It is Hiksemi wave(p) 256GB, safe running temperature 70°C. NVMe SSD already has APST enabled and is configured to use its deepest power-saving state, PS4.

 

Saturday, November 7, 2026

Debian 13: installing mobile verification toolkit to trace pegasus malware for android devices

Mobile Verification Toolkit (MVT) is a tool to facilitate the consensual forensic analysis of Android and iOS devices, for the purpose of identifying traces of compromise. The Mobile Verification Toolkit (MVT) was developed by the Amnesty International Security Lab. Note: mvt is not removal tools.

Here are common known spyware can be trace by MVT:

  1. Pegasus: NSO Group spyware targeting iOS and Android
  2. Predator: Commercial spyware associated with Intellexa
  3. Reign: Sophisticated spyware associated with QuaDream
  4. Hermit: Commercial spyware associated with RCS Lab
  5. KingsPawn: Spyware associated with QuaDream investigations
  6. FinSpy / FinFisher: Commercial surveillance software
  7. DarkCaracal: Mobile surveillance campaign targeting Android devices

Install python 

# apt install python3 python3-venv sqlite3 libusb-1.0-0 libimobiledevice-utils usbmuxd pipx

Install adb for android

# apt install -y android-sdk-platform-tools android-sdk-platform-tools-common

Create virtual python 

$ pipx ensurepath
Success! Added /[home_user]/.local/bin to the PATH environment variable.

Consider adding shell completions for pipx. Run 'pipx completions' for
instructions.

You will need to open a new terminal or re-login for the PATH changes to take
effect. Alternatively, you can source your shell's config file with e.g.
'source ~/.bashrc'.

Otherwise pipx is ready to go!

Install mvt

$ pipx install mvt
  installed package mvt 2026.11.2, installed using Python 3.13.5
  These apps are now globally available
    - mvt
    - mvt-android
    - mvt-ios
⚠️  Note: '/[home_user]/.local/bin' is not on your PATH environment
    variable. These apps will not be globally accessible until your PATH is
    updated. Run `pipx ensurepath` to automatically add it, or manually modify
    your PATH in your shell's config file (e.g. ~/.bashrc).
done!
$ ls ./.local/bin/
mvt  mvt-android  mvt-ios

To update mvt

$ pip3 install --upgrade mvt

Add virtual python binary 

$ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
$ mvt version


        MVT - Mobile Verification Toolkit

        https://mvt.re
        Version: 2026.11.2

        You have not yet downloaded any indicators, check the `download-iocs` 
command!

Download / Update spyware indicators

$ mvt download-iocs


        MVT - Mobile Verification Toolkit

        https://mvt.re
        Version: 2026.11.2

        You have not yet downloaded any indicators, check the `download-iocs` 
command!


               [mvt.common.updates] Downloaded indicators "NSO Group Pegasus 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_AmnestyTec
h_investigations_master_2021-07-18_nso_pegasus.stix2
               [mvt.common.updates] Downloaded indicators "Predator Spyware 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_intellexa_predator_predator.stix2
               [mvt.common.updates] Downloaded indicators "RCS Lab Spyware 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2022-06-23_rcs_lab_rcs.stix2
               [mvt.common.updates] Downloaded indicators "Stalkerware 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_AssoEchap_
stalkerware-indicators_master_generated_stalkerware.stix2
               [mvt.common.updates] Downloaded indicators "Surveillance campaign
linked to mercenary spyware company" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_AmnestyTec
h_investigations_master_2023-03-29_android_campaign_malware.stix2
               [mvt.common.updates] Downloaded indicators "Quadream KingSpawn 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2023-04-11_quadream_kingspawn.stix2
               [mvt.common.updates] Downloaded indicators "Operation 
Triangulation Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2023-06_01_operation_triangulation_operation_triangulation
.stix2
               [mvt.common.updates] Downloaded indicators "WyrmSpy and DragonEgg
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2023-07-25_wyrmspy_dragonegg_wyrmspy_dragonegg.stix2
               [mvt.common.updates] Downloaded indicators "Wintego Helios 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_AmnestyTec
h_investigations_master_2024-05-02_wintego_helios_wintego_helios.stix2
               [mvt.common.updates] Downloaded indicators "NoviSpy (Serbia) 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_AmnestyTec
h_investigations_master_2024-12-16_serbia_novispy_novispy.stix2
               [mvt.common.updates] Downloaded indicators "EagleMsgSpy 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2024-12-25_eaglemsgspy_eaglemsgspy.stix2
               [mvt.common.updates] Downloaded indicators "Candiru 
(DevilsTongue) Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_candiru_candiru.stix2
               [mvt.common.updates] Downloaded indicators "ResidentBat 
Indicators of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_ResidentBat_residentbat.stix2
               [mvt.common.updates] Downloaded indicators "Cellebrite Indicators
of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_cellebrite_cellebrite.stix2
               [mvt.common.updates] Downloaded indicators "DarkSword Indicators 
of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2026-03-30_darksword_darksword.stix2
               [mvt.common.updates] Downloaded indicators "Coruna Indicators of 
Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2026-03-03_coruna_cryptowaters_coruna.stix2
               [mvt.common.updates] Downloaded indicators "Morpheus Indicators 
of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2026-04-23_ips_morpheus_morpheus.stix2
               [mvt.common.updates] Downloaded indicators "BTMOB Indicators of 
Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2026-05-26_btmob_btmob.stix2
               [mvt.common.updates] Downloaded indicators "Spyrtacus Indicators 
of Compromise" to 
/[home_user]/.local/share/mvt/indicators/raw.githubusercontent.com_mvt-projec
t_mvt-indicators_main_2026-04-09_sio_spyrtacus_spyrtacus.stix2
$ mvt version
        MVT - Mobile Verification Toolkit

        https://mvt.re
        Version: 2026.11.2

        Indicators updates checked recently, next automatic check in 12 hours

MVT installation done.

NOTE: steps below does not tested, and may different output depends on your android phone. 

You MUST enable developer option and debug on your Android phone.  Connect your android phone using usb cable.

create directory for forensic

$ mkdir -p ~/forensics/{evidence/android,working/android,reports/android}

Pull your data from android phone

$ adb bugreport ~/forensics/evidence/android/bugreport.zip

Scan your data to find evidence of spying malware 

$ mvt-android check-bugreport -o ~/forensics/reports/android/ ~/forensics/evidence/android/bugreport.zip

Find out the result on folder ~/forensics/reports/android/ 

 

Monday, October 26, 2026

Debian 13: patching CVE-2026-109618 and CVE-2026-109619 php2shell

known CVE-2026-109618 and CVE-2026-109619

Description: PHP uses longjmp() for out-of-memory (OOM) errors to exit the current context and abort handling of the request. Some contexts may not properly account for this scenario and leave request memory in an uninitialized state before performing an allocation. The subsequent request cleanup procedure may read or branch on this memory. Multiple OOM strategies can consistently trigger this condition and lead to remote code execution (RCE).

Offical debian patch

  • debian 12 php 8.2 -> fix 8.2.35 
  • debian 13 php 8.4 -> fix 8.4.27

source: https://security-tracker.debian.org/tracker/CVE-2026-109618

The steps are

  1. check your php version# php -v
    PHP 8.4.26 (cli) (built: Sep 24 2026 17:16:18) (NTS)
    Copyright (c) The PHP Group
    Built by Debian
    Zend Engine v4.4.26, Copyright (c) Zend Technologies
        with Zend OPcache v8.4.26, Copyright (c), by Zend Technologies
  2. perform upgrade if patch require
    # apt update && apt upgrade -y
    ...
  3. check php version after upgradea
    < # php -v PHP 8.4.27 (cli) (built: Oct 21 2026 07:53:46) (NTS) Copyright (c) The PHP Group Built by Debian Zend Engine v4.4.27, Copyright (c) Zend Technologies with Zend OPcache v8.4.27, Copyright (c), by Zend Technologies
  4. Restart your apache 
    # systemctl restart apache2
  5. Restart PHP-FPM if you install it
    # systemctl restart php8.4-fpm

Warning: for server running Debian 11 24/7 and lower, please upgrade to Debian 12 to get patch! 

If you can not upgrade your os these are minimum php version had been patched:

  1. **PHP 8.2:** minimum 8.2.35
  2. **PHP 8.3:** minimum 8.3.36
  3. **PHP 8.4:** minimum 8.4.27
  4. **PHP 8.5:** minimum 8.5.12

If your php below those version e.g. php 7.4, these are configuration for emergency:

  1. apache include wamp

    # Limit request body size to 2MB (adjust based on your app's actual needs)
    LimitRequestBody 2097152
    # if you use php-fpm
    pm.max_requests = 1 if using PHP-FPM
  2. nginx

    http {
        client_max_body_size 2m;
    }
  3. lighttpd

    server.max-request-size = 2048
  4. iis with http

    <configuration>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="2097152" />
                </requestFiltering>
           </security>
       </system.webServer>
    </configuration>
  5. caddy

    example.com {
        route {
            request_body {
                max_size 2MB
            }
            php_fastcgi localhost:9000
        }
    }
  6. haproxy
    tune.http.maxrequest 

 

 

Saturday, October 24, 2026

Windows: fix boot manager after downgrade windows 11 to windows 10 on HP 15-AF109AX

Symptom: windows boot show 2 option, windows 10 and windows recovery

Assume: partition windows 11 has been replace with windows 10. 

i used these steps to downgrade win 11 to win 10 (fresh install)

  1. use gparted to delete drive c windows 11, resize esp partition from 100mb to 300mb (dual boot Debian), 
  2. use original iso dvd to install Windows 10.
  3. download and install wifi driver sp78044.exe from hp web. i download from existing debian inside this laptop, mount ntfs, and copy the file to windows directory. here is the url https://ftp.hp.com/pub/softpaq/sp78001-78500/sp78044.exe.

Find windows recovery / old windows i.e. windows 11

C:\Windows\system32>bcdedit /enum

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume2
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {current}
resumeobject            {b9a24d5c-cf4c-11f1-88b8-fa1143ace85b}
displayorder            {current}
                        {7c1da856-b085-11ec-bcd2-a47027794018}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.efi
description             Windows 10
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {b9a24d5e-cf4c-11f1-88b8-fa1143ace85b}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \Windows
resumeobject            {b9a24d5c-cf4c-11f1-88b8-fa1143ace85b}
nx                      OptIn
bootmenupolicy          Standard

Windows Boot Loader
-------------------
identifier              {7c1da856-b085-11ec-bcd2-a47027794018}
device                  unknown <-----------------------------------
path                    \WINDOWS\system32\winload.efi
description             Windows 10
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {7c1da857-b085-11ec-bcd2-a47027794018}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                unknown
systemroot              \WINDOWS
resumeobject            {7c1da855-b085-11ec-bcd2-a47027794018}
nx                      OptIn
bootmenupolicy          Standard

Remove  windows recovery / old windows 

C:\Windows\system32>bcdedit /delete {7c1da856-b085-11ec-bcd2-a47027794018}
The operation completed successfully.

Restart your laptop to test it.

We dont want windows 10 upgrading to windows 11

  1. open regedit (run->regedit)
  2. go to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows 
  3. create a new key WindowsUpdate if not exist
  4. at right side create these values:
    • ProductVersion -> String Value -> Windows 10
    • TargetReleaseVersionInfo -> String Value -> 22H2
    • TargetReleaseVersion -> DWORD (32-bit) -> 1

 or copy this to notepad and save as no_win11.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate]
"TargetReleaseVersion"=dword:00000001
"ProductVersion"="Windows 10"
"TargetReleaseVersionInfo"="22H2"

then right click to file and merge 

Tuesday, October 20, 2026

Debian 13: in dual boot, grub update can not fix debian boot

Go into windows and open cmd with administrator 

C:\Windows\System32>bcdedit /enum all

Firmware Boot Manager
---------------------
identifier              {fwbootmgr}
displayorder            {bootmgr}
                        {e074b9af-824b-11f1-806d-806e6f6e6963}
                        {3923b543-cc0a-11f1-9907-806e6f6e6963}
timeout                 1

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume2
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  id-ID
inherit                 {globalsettings}
default                 {current}
resumeobject            {d5b4c214-c5eb-11f0-b9cc-bfd3f4d1aeed}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 30

Firmware Application (101fffff)
-------------------------------
identifier              {3923b543-cc0a-11f1-9907-806e6f6e6963}
device                  partition=\Device\HarddiskVolume2
path                    \EFI\debian\shimx64.efi
description             debian

Firmware Application (101fffff)
-------------------------------
identifier              {e074b9af-824b-11f1-806d-806e6f6e6963}
device                  partition=\Device\HarddiskVolume2
path                    \EFI\RECOVERY\BOOT\BOOTMGFW.EFI
description             Windows Boot Manager
....

run

C:\Windows\System32>bcdedit /set {fwbootmgr} displayorder {3923b543-cc0a-11f1-9907-806e6f6e6963} {bootmgr} {e074b9af-824b-11f1-806d-806e6f6e6963}
The operation completed successfully. 

confirm boot order

C:\Windows\System32>bcdedit /enum all

Firmware Boot Manager
---------------------
identifier              {fwbootmgr}
displayorder            {3923b543-cc0a-11f1-9907-806e6f6e6963}
                        {bootmgr}
                        {e074b9af-824b-11f1-806d-806e6f6e6963}
timeout                 1

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume2
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  id-ID
inherit                 {globalsettings}
default                 {current}
resumeobject            {d5b4c214-c5eb-11f0-b9cc-bfd3f4d1aeed}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 30

Firmware Application (101fffff)
-------------------------------
identifier              {3923b543-cc0a-11f1-9907-806e6f6e6963}
device                  partition=\Device\HarddiskVolume2
path                    \EFI\debian\shimx64.efi
description             debian

Firmware Application (101fffff)
-------------------------------
identifier              {e074b9af-824b-11f1-806d-806e6f6e6963}
device                  partition=\Device\HarddiskVolume2
path                    \EFI\RECOVERY\BOOT\BOOTMGFW.EFI
description             Windows Boot Manager
... 

Restart your computer.

Last option, change boot order from Bios (depends on vendor) 

Bios -> Boot NVME Drive BBS Priorities  

Monday, October 19, 2026

windows 11: find esp partition free space

use cmd or powershell and use disk part to mount esp partition

C:\Windows\System32>diskpart

Microsoft DiskPart version 10.0.26100.1150

find which is esp partition

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     C   Windows_Bon  NTFS   Partition    137 GB  Healthy    Boot
  Volume 1     D   Data_Boni    NTFS   Partition     20 GB  Healthy
  Volume 2         SYSTEM       FAT32  Partition    100 MB  Healthy    System
  Volume 3         Recovery     NTFS   Partition   1001 MB  Healthy    Hidden

select volume, it is volume 2 

DISKPART> select volume 2

Volume 2 is the selected volume. 

assign drive letter for volume 2

DISKPART> assign letter=z

DiskPart successfully assigned the drive letter or mount point.

exit, and run command dir z: and at the it will show free space ",,,,,  bytes free"

Don't forget to remove drive letter, replace assign letter=z to  remove letter=z

 

Wednesday, October 14, 2026

Debian 13: jakarta tomcat create servlet using Netbeans

This steps use Netbeans version 31.

to create tomcat apache project in netbeans follow these steps:

  1. open your netbeans
  2. File -> New Project -> java with Maven -> Web Application
  3. fill "Project Name" e.g. My Servlet
  4. in New Web Application -> Server click Add
  5. select Apache Tomcat or TomEE
  6. select your jakarta tomcat directory
  7. fill username and password from tomcat-users.xml file which is has rule rolename="manager-gui"
  8. Finish will return to New Web Application, then Finish 

to create a new servlet

  1. From your project -> Source Packages -> <package_name>. MyServlet, right click and create New -> Servlet
  2. Class Name: HelloWorld, then next
  3. Servlet Name: My Servlet
  4. URL Pattern: /HelloWorkd
  5. This will create default response
  6. run from your netbeans, and your HelloWorld will appear in browser with url http://localhost:8080/MyServlet/HelloWorld

now, we add mariadb into our project, edit Project Files -> pom.xml

     <dependencies>
        ....
        <!-- MariaDB JDBC driver -->
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>3.5.10</version>
        </dependency>
    </dependencies>

now edit HelloWorld.java

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet HelloWorld </title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet HelloWorld at " + request.getContextPath() + " 0261015</h1>");
            
            // connect to db
            out.println("<p>connecting to mariadb</p>");
            
            try {
                Class.forName("org.mariadb.jdbc.Driver");
                out.println("<p>MariaDB JDBC driver FOUND</p>");
                
                try (java.sql.Connection conn =
                        java.sql.DriverManager.getConnection(
                            "jdbc:mariadb://localhost:3306/<db_name>",
                            "<db_user>",
                            "<db_password>")) {

                    out.println("<p>MariaDB CONNECTION SUCCESSFUL</p>");
                    out.println("<p>Database: "
                            + conn.getCatalog() + "</p>");
                } catch (SQLException ex) {
                    out.println("<p>Error"+ex.getMessage()+"</p>");
                }
                
            } catch (ClassNotFoundException e) {
                out.println("<p>MariaDB JDBC driver NOT FOUND</p>");
            }
            
            out.println("</body>");
            out.println("</html>");
        }
    }

run your servlet.

if no error found, you may start writing your application.  

hint: use any ai to find error in your code, copy paste code and error. but Do Not rely on it, use your instinct to fix your code, ai may made mistake.  

Monday, September 28, 2026

Cara daftar ke poliklinik RSCM dengan aplikasi RSCMku

Asumsi aplikasi RSCMku telah aktif. 

antrian poliklinik mandiri:

Masuk ke menu "Perjanjian Online"

lengkapi cara pembayaran, poliklinik rawat jalan, dan dokternya.

setelah terbuat, tunggu sampai hari H. Asumsi janji dengan dokter jam 14.

Datang ke Pelayanan Rawat Jalan RSCM jam 30 menit sebelum.jam 14 . 

validasi sidik jari di vending mesin yang tersedia.

15 menit sebelum jam 14, melalui aplikasi, anda dapat melakukan checkin. alternatif, 15 menit sebelum jam 14, lakukan checkin di vending mesin yang tersedia.

anda tunggu panggilan di poliklinik yang amda tuju.


antrian poliklinik yang dibuat dokter:

datang 30 menit sebelum jam janji dengan dokter

sidik jarivalidasi sidik jari di vending mesin yang tersedia

checkin 10 menit sebelum waktu janji 

tunggi di poli


antrian farmasi

dokter akan mengirim resep, akan muncul notifikasi di handphone

konfirmasi,  'resep terkirim'

 tunggu status 


antrian laboratorium

laboratorium darah

ambil no

jangan salah

lab patologi & mikrobiologi klinik

lab patologi anatomik

pilih apakah pakai jaminan atau tidak.

nanti akan dipanggil nomornya untuk verifikasi

bila ok, akan diberikan no ambil darah, urine atau feses, sesuai dengan rekomendasi dokter.

setelah sampel sudah lengkap, status lab dapat dilihat di rscmku

aerelah statua selesai, dapat langsung diambil tanpa harus mengambil no antrian, langsung ke counter. 


Semoga lekas sembuh ❤️


Friday, September 25, 2026

Android Studio: extract public key for your application SHA 256

To extract public for you application follow one of these way:

1. From Android Studio

open  Terminal and run 

$ ./gradlew signingReport
...
SHA1: BA:44:...
SHA-256: 61:8C:...
...

2. Using keytool

from directory where jks file locate execute

$ keytool -list -v -keystore ./<jks_name>.jks -alias <your_key>
Enter keystore password:  
Alias name: <your_key>
Creation date: Apr 2, 2024
Entry type: PrivateKeyEntry
...
Valid from: Tue Apr 02 11:18:07 WIB 2024 until: Sat Mar 27 11:18:07 WIB 2049
Certificate fingerprints:
     SHA1: 4B:F2:...
     SHA256: 5F:A0:...
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 2048-bit RSA key
Version: 1

You can upload / paste your SHA 256 to your play store console  

 

 

 

Android Studio: error Incompatible Gradle JVM version The project's Gradle version 8.13 is incompatible with the Gradle JVM version 25 currently selected to run Gradle build. Gradle 8.13 supports Java versions between 1.8 and 23. Please update the selected JVM to a compatible version.

"Incompatible Gradle JVM version The project's Gradle version 8.13 is incompatible with the Gradle JVM version 25 currently selected to run Gradle build. Gradle 8.13 supports Java versions between 1.8 and 23. Please update the selected JVM to a compatible version. 
Apply compatible Gradle JDK configuration and sync Change Gradle JDK configuration"

to repair android studio error abov, goto File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JDK, then select your current JDK folder i.e. /usr/lib/jvm/java-21-openjdk-amd64. Then sync project.  

Thursday, September 24, 2026

Asus eee pc 1215b dual boot (debian and windows), downgrade windows 10 to windows 7 pro x64

the disk of system used mbr/dos partition. there are 2 option to install windows 7 pro:

  1. using usb and rufus in mbr mode
  2. using cd/dvd rom
for systen with mbr/dos partition, using cd/dvd is easier. 

the installation is straight forward. yoy format c:/ contains windows 10 , and select this disk as target your windows 7 pro x64. it takes 30 minutes to insta windows 7 pro x64 from dvd.

you need to install driver for vga, wifi and usb. my system uses broadcom bcm4313 combo bluetooth. drives is not exist in official website for asus eee pc 1215b, but exis asus support. alternative, downloas bcm4313 from windowa catalog. you can uses your existing debian to download driver after you repair grub boot.

to repair your existinf grub follow these steps:
  1. boot from any debian media 
  2. enter rescue mode, debian will load any components require.
  3. choose your root system 
  4. choose execute a shell 
  5. run 
# grub-install /dev/sda/
# update-grub

after you restart to your syatem and find no windows option at grub screen, enter into your debian. then at root shell execute 

# update-grub

microsoft has closed any support to windows 7, click on windows update will useless.

Note: your internet explorer will rejected by seach engine because it is too old. the option is using supermium browser.

open your internel explorer and type https://www.supermium.net/. download and install it. dont use internet to open or search supermium, the most search engine server will reject your internet explorer.

if you are not sure about supermium security, use your debian 13 with icewn to browse sensitive application like email or banking.  

Friday, September 18, 2026

Debian 13: jakarta tomcat create servlet manually

under directory WEB-INF create 2 folder

  1. src
  2. classes 

under src, we place servlet and java code.

for package com.dedetok, create folder ~/WEB-INF/src/com/dedetok/ and write 2 files

MyWorld.java

package com.dedetok;

public class MyWorld {

    public String getMessage() {
        return "hello world";
    }
}

HelloServlet.java 

package com.dedetok;

import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

public class HelloServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request,
                          HttpServletResponse response)
            throws IOException {

        MyWorld world = new MyWorld();

        response.setContentType("text/plain");
        response.getWriter().println(world.getMessage());
    }
} 

We map our servlet, edit ~/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
                             https://jakarta.ee/xml/ns/jakartaee/web-app_6_1.xsd"
         version="6.1">

    <display-name>My Application</display-name>

    <servlet>
        <servlet-name>Hello Anything</servlet-name>
        <servlet-class>com.dedetok.HelloServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Hello Anything</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>
</web-app>

Note: <servlet-name> between <servlet> and <servlet-mapping> must match.

compile your java, go it ~/WEB-INF/ folder and run

$ javac   -cp <your_path_to_jakarta_tomcat>/apache-tomcat-11.0.26/lib/servlet-api.jar   -d ./classes   ./src/com/dedetok/*.java 

restart your jakarta tomcat and try servlet http://localhost:8080/myapp/hello. hello comes from <servlet-mapping>

It is not practicable to map every servlet, there is other way

now at directory ~/WEB-INF/src/com/dedetok/  create HelloServlet2.java

package com.dedetok;

import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import jakarta.servlet.annotation.WebServlet;

@WebServlet("/hello2")
public class HelloServlet2 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request,
                          HttpServletResponse response)
            throws IOException {

        MyWorld world = new MyWorld();

        response.setContentType("text/plain");
        response.getWriter().println(world.getMessage()+" 2");
    }
}  

we use  @WebServlet("/hello2") to map url. do not forget to import  jakarta.servlet.annotation.WebServlet.

compile it, and restart your jakarta tomcat. you can access it via http://localhost:8080/myapp/hello2.

To use MyWorld class into jsp, at directory ~/myapp/ (upper directory from WEB-INF) , create file callservlet.jsp

<%@ page import="com.dedetok.MyWorld" %>

<%
    MyWorld world = new MyWorld();
%>

<html>
<body>
    <h1><%= world.getMessage() %></h1>
</body>
</html> 

or use wildcard for import="com.dedetok.*"  

Now you can directly build your application. MVC model can be used if you like. happy coding.  

 

Thursday, September 17, 2026

Debian 13: jakarta tomcat add application myapp manually without war (part 2)

It this part, we will: 

  1. Add myapp
  2. Add mariadb library

Add myapp

  1. under folder <home>/webapps/ create folder myapp
  2. under folder <home>/webapps/myapp/  create folder WEB-INF
  3. optional, at folder <home>/webapp/myapp> write index.html e.g  
<!DOCTYPE html>
<html lang="en">
<body>
    <h1>Hello, World!</h1>
</body>
</html>

Restart your jakarta tomcat, and myapp appear in list of application. Test your index.html, url http://localhost:8080/myapp/.

Add mariadb 

  1. Under folder  <home>/webapps/myapp/WEB_INF, create folder lib.
  2. download jconnect from https://mariadb.org/connector-java/all-releases/, and put it in <home>/webapps/myapp/WEB_INF/lib, i.e. <home>/webapps/myapp/WEB-INF/lib/mariadb-java-client-3.5.3.jar

Under folder  <home>/webapps/myapp/ write test.jsp

<%
try {
    Class.forName("org.mariadb.jdbc.Driver");
    out.println("MariaDB JDBC driver FOUND");
} catch (ClassNotFoundException e) {
    out.println("MariaDB JDBC driver NOT FOUND");
}
%>

restart your jakarta tomcat and test it http://localhost:8080/myapp/test.jsp.

if you have mariadb running, you can extend test.jsp to this

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>

<%
try {
    Class.forName("org.mariadb.jdbc.Driver");
    out.println("MariaDB JDBC driver FOUND<br>");

    Connection conn = DriverManager.getConnection(
        "jdbc:mariadb://localhost:3306/mydb", // change to your db name
        "admin", // change to your user
        "admin" // change to your password
    );

    out.println("Connected to MariaDB!<br>");

    conn.close();

} catch (ClassNotFoundException e) {
    out.println("MariaDB JDBC driver NOT FOUND<br>");
    out.println(e);

} catch (Exception e) {
    out.println("Database connection FAILED<br>");
    out.println(e);
}
%> 

 

 

 

Debian 13: jakarta tomcat & openjdk 21 installation (part 1)

Assume openjdk 21 installed, it is lts verssion.

Download latest jakarta tomcat from https://tomcat.apache.org/download-11.cgi, i.e. version 11.0.26 (currently).

extract it into your home (user) directory

change permission to start jakarta tomcat

$ cd apache-tomcat-11.0.26/bin/
$ chmod 744 *.sh

Directory structure is:

  • bin
  • conf
  • lob
  • logss
  • temps
  • webapps
  • work 

You must add user to manage your jakarta tomcat. User rules are:

  1. manager-gui - allows access to the HTML GUI and the status pages
  2. manager-script - allows access to the text interface and the status pages
  3. manager-jmx - allows access to the JMX proxy and the status pages
  4. manager-status - allows access to the status pages only 

Edit <tomcat_home>/conf/tomcat-users.xml

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
...
  <role rolename="manager-gui"/>
  <user username="admin" password="admin" roles="manager-gui"/>
</tomcat-users> 

To run jakarta tomcat

$ ./startup.sh&
[1] 6430
~/apache-tomcat-11.0.26/bin$ Using CATALINA_BASE:   <home>/apache-tomcat-11.0.26
Using CATALINA_HOME:   <home>/apache-tomcat-11.0.26
Using CATALINA_TMPDIR: <home>/apache-tomcat-11.0.26/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       <home>/apache-tomcat-11.0.26/bin/bootstrap.jar:<home>/apache-tomcat-11.0.26/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.

[1]+  Done                    ./startup.sh

Open your browser and open url http://localhost:8080/. 

To shutdown, run $ ./shutdown.sh.

Your application will on <home>/webapps and root for http://localhost:8080 is on <home>/webapps/ROOT/

For production, go to "List Application", Undeploy any unused applications.  

 

Friday, July 10, 2026

Debian 13: installing mysql-workbench-community

Download apt configuration from https://dev.mysql.com/downloads/repo/apt/ , current version is mysql-apt-config_0.8.39-1_all.deb

here is configuration for non cluster only target to mysql workbench

  • MySql Server & Cluster: mysql 8.4 lts
  • MySql Connector: non/disable -> enable if you need MySql connector e.g. jConnector

# dpkg -i mysql-apt-config_0.8.39-1_all.deb 
Selecting previously unselected package mysql-apt-config.
(Reading database ... 232081 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.39-1_all.deb ...
Unpacking mysql-apt-config (0.8.39-1) ...
Setting up mysql-apt-config (0.8.39-1) ...

mysql-workbench-community is not available for Debian 13  

credit: online html escape https://www.freeformatter.com/html-escape.html#before-output 

Thursday, June 25, 2026

Menelpon keluar negeri berdasarkan operator dan NATO phonetic alphabet

Menelpon keluar negeri berdasarkan operator 

  1.  telkomsel/by.u
    1. 01017+[nomor_lengkap] tarif Rp. 350 per menit terbatas negara: Australia, Bangladesh, Brunei Darussalam, China, Hong Kong, India, Malaysia, Singapura, Korea Selatan, Thailand, dan Amerika Serikat/Kanada (tidak termasuk destinasi Hawaii)
    2. 007+[nomor_lengkap] tarif Rp. 4.550 per menit
  2. indosat im3
    1. 001+[nomor_lengkap] atau 008+[nomor_lengkap] tarif cek https://im3.id/portal/id/psinternationalcallandsms contoh australia Rp. 5.000 per menit.
    2. 01016+[nomor_lengkap] tarif cek https://im3.id/portal/id/psinternationalcallandsms contoh australia Rp. 1.500 per menit.
  3. xl (tidak diinformasikan secara resmi di xl.co.id
    • 01000+[nomor_lengkap] atau 01017 +[nomor_lengkap], memerlukan paket Nelpon Internasional XL
  4. three/3
    1. 001+[nomor_lengkap] atau 008+[nomor_lengkap], memerlukan paket Paket Nelpon Luar Negeri, contoh australia Rp. 7.350 per menit 
    2. 01016+[nomor_lengkap], memerlukan paket Paket Nelpon Luar Negeri, contoh australia Rp. 1.500 per menit.  
    3. paket yang tersedia https://tri.co.id/nelpon-luar-negeri
      1. Nelpon Luar Negeri     30     1 Hari     30 Menit
      2. Nelpon Luar Negeri     100     30 Hari     100 Menit 

 

NATO phonetic alphabet:

  1. A – Alfa
  2. B – Bravo
  3. C – Charlie
  4. D – Delta
  5. E – Echo
  6. F – Foxtrot
  7. G – Golf
  8. H – Hotel
  9. I – India
  10. J – Juliett
  11. K – Kilo
  12. L – Lima
  13. M – Mike
  14. N – November
  15. O – Oscar
  16. P – Papa
  17. Q – Quebec
  18. R – Romeo
  19. S – Sierra
  20. T – Tango
  21. U – Uniform
  22. V – Victor
  23. W – Whiskey
  24. X – X-ray
  25. Y – Yankee
  26. Z – Zulu  

 

ETLE dan stnk terblokir saat perpanjangan

Sebelum perpanjangan stnk coba cek dulu, apakah kendaraan di blok terkait etle (Electronic Traffic Law Enforcement). jangan sampai di samsat baru buka blokiran ya, lama banget. 

Siapkan 

  1. Nomor kendaraan
  2. Nomor kerangka kendaraan
  3. Nomor mesin kendaraan

Buka internet melalui browser lalu cari "ETLE PMJ" melalui mesin pencari. ini link-nya https://etle-pmj.id/ , namun bisa berubah tergantung kondisi.

Masuk menu cek data, dan masukan data yang telah disiapkan. bila kendaraan kamu terkena etle, pastikan itu memang kendaraan milik anda. bila benar anda bisa melakukan konfirmasi. bila tidak benar anda bisa menyanggahnya.

Bila kendaraan terkena etle saat konfirmasi anda akan diminta melengkapi data pribadi untuk dapat dihubungi. berikan data yang benar. Setelah itu anda akan menerima surat perintah bayar dengan nomor "BRIVA" yang berupa 15 angka. Lakukan deposit denda melalui bank bri atau aplikasi bri. Dari bank lain, jumlah tidak muncul. setelah pembayaran, blokir stnk terbuka. 

Note: pastikan anda telah membayar semua pelanggaran yang tertangkap etle.

Setelah dibayar, akan muncul konfirmasi dan anda akan menerima pesan tanggal sidang dan "No Blanko Tilang". 

melalui browser cari "ETLE kejaksaan" atau https://tilang.kejaksaan.go.id/be/ untuk mengecek sidang anda.

setelah tanggal sidang anda bisa melihat besaran denda tilang yang dibebankan ke anda. bisa kurang atau lebih bayar tergantung putusan sidang.  bila lebih bayar, ada 2 pilihan, pengambilan tunai atau transfer ke bank bri.

Wednesday, June 17, 2026

Android java: migrate build to gradle version catalog

create a new gradle catalog, project -> gradle -> new -> Version Catalog, it will prompt "lib" and press enter.

fill libs.version.toml with agp version


[versions]
agp = "9.2.1"
appcompat = "1.7.1"
material = "1.14.0"
constraintlayout = "2.2.1"
junit = "4.13.2"
androidx-junit = "1.3.0"
espresso-core = "3.7.0"
play-services-ads-lite = "25.0.0"

[libraries]
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
material = { module = "com.google.android.material:material", version.ref = "material" }
constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" }

junit4 = { module = "junit:junit", version.ref = "junit" }
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-junit" }
espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso-core" }

play-services-ads-lite = { module = "com.google.android.gms:play-services-ads-lite", version.ref = "play-services-ads-lite" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }

agp in [version] and [plugin] must exist.

edit build.gradle.kts

change


dependencies {

    implementation("androidx.appcompat:appcompat:1.7.0")
    implementation("com.google.android.material:material:1.12.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.2.1")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
    implementation("com.google.android.gms:play-services-ads-lite:23.3.0")
}

 to


dependencies {

    implementation(libs.appcompat)
    implementation(libs.material)
    implementation(libs.constraintlayout)

    implementation(libs.play.services.ads.lite)

    testImplementation(libs.junit4)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.espresso.core)
}

Synchronize project and change


plugins {
    id("com.android.application")
}

to


plugins {
    alias(libs.plugins.android.application)
} 



Wednesday, June 10, 2026

Java: reading config.conf file

example config.conf


# http and https ports configuration
http_port = 48001
https_port = 48001

# printer port
printer_port=/dev/rfcomm0
# printer size
printer_size=80mm

java code


    // configuration file config.conf
    static final String linux_file_path = "/etc/dddtescpos/config.conf";
    static final String file_path = "./config.conf";

    public static String printer_port = null;
    public static String printer_size = null;
    
    public static int http_port = -1;
    public static int https_port = -1;
    
    public static void readConfig() {
        Path configFile = Paths.get(linux_file_path);
        
        if (Files.notExists(configFile)) {
            configFile = Paths.get(file_path);
        }
        
        // comment in config file will # or !
        Properties props = new Properties();

        try (InputStream input = Files.newInputStream(configFile)) {
            props.load(input);
        
            printer_port = props.getProperty("printer_port");
            printer_size = props.getProperty("printer_size");
            if (printer_size == null || printer_size.isBlank()) {
                printer_size = "80mm";   // default
            } else {
                printer_size = printer_size.trim().toLowerCase();

                if (!printer_size.equals("58mm")
                        && !printer_size.equals("80mm")) {
                    printer_size = "80mm";   // default for invalid value
                }
            }


            String tmpPort = props.getProperty("http_port","48001");
            try {
                int intTmpPort = Integer.parseInt(tmpPort); 
                if (intTmpPort<48000 || intTmpPort>65535)
                    intTmpPort = 48001;
                    http_port = intTmpPort;
            } catch (NumberFormatException ex) {
                http_port = 48001;
            }
            tmpPort = props.getProperty("https_port","48002");
            try {
                int intTmpPort = Integer.parseInt(tmpPort); 
                if (intTmpPort<48000 || intTmpPort>65535)
                    intTmpPort = 48002;
                https_port = intTmpPort;
            } catch (NumberFormatException ex) {
                https_port = 48002;
            }
            // if ports hava equal value, set default
            if (http_port == https_port) {
                http_port = 48001;
                https_port = 48002;
            }
        } catch (IOException ex) {
            System.out.println("No Configuration file found");
            http_port = 48001;
            https_port = 48002;            
        }
        
    }

 

Monday, June 8, 2026

Java: http and https (self sign certificate)

install mkcert


# apt install mkcert

go to root of netbeans project and create self sign certificate


$ mkcert localhost
Created a new local CA 💥
Note: the local CA is not installed in the system trust store.
Note: the local CA is not installed in the Firefox and/or Chrome/Chromium trust store.
Run "mkcert -install" for certificates to be trusted automatically ⚠️

Created a new certificate valid for the following names 📜
 - "localhost"

The certificate is at "./localhost.pem" and the key at "./localhost-key.pem" ✅

It will expire on 8 September 2028 🗓

Convert to PKCS 12


$ openssl pkcs12 -export \
  -in localhost.pem \
  -inkey localhost-key.pem \
  -out localhost.p12 \
  -name localhost
Enter Export Password:
Verifying - Enter Export Password:

main java code


/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 */

package com.dedetok.ddtescpos;

import com.alibaba.fastjson2.JSONObject;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpsConfigurator;
import com.sun.net.httpserver.HttpsExchange;
import com.sun.net.httpserver.HttpsServer;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;


/**
 *
 * @author dedetok
 */
public class DdtEscPos {

    final static String serviceString = "DdtEscPos";
    final static String serviceVersion = "1.0";
    
    public static void main(String[] args) {
        System.out.println("DdtEscPos reading configuration file");
        MyController.readConfig(); // if configuration not available, use hard code config
        
        System.out.println(serviceString+" "+serviceVersion);
        
        // ================= 
        try {
            HttpServer httpServer = createHttpService(MyController.http_port);
            HttpsServer httpsServer = createHttpsService(MyController.https_port);
            
            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
                System.out.println("Stopping HTTP & HTTPS server...");
                httpServer.stop(5); // stop 5 second
                System.out.println("HTTP server stopped");
                httpsServer.stop(5); // stop 5 second
                System.out.println("HTTPS server stopped");

            }));
            httpServer.start();
            System.out.println("HTTP server running on http://localhost:" + MyController.http_port);
            httpsServer.start();
            System.out.println("HTTPS server running on http://localhost:" + MyController.https_port);

        } catch (IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException | UnrecoverableKeyException | KeyManagementException ex) {
            System.getLogger(DdtEscPos.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex);
        }
    }

    /*
     * create http service in httpPort
     */
    static HttpsServer createHttpsService(int httpsPort) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException, KeyManagementException {
        // Load PKCS12 keystore
        char[] password = "escpos".toCharArray();
        KeyStore ks = KeyStore.getInstance("PKCS12");
        try (FileInputStream fis = new FileInputStream("localhost.p12")) {
            ks.load(fis, password);
        }

        KeyManagerFactory kmf = KeyManagerFactory.getInstance(
                KeyManagerFactory.getDefaultAlgorithm());
        
        kmf.init(ks, password);

        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(kmf.getKeyManagers(), null, null);

        // Create HTTPS server
        HttpsServer httpsServer =
                HttpsServer.create(
                        new InetSocketAddress("localhost", httpsPort),
                        0);        
    
        httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext));
        
        // Register endpoints
        httpsServer.createContext("/", DdtEscPos::handleHttpRequest);
        httpsServer.createContext("/printjson", DdtEscPos::handlePrintJson);        
        
        return httpsServer;
    }
    
    /*
     * create http service in httpPort
     */
    static HttpServer createHttpService(int httpPort) throws IOException {
        HttpServer httpServer =
                HttpServer.create(new InetSocketAddress("localhost", httpPort), 0);
        
        httpServer.createContext("/", DdtEscPos::handleHttpRequest);
        httpServer.createContext("/printjson", DdtEscPos::handlePrintJson);
        return httpServer;
    }

    /*
     * handling /
     */
    static void handleHttpRequest(HttpExchange exchange) throws IOException {
        // CORS
        exchange.getResponseHeaders().add(
                "Access-Control-Allow-Origin", "*");

        exchange.getResponseHeaders().add(
                "Access-Control-Allow-Headers",
                "Content-Type, Authorization");

        exchange.getResponseHeaders().add(
        "Access-Control-Allow-Methods",
        "GET, POST, OPTIONS");

        if ("OPTIONS".equalsIgnoreCase(exchange.getRequestMethod())) {
            exchange.sendResponseHeaders(204, -1);
            return;
        }
        
        // UTF-8 text response
        exchange.getResponseHeaders().add(
                "Content-Type",
                "text/plain; charset=UTF-8");
        
        String response = infoService(exchange).toString();

        byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);

        exchange.sendResponseHeaders(200, responseBytes.length);

        
        try (OutputStream os = exchange.getResponseBody()) {
            os.write(responseBytes);
        }
        System.out.println("Servicing client done"); // debug
    }

    /*
     * handling /printjson
     */
    static void handlePrintJson(HttpExchange exchange) throws IOException {
        // CORS
        exchange.getResponseHeaders().add(
                "Access-Control-Allow-Origin", "*");

        exchange.getResponseHeaders().add(
                "Access-Control-Allow-Headers",
                "Content-Type, Authorization");

        exchange.getResponseHeaders().add(
        "Access-Control-Allow-Methods",
        "GET, POST, OPTIONS");

        if ("OPTIONS".equalsIgnoreCase(exchange.getRequestMethod())) {
            exchange.sendResponseHeaders(204, -1);
            return;
        }
        
        // UTF-8 text response
        exchange.getResponseHeaders().add(
                "Content-Type",
                "text/plain; charset=UTF-8");
        // get json from request
        // Read request body
        String requestBody;
        try (InputStream is = exchange.getRequestBody()) {
            requestBody = new String(is.readAllBytes(), StandardCharsets.UTF_8);
            // Parse JSON
            // Parse JSON and process
            JSONObject json = JSONObject.parseObject(requestBody);

            JSONObject responseJson = infoService(exchange);
            
            try {
                MyController.printJson(json.toString());


                responseJson.put("status", "printing done");
            } catch (IOException ex) {
                responseJson.put("status", "printing fail");
                responseJson.put("error", ex.getMessage());
                
            }
            
            byte[] bytes =
                responseJson.toString().getBytes(StandardCharsets.UTF_8);

            exchange.sendResponseHeaders(200, bytes.length);
            OutputStream os = exchange.getResponseBody();
            os.write(bytes);
            os.flush();

        }
    }
    
    /* 
     * standard info response 
     */
    static JSONObject infoService(HttpExchange exchange) {
        JSONObject jsonObj = new JSONObject();
        
        jsonObj.put("version", serviceVersion);
        jsonObj.put("service", serviceString);
        jsonObj.put("status", "running");
        String host = exchange.getLocalAddress().getHostString();
        int port = exchange.getLocalAddress().getPort();

        String scheme = (exchange instanceof HttpsExchange)
        ? "https://"
        : "http://";
        
        String baseUrl = scheme + host + ":" + port;
        jsonObj.put("endpoint",baseUrl+"/printjson");
        
        return jsonObj;
    }
}

to run service


$ java -jar target/DdtEscPos-1.0.jar 
Hello World!
HTTP server running on http://localhost:50001
HTTPS server running on https://localhost:50002
Serviing client done
Serviing client done

using curl to send json to print http


$ curl -H "Content-Type: application/json" \
     -d @exampleescpos.json \
     http://localhost:50001/printjson

https


$ curl -k \
  -H "Content-Type: application/json" \
  -d @exampleescpos.json \
  https://localhost:50002/printjson

or 


$ curl --insecure \
  -H "Content-Type: application/json" \
  -d @exampleescpos.json \
  https://localhost:50002/printjson

Credit: esc html using https://www.freeformatter.com/html-escape.html 

Saturday, June 6, 2026

Java: using thermal printer 6106 - 80mm esc/pos java in debian 13 bluetooth

Install bluetooth software


$ apt install firmware-misc-nonfree bluez bluez-tools blueman screen

linux user groups: bluetooth, lp, netdev, sudo, and plugdev

add linux user to group


# usermod -aG sudo username

check your bluetooth adapter has been recognize by debian


$ lsusb
...
Bus 001 Device 003: ID 0489:e0cd Foxconn / Hon Hai MediaTek Bluetooth Adapter
...

pair your device, if you don't hook it in boot, you need to rebind after boot. 


$ bluetoothctl pair 86:67:7A:1D:C2:E3
Attempting to pair with 86:67:7A:1D:C2:E3
[CHG] Device 86:67:7A:1D:C2:E3 Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed

using bluetoothctl to handle bluetooth password


$ bluetoothctl
Agent registered
[bluetoothctl]> agent KeyboardOnly
Agent is already registered
[bluetoothctl]> default-agent
Default agent request successful
[bluetoothctl]> scan on
SetDiscoveryFilter success
Discovery started
[CHG] Controller BC:F4:D4:12:4C:28 Discovering: yes
[NEW] Device 4D:F9:CE:48:C4:1B 4D-F9-CE-48-C4-1B
[NEW] Device 62:FE:E1:08:CD:73 62-FE-E1-08-CD-73
[NEW] Device 6D:AC:09:7B:A7:F3 6D-AC-09-7B-A7-F3
[NEW] Device 86:67:7A:1D:C2:E3 RPP02N
[bluetoothctl]> pair 86:67:7A:1D:C2:E3
Attempting to pair with 86:67:7A:1D:C2:E3
[CHG] Device 86:67:7A:1D:C2:E3 Connected: yes
[CHG] Device 86:67:7A:1D:C2:E3 Bonded: yes
[CHG] Device 86:67:7A:1D:C2:E3 Modalias: usb:v05ACp0239d0644
[CHG] Device 86:67:7A:1D:C2:E3 ServicesResolved: yes
[CHG] Device 86:67:7A:1D:C2:E3 Paired: yes
Pairing successful
[DEL] Device 6D:AC:09:7B:A7:F3 6D-AC-09-7B-A7-F3
[CHG] Device 86:67:7A:1D:C2:E3 ServicesResolved: no
[CHG] Device 86:67:7A:1D:C2:E3 Connected: no
[DEL] Device 4D:F9:CE:48:C4:1B 4D-F9-CE-48-C4-1B
[DEL] Device 62:FE:E1:08:CD:73 62-FE-E1-08-CD-73
[bluetoothctl]> trust 86:67:7A:1D:C2:E3
[CHG] Device 86:67:7A:1D:C2:E3 Trusted: yes
Changing 86:67:7A:1D:C2:E3 trust succeeded

busctl output


$ busctl introspect org.bluez /org/bluez/hci0/dev_86_67_7A_1D_C2_E3
NAME                                TYPE      SIGNATURE RESULT/VALUE                             FLAGS
org.bluez.Device1                   interface -         -                                        -
.CancelPairing                      method    -         -                                        -
.Connect                            method    -         -                                        -
.ConnectProfile                     method    s         -                                        -
.Disconnect                         method    -         -                                        -
.DisconnectProfile                  method    s         -                                        -
.Pair                               method    -         -                                        -
.Adapter                            property  o         "/org/bluez/hci0"                        emits-change
.Address                            property  s         "86:67:7A:1D:C2:E3"                      emits-change
.AddressType                        property  s         "public"                                 emits-change
.AdvertisingData                    property  a{yv}     -                                        emits-change
.AdvertisingFlags                   property  ay        -                                        emits-change
.Alias                              property  s         "RPP02N"                                 emits-change writable
.Appearance                         property  q         -                                        emits-change
.Blocked                            property  b         false                                    emits-change writable
.Bonded                             property  b         true                                     emits-change
.Class                              property  u         263808                                   emits-change
.Connected                          property  b         false                                    emits-change
.Icon                               property  s         "printer"                                emits-change
.LegacyPairing                      property  b         false                                    emits-change
.ManufacturerData                   property  a{qv}     -                                        emits-change
.Modalias                           property  s         "usb:v05ACp0239d0644"                    emits-change
.Name                               property  s         "RPP02N"                                 emits-change
.Paired                             property  b         true                                     emits-change
.RSSI                               property  n         -                                        emits-change
.ServiceData                        property  a{sv}     -                                        emits-change
.ServicesResolved                   property  b         false                                    emits-change
.Sets                               property  a{oa{sv}} -                                        emits-change
.Trusted                            property  b         true                                     emits-change writable
.TxPower                            property  n         -                                        emits-change
.UUIDs                              property  as        7 "00000001-0000-1000-8000-00805f9b34fb… emits-change
.WakeAllowed                        property  b         -                                        emits-change writable
org.freedesktop.DBus.Introspectable interface -         -                                        -
.Introspect                         method    -         s                                        -
org.freedesktop.DBus.Properties     interface -         -                                        -
.Get                                method    ss        v                                        -
.GetAll                             method    s         a{sv}                                    -
.Set                                method    ssv       -                                        -
.PropertiesChanged                  signal    sa{sv}as  -                                        -

bind to rfcomm (sudo), if you don't hook it in boot, you need to rebind after boot. if you already trust the printer, just bind it.


  # rfcomm bind rfcomm0 86:67:7A:1D:C2:E3

or with sudo


  $ sudo  rfcomm bind rfcomm0 86:67:7A:1D:C2:E3

your dev access point


$ ls /dev/ | grep rfcomm
rfcomm0

get your bluetooth device info


$ bluetoothctl info 86:67:7A:1D:C2:E3
Device 86:67:7A:1D:C2:E3 (public)
	Name: RPP02N
	Alias: RPP02N
	Class: 0x00040680 (263808)
	Icon: printer
	Paired: yes
	Bonded: yes
	Trusted: yes
	Blocked: no
	Connected: no
	LegacyPairing: no
	UUID: SDP                       (00000001-0000-1000-8000-00805f9b34fb)
	UUID: RFCOMM                    (00000003-0000-1000-8000-00805f9b34fb)
	UUID: L2CAP                     (00000100-0000-1000-8000-00805f9b34fb)
	UUID: Serial Port               (00001101-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: Unknown                   (000018f0-0000-1000-8000-00805f9b34fb)
	UUID: Vendor specific           (e7810a71-73ae-499d-8c15-faa9aef0c3f2)
	Modalias: usb:v05ACp0239d0644

Optional: to let systemd handling pair device

create/edit bluetooth-printer.service (or any name you wish), at /etc/systemd/system/, e.g   /etc/systemd/system/bluetooth-printer.service.


[Unit]
Description=Bind Bluetooth Thermal Printer to rfcomm0
After=bluetooth.service
Requires=bluetooth.service

[Service]
Type=oneshot
ExecStart=/usr/bin/rfcomm bind rfcomm0 86:67:7A:1D:C2:E3
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

After that use systemd to handle pairing

  • sudo systemctl daemon-reload
  • sudo systemctl enable bluetooth-printer.service
  • sudo systemctl start bluetooth-printer.service
  • systemctl status bluetooth-printer.service 

you can try previous code https://dedetoknotes.blogspot.com/2026/06/java-using-thermal-printer-6106-80mm.html by change 

devicePath = "/dev/usb/lp1" 

to

devicePath = "/dev/rfcomm0" 

Credit: https://www.freeformatter.com/html-escape.html#before-output to esc html 

Monday, June 1, 2026

Java: using thermal printer 6106 - 80mm esc/pos java in debian 13 usb

insert your printer using usb cable


# lsusb
...
Bus 008 Device 002: ID 28e9:0289 GDMicroelectronics micro-printer
Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
# dmesg
[   70.532011] usb 8-1: new full-speed USB device number 2 using xhci_hcd
[   70.688254] usb 8-1: New USB device found, idVendor=28e9, idProduct=0289, bcdDevice= 2.00
[   70.688270] usb 8-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   70.688276] usb 8-1: Product: micro-printer
[   70.688282] usb 8-1: Manufacturer: GEZHI
[   70.688286] usb 8-1: SerialNumber: 000000000004
[   70.730721] usblp 8-1:1.0: usblp1: USB Bidirectional printer dev 2 if 0 alt 0 proto 2 vid 0x28E9 pid 0x0289
[   70.730783] usbcore: registered new interface driver usblp
use nl80211
# ls -al /dev/usb/
total 0
drwxr-xr-x  2 root root     80 May 31 14:31 .
drwxr-xr-x 20 root root   3840 May 31 14:31 ..
crw-------  1 root root 180, 0 May 31 14:30 hiddev0
crw-rw----  1 root lp   180, 1 May 31 14:31 lp1
# ls -al /dev/usb/lp1
crw-rw---- 1 root lp 180, 1 May 31 14:31 /dev/usb/lp1

we found the device known as usb lp1 i.e. /dev/usb/lp1. test to print something.


# printf '\x1b\x40Hello World\n\n\n' > /dev/usb/lp1

your printer should print "Hello World"

add your account or linux user as lp group 


# usermod -aG lp [username]

you need to sign out and re sign in, then try to print as [username]


$ printf '\x1b\x40Hello World\n\n\n' > /dev/usb/lp1

if everything work, now you can work as [username]. this is simple netbeans 30 - maven, to test your printer.

This is pom.xml for your project.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.dedetok</groupId>
    <artifactId>EnumComPort</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>21</maven.compiler.release>
        <exec.mainClass>com.dedetok.enumcomport.EnumComPort</exec.mainClass>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.fazecast</groupId>
            <artifactId>jSerialComm</artifactId>
            <version>2.11.0</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.5.0</version>

                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>

                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>

                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.dedetok.enumcomport.EnumComPort</mainClass>
                                </transformer>
                            </transformers>

                        </configuration>
                    </execution>
                </executions>

            </plugin>

        </plugins>
    </build>
</project>

This is the java code


package com.dedetok.enumcomport;

import com.fazecast.jSerialComm.SerialPort;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 *
 * @author dedetok
 */
public class EnumComPort {

    public static void main(String[] args) throws IOException {
        System.out.println("Hello World!");
        System.out.println(System.getProperty("user.name"));
        Process p = Runtime.getRuntime().exec("id");
        p.getInputStream().transferTo(System.out);
        
        SerialPort[] ports = SerialPort.getCommPorts();

        if (ports.length == 0) {
            System.out.println("No serial ports detected.");
        }

        System.out.println("Available Serial Ports:");
        System.out.println("------------------------");

        for (SerialPort port : ports) {

            System.out.println("System Port Name : " + port.getSystemPortName());
            System.out.println("Descriptive Name: " + port.getDescriptivePortName());
            System.out.println("Port Description: " + port.getPortDescription());
            System.out.println("System Location : " + port.getSystemPortPath());
            System.out.println("------------------------");
        }
        
        String devicePath = "/dev/usb/lp1";
        // Open file in read-write mode for raw bidirectional access
        RandomAccessFile deviceFile = new RandomAccessFile(devicePath, "rw");
        FileDescriptor fd = deviceFile.getFD();
        
        try (OutputStream out = new FileOutputStream(fd)) {
            // ESC @ (initialize)
            out.write(new byte[]{0x1B, 0x40});

            out.write("Hello World\n".getBytes());

            // Feed
            out.write("\n\n".getBytes());

            // Cut
            out.write(new byte[]{0x1D, 0x56, 0x00});

            out.flush();
            out.close(); // NO NEED
        } catch (FileNotFoundException ex) {
            System.getLogger(EnumComPort.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex);
        }
        System.out.println("End");
    }
}

In my test, you can run inside your netbeans, Run -> Build Project or Run -> Clean and Run Project. to run the jar, you go to project root and run like this


$ java -jar ./target/EnumComPort-1.0.jar 
Hello World!
[username]
uid=1000([username]) gid=1000([username]) groups=1000([username]),7(lp),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),33(www-data),44(video),46(plugdev),100(users),106(netdev),111(bluetooth),113(lpadmin),116(scanner),124(libvirt)
No serial ports detected.
Available Serial Ports:
------------------------
End

your printer should print "Hello World". "No serial ports" means, you can use com.fazecast.jSerialComm library for lp printer.

Credit: https://www.freeformatter.com/html-escape.html for free html escape 

Saturday, May 30, 2026

Java: enumerate com serial using fazecast jSerialComm

Simple code to enumerate serial com port


/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 */

package com.dedetok.enumcomport;

import com.fazecast.jSerialComm.SerialPort;

/**
 *
 * @author dedetok
 */
public class EnumComPort {

    public static void main(String[] args) {
        System.out.println("Hello World!");

        SerialPort[] ports = SerialPort.getCommPorts();

        if (ports.length == 0) {
            System.out.println("No serial ports detected.");
            return;
        }

        System.out.println("Available Serial Ports:");
        System.out.println("------------------------");

        for (SerialPort port : ports) {

            System.out.println("System Port Name : " + port.getSystemPortName());
            System.out.println("Descriptive Name: " + port.getDescriptivePortName());
            System.out.println("Port Description: " + port.getPortDescription());
            System.out.println("System Location : " + port.getSystemPortPath());
            System.out.println("------------------------");
        }
        
    }
}

Note: lpx device (e.g /dev/usb/lp1) does not use serial com, you need to send hex code direct via OutputStream.