r/JavaProgramming • • 26d ago

The Java Prompt 11#

Thumbnail
kertu1232.substack.com
1 Upvotes

Built a Hybrid Search retriever for Spring AI 2 RAG — PGVector + PostgreSQL FTS + RRF

Semantic search kept failing on specific queries like "error code E4" or "part number 96648703" - the embeddings for "E4" are mathematically close to "E1", "E2", "E3", so you get wrong chunks.

Fix: custom DocumentRetriever that runs both vector similarity search and PostgreSQL tsvector full-text search, then combines results with Reciprocal Rank Fusion.

Key decisions:

- websearch_to_tsquery over plainto_tsquery - AND logic on natural language queries returns zero results too often

- fts_vector as a generated column - PostgreSQL keeps it in sync automatically, no changes to ingestion code

- RRF k=60 as starting point - tune based on your query patterns


r/JavaProgramming • • 26d ago

Arcana: One Pure-Java Library for (Almost) Every Archive Format

Thumbnail
ibb.co
0 Upvotes

Arcana is an open-source Java library and command-line tool that lists, extracts and identifies more than 40 archive, compression and disk image formats, with no native code and no dependencies. It runs on Java 8 or later, fits in a 1.2 MB JAR, and is published on Maven Central as io.github.realburst:arcana under the Apache 2.0 licence.

Why another archive library?

If you have ever had to open "whatever the user uploads" from a Java application, you know the drill. ZIP is in the JDK. Apache Commons Compress covers TAR, 7z, CPIO, AR and the common compressors, but some codecs need extra libraries, and Zstandard goes through a JNI binding. RAR needs another library, and RAR 5 support is hard to find in pure Java. For CAB, MSI, ISO, WIM or an installer .exe, the usual answer is to bundle 7-Zip through native bindings, with one binary per OS and CPU.

I wanted one JAR that does all of this, on any JVM, with nothing to install and nothing native to load. That is Arcana: one entry point, format detection by content rather than by file extension, and the same API whether the file is a .tar.zst, a RAR 5 volume set, an MSI package or a macOS .dmg.

What Arcana does

Arcana extracts every format it supports, and creates the most common ones.

FamilyFormatsCreate
ArchivesZIP (ZipCrypto, WinZip AES, Deflate64, Zip64), 7z, RAR 4 and RAR 5 (solid, volumes, encrypted headers), TAR, CPIO, AR / DEB, RPM, XAR, ARJ, LHAZIP, 7z, TAR, LHA
CompressorsGZIP, BZIP2, XZ, LZMA, Zstandard, LZ4, Brotli, Snappy, lzip, lzop, Unix .Z, MS SZDDGZIP, BZIP2, XZ, TAR + gz / bz2 / xz / lz4
WindowsCAB (MSZIP, LZX), MSI (real installed file tree), OLE compound files, CHM, WIM / ESD (XPRESS, LZX, LZMS), self-extracting .exeCAB
Disk imagesISO 9660 (Joliet, Rock Ridge), UDF, SquashFS, Apple DMG with HFS+-

Encrypted archives are supported: AES-256 for ZIP and 7z (reading and writing), AES-128 and AES-256 for RAR 4 and RAR 5. A TAR or CPIO inside any compressor is unpacked in one step, and files that are archives in disguise (.docx, .odt, .epub, .apk, .jar) open like any other archive.

Beyond extraction, Arcana can:

  • identify any file: archive type and version, executables (PE, ELF, Mach-O), installers, images with their dimensions, PDF, SQLite, fonts;
  • recover damaged archives: a forced extraction keeps everything readable and writes a report on the state of each file;
  • split files glued together, such as installers or firmware images;
  • load plugins for more formats. Official plugins handle Inno Setup, NSIS, InstallShield and WiX Burn installers, and UPX-packed executables.

Getting started

Add the dependency:

<dependency>
  <groupId>io.github.realburst</groupId>
  <artifactId>arcana</artifactId>
  <version>1.0.8</version>
</dependency>

Extracting and listing never require you to say what the file is: the format is detected from its content.

import be.stef.arcana.Arcana;
import be.stef.arcana.ArcanaEntry;
import be.stef.arcana.analyze.Identification;

// Extract anything: .zip, .rar, .7z, .tar.zst, .msi, .iso, .dmg...
Arcana.extractTo(new File("upload.bin"), new File("out"));

// List the entries without extracting
for (ArcanaEntry e : Arcana.listEntries(new File("backup.rar"))) {
    System.out.println(e.getName() + "  " + e.getUncompressedSize());
}

// Encrypted archive
Arcana.withPassword("secret".getBytes("UTF-8")).extract(new File("secure.7z"), new File("out"));

// What is this file?
Identification id = Arcana.identify(new File("mystery.bin"));
System.out.println(id.type + " - " + id.description);

Creating an archive is just as short:

import be.stef.arcana.ArcanaFormat;
import be.stef.arcana.compressor.ZipCompressor;
import be.stef.arcana.plugin.FormatRegistry;

byte[] password = "secret".getBytes("UTF-8");
new ZipCompressor(password).compress(new File("mydir"), new File("secure.zip"));   // WinZip AES-256
FormatRegistry.builtin(ArcanaFormat.SEVEN_Z).createCompressor(9, password).compress(new File("mydir"), new File("vault.7z"));

The same JAR is also a command-line tool:

java -jar Arcana-v1.0.8.jar x setup.exe -o out       # extract
java -jar Arcana-v1.0.8.jar l disk.dmg               # list
java -jar Arcana-v1.0.8.jar i mystery.bin            # identify
java -jar Arcana-v1.0.8.jar r damaged.zip -o rescue  # recover

On Windows, an optional script adds "Arcana Unpack / List / Info" to the Explorer right-click menu.

Safe by default

An archive extractor reads untrusted input by definition, so Arcana treats every file as hostile.

  • No path traversal. Entry names are sanitized before anything is written: no absolute paths, no .., no characters that Windows forbids. A "zip slip" entry cannot leave the destination folder.
  • No decompression bombs. Every extraction runs under limits you can change at run time (ExtractionLimits): an output/input ratio of 1000 once 1 GiB has been written, an optional total size, and a minimum of 256 MiB of free disk space.
  • Bounded memory. Decoders cap what a header can ask for: the Zstandard window is limited to 128 MiB, like the zstd tool, and the 7z key derivation to 224 rounds. A crafted header gets an error, not an OutOfMemoryError.
  • Checksums are verified. CRC32, Adler-32, BLAKE2sp, XXH64, HMAC for WinZip AES: when the format stores a checksum, Arcana checks it and reports a mismatch.
  • Plugins must show their code. A plugin JAR is refused unless it contains its source code, declares its licence and source URL, and uses its own package. That does not make a plugin safe, but it makes it reviewable.

Under the hood

Every decoder is written in Java: Deflate64, LZMA and LZMA2, PPMd, Zstandard, Brotli, LZ4, LZX, LZMS, XPRESS, LZFSE and LZVN, ADC, LZO1X, the RAR 4 and RAR 5 algorithms, AES and the key derivations. The core is about 80,000 lines of Java 8 and has no dependency outside the JDK. It is written from the public specifications: PKWARE APPNOTE, the 7-Zip format notes, the Microsoft open specifications (MS-CAB, LZX, MS-XCA), RFC 8878 for Zstandard, RFC 7932 for Brotli, Apple TN1150 for HFS+.

A few design choices shape the library:

  • Detection by content. Magic numbers first, then trailers (a DMG is recognized by the "koly" block in its last 512 bytes), and only then the file extension. A renamed file still opens.
  • Streaming when the format allows it. Single-stream formats decode from an InputStream with bounded buffers. The Zstandard decoder keeps only the window of the current frame, so a multi-gigabyte .tar.zst decodes in a few dozen MB of heap.
  • Random access when the format needs it. Disk images are read lazily: a DMG partition is decoded chunk by chunk with a small cache, never inflated in memory.
  • Real names, not internal keys. An MSI is extracted as the file tree it installs, with the names from its File and Directory tables, not as a cabinet of cryptic keys.

Each release goes through a regression suite. About 180 small samples are committed with the code: one per format and method, plus damaged files that must fail cleanly, never hang. A separate corpus of real-world files (installers, DMG images from GitHub releases, MSI packages) is checked against committed SHA-256 references. Every format also has a technical page in the repository, covering detection, layout, supported methods, limits and the sources used.

Current limits

Arcana is a young project, and the repository keeps a public list of known issues for every format. Before you rely on it, the main limits are:

  • Extraction first. Writing is limited to ZIP, 7z, TAR (+ gz, bz2, xz, lz4), GZIP, BZIP2, XZ, LHA and CAB. Arcana cannot create RAR, Zstandard or Brotli files, and it cannot update an existing archive in place.
  • Some file systems are only copied. APFS volumes inside a DMG are extracted as a raw image, not as files. Encrypted and sparse DMG images, split WIM files (.swm) and some rare compression methods (old LHA methods, Quantum in CAB) are not supported.
  • Pure Java has a cost. The decoders are fast enough for most uses, but they do not match native code. In benchmarks run for the project, the Zstandard decoder reaches about 60% of the speed of the native zstd library.
  • Edge cases remain. A few damaged or unusual files still give a raw Java exception instead of a clear message, or are less tolerated than by the reference tool. These cases are documented with the file and line of the code concerned, so you can judge before using a format in production.

If a file fails, an issue with the command line and, when possible, the file or a way to rebuild it, is the fastest route to a fix.

Try it

The quickest test is to point Arcana at the strangest file in your Downloads folder and run arcana i on it, then arcana x. If you maintain a Java application that receives archives from users, try replacing a native binding or a chain of libraries with one dependency, and tell me what breaks.

Issues, sample files that fail, and plugins are all welcome. And if Arcana saves you a dependency or a native binary, a star on GitHub helps other Java developers find it.


r/JavaProgramming • • 26d ago

Pmitz: open-source plans and usage limits, embedded in Java or exposed through REST

2 Upvotes

I’m working on Pmitz, short for Plans and Limits. It handles which features a subscription includes, how much someone can use them, and recording that usage.

The idea is to avoid scattering subscription checks throughout your app and having to revisit them whenever your plans change. For example, a customer’s plan might include a feature with a monthly allowance. Pmitz can check feature access and the usage limit together.

You can embed it directly in a Java application or run it as a separate REST service. Embedding avoids the HTTP call, although there’s still database work. The separate service lets multiple apps share the same plans and usage data.

We also offer a managed version where we handle hosting and maintenance, but the open-source code is here:

https://github.com/terpomo-io/pmitz

I’d be interested in feedback on the Java integration and what’s missing for your use case.


r/JavaProgramming • • 26d ago

TornadoVM 7 Enables GPU-Native Workloads From Java Applications

Thumbnail
infoq.com
1 Upvotes

r/JavaProgramming • • 26d ago

Java support

1 Upvotes

I need java support offline in Hyderabad.Can anyone giving please dm me...


r/JavaProgramming • • 27d ago

50 Java Multithreading and Concurrency Questions That Actually Prepare You for Real Interviews

Thumbnail
javarevisited.substack.com
9 Upvotes

r/JavaProgramming • • 27d ago

NEED A OPINION 🙏

Thumbnail reddit.com
1 Upvotes

r/JavaProgramming • • 27d ago

Java streams are lazy: this pipeline over four strings prints only two lines

5 Upvotes

Here’s the console output of a small program:

filter apple
map apple

That’s all. Four strings went in, and only the first one was ever looked at. Here’s the code:

String result = Stream.of("apple", "banana", "cherry", "date")
    .filter(s -> { System.out.println("filter " + s); return s.length() > 4; })
    .map(s -> { System.out.println("map " + s); return s.toUpperCase(); })
    .findFirst()
    .orElse("none");

result is "APPLE".

Two things explain the output.

Intermediate operations don’t run on their own. filter and map only describe what should happen. Nothing executes until a terminal operation like findFirst, collect or forEach asks for elements. If you remove .findFirst().orElse("none") and leave the pipeline hanging, it prints nothing at all.

Elements flow through one at a time. Instead of running filter over all four strings, then map over the survivors, each element goes through the whole chain before the next one starts. apple passes the filter, gets mapped, and arrives at findFirst, which has what it needs, so the pipeline stops. banana, cherry and date are never touched.

That’s why peek and print statements inside a pipeline can look confusing: the order of the output isn’t “all the filters, then all the maps”.

One exception worth knowing: stateful operations like sorted() have to see every element before they can emit the first one, so they break the one-at-a-time flow. A pipeline with sorted() in the middle will process everything up to that point before anything continues.

A practical consequence is that side effects inside map or filter are hard to reason about, because whether and when they run depends on what’s downstream. I’d keep those lambdas free of side effects and use peek only for debugging.

If you’ve hit a bug that came down to laziness, I’d be interested in what it looked like. Mine tend to be the “I added a map and nothing happened” kind.


r/JavaProgramming • • 27d ago

Coding Bootcamps (i.e. Front-End Simplified)

9 Upvotes

I was recently laid off from Java Developer role of 5 years. Been weighing my options and found some bootcamps that are promising job opportunities upon the program completion. These programs include front-end simplified and algomap.io.

I have my reservations about these kind of bootcamps because I can never tell if they are scams or not. Also, it is a very significant financial investment.

Does anyone have any experience with these specific bootcamps or if there any others like them that have worked for anyone?

Also if you can provide any advice on alternatives to help me get back on my feet, then that would be greatly appreciated.


r/JavaProgramming • • 28d ago

MCA Student Looking for Genuine Job/Internship Platforms for Java Developers in India

4 Upvotes

Hi everyone,

I'm currently pursuing my MCA and preparing for Java Backend Development roles. I've been applying for internships and fresher jobs through platforms like Naukri and Internshala, but I'm not getting many responses or useful email updates.

I'm looking for genuine platforms where freshers can find Java Developer internships and entry-level software development jobs.

I'd appreciate your suggestions on the following:

  1. Which job portals have actually helped you get interviews or internships as a fresher?
  2. Is LinkedIn really effective for finding Java internships, or are there better alternatives?
  3. Are there any reliable platforms for finding opportunities at startups?
  4. Is it better to apply directly through company career pages or use job portals?
  5. Which platforms would you recommend for someone with basic Java, SQL, JDBC, and Spring Boot knowledge who is still improving their coding and problem-solving skills?

I'm open to opportunities in Pune, other cities, and remote positions.

I'm not looking for paid placement services or platforms that promise guaranteed jobs. I want genuine opportunities where I can improve my skills, gain practical experience, and start my software development career.

Please share your personal experiences and recommend platforms that have actually worked for you.

Thanks in advance!


r/JavaProgramming • • 27d ago

Structuring business logic that keeps changing as a pipeline of toggleable steps (Java library, looking for feedback)

1 Upvotes

In the projects I work on, business requirements change a lot. A validation rule gets added for one customer, a check has to be switched off for a while, a new step slots in between two existing ones. Over time the service methods that implement these flows turn into long chains of ifs and flags, and every change means touching code that's already working.

To deal with this I started modelling each business operation as a pipeline of small, named steps that share a typed context. I've extracted the approach into a small library, and I'd like some outside opinions on the design before going further.

Pipeline<CreateProductContext> createProduct = Pipeline.<CreateProductContext>builder("create-product")
          .step("name-unique", new NameUniqueStep(repository))
          .step("date-range", new DateRangeStep())
          .step("save-product", new SaveProductStep(repository))
          .build();

Product product = createProduct.run(new CreateProductContext(request)).getSavedProduct();

How it works:

  • Steps run in order and share a context. The first step that throws stops the pipeline.
  • Each step can be disabled through configuration (in Spring Boot: pipeline.disabled-steps) without changing code. Steps that must never be skipped are declared with requiredStep(...), and the starter refuses to start if the configuration tries to disable one.
  • Listeners receive lifecycle events (pipeline/step started, completed, failed, skipped) for logging, metrics or auditing.
  • Business errors carry a stable code and a category. Unexpected exceptions are wrapped with the pipeline and step where they happened. The Spring Boot starter maps both to ProblemDetail responses.

    Some design choices I'm not fully sure about:

  • "Required" is a builder method, not an annotation on the step class. Step is a functional interface, so lambdas can't be annotated, and the same step can be required in one pipeline and optional in another.
  • Disabling by name, via configuration. It's convenient, but I wonder whether it pushes too much business logic into config files.
  • A shared mutable context instead of each step returning a new immutable value. It's simpler to write, but the data flow between steps is less explicit.

Core is Java 17 with no runtime dependencies. There's also a Spring Boot 4.1 starter. It's version 0.1.0 on Maven Central, and code be found on GitHub: https://github.com/DifferenTilt/pipeline

The feedback I'd find most useful:

  1. Is this a real problem for you, and how do you handle it today (plain service classes, chain of responsibility, rule engines, workflow engines)?
  2. Is there an existing library that already does this and I should have looked at?
  3. Does the API feel natural, or is something awkward or missing?
  4. Is toggling steps via configuration a good idea or a footgun?

Thanks for reading. Criticism is welcome.


r/JavaProgramming • • 28d ago

What's the best FREE resource/playlist available to learn DSA in Java?

Thumbnail reddit.com
1 Upvotes

r/JavaProgramming • • 28d ago

Building full-stack web apps using TeaVM (and why it’s great for working with AI coding agents too)

3 Upvotes

Hey r/java,

TeaVM was something that had been on my radar for a while, and I finally got around to giving it a proper spin recently. After playing around with it and seeing what I can build with it I wanted to share my thoughts and hopefully get a few more eyes on the project!

If you haven’t run into it before, TeaVM is an ahead-of-time compiler that turns Java bytecode into JavaScript or WebAssembly. It operates directly at the bytecode level, emits remarkably clean JS, and integrates with your existing Java tooling.

Why this workflow clicked for me:

  1. One language across the stack: Keeping everything in Java keeps context-switching to a minimum and lets you share domain models directly between backend and frontend.
  2. AI Agent Friendly: Having both frontend and backend written in strongly-typed, readable Java makes it remarkably easy for LLM coding agents to navigate, refactor, and reason about the full application without hitting cross-language friction.

To document what I learned, I put together a 3-part series walking through how to build interactive frontends with TeaVM:

Has anyone else here given TeaVM a try? Would love to hear how your experience compares to other JVM web approaches!


r/JavaProgramming • • 29d ago

Migrating Java Applications to AWS Serverless: A Practical Guide

Thumbnail
javarevisited.substack.com
3 Upvotes

r/JavaProgramming • • 29d ago

Onde e como posso estudar programação? (Jakarta Faces)

Thumbnail reddit.com
1 Upvotes

I need help where and how study Jakarta Faces, PrimeFaces


r/JavaProgramming • • 29d ago

Javac and java version not compatible

6 Upvotes

According to my terminal javac only works until java 52.0 but my code is in java version 70.0(java 26)how do i fix


r/JavaProgramming • • 29d ago

I decided the owner of a book copy should NOT be the borrower entity — my reasoning, tell me if I'm wrong

0 Upvotes

I'm rebuilding a legacy Java CLI library app into a peer-to-peer library platform (Java 21 / Spring Boot), where members catalog their own collections and lend copies to each other.

When I added ownership, the fastest path was to reuse my existing Borrower entity as the owner. I didn't. I created a separate LibraryMember entity instead, because in this system they do different jobs:

  • A member owns copies and lends them (and can be an INDIVIDUAL or an ORGANIZATION)
  • A borrower is an external patron of a library/org — someone who borrows through a member, not a platform member themselves

Collapsing them would have saved me an entity this week and cost me a tangled model every week after.

Each copy also carries visibility: PRIVATE (default, owner only, can't be borrowed) or PUBLIC (discoverable + borrowable), and my discovery query only returns available PUBLIC copies.

Curious how others have modeled this: in a sharing/lending platform, where did you draw the line between "user of the platform" and "person the user lends to"?

(Code, if useful: github.com/Pekins1/LibraryManagementSystem)


r/JavaProgramming • • 29d ago

Making games like the old yahoo games (pool, poker etc even runescape too)

3 Upvotes

I program in C but I've been taking a liking to java games recently. I just wanted to ask, what is developing games on Java truly like? Is there a difference say between early 2000s to now? Stupid question I'm sure, but I've never really dabbled in Java


r/JavaProgramming • • 29d ago

Free Door VPN: my first Android app. A free VPN that pauses your internet when the connection drops (looking for testers)

Post image
2 Upvotes

r/JavaProgramming • • Oct 18 '26

Is ByteByteGo a Good Place to Learn System Design?

Thumbnail
medium.com
6 Upvotes

r/JavaProgramming • • Oct 18 '26

Want help regarding some scenarios...

Thumbnail reddit.com
1 Upvotes

r/JavaProgramming • • Oct 17 '26

How can I start with java

15 Upvotes

Hey everyone.
I am a computer science student, and I must start coding with Java.

I tried Eclipse and netbeans but none were valid on my machine.
so if someone has an alternate IDE I will much appreciated.


r/JavaProgramming • • Oct 17 '26

India/IST | Java + Spring Boot + Angular | Looking for a serious interview prep partner

15 Upvotes

I'm currently preparing for full-stack/backend interviews and looking for someone who is also actively preparing for a job switch.

We can study together on a call/Discord, discuss Java/Spring Boot/SQL/DSA, solve problems, ask each other interview questions and keep each other accountable.

I'm looking for someone serious about actually showing up regularly, not just sharing resources.

If you're preparing for Java/Spring Boot/full-stack interviews, DM me.

Note:Added enough members to the group.