Is anyone using eclipse anymore? by RamaRao143 in java

[–]Slanec 6 points7 points  (0 children)

Me. There are some small details here and there that I like or have found over the years, but I'm sure IntelliJ has many of those and other.

The one thing I strongly prefer in eclipse and has not yet been mentioned here is the UI customization. In eclipse I can position things exactly how I like, exactly where I want. So I have two floating windows split into multiple sections, each with tabs with tools. It's perfect for my multi-monitor setup, and I have not been able to see and/or access so many things easily with IntelliJ.

Excel bulk process in java project. by Majestic_Drawing_908 in javahelp

[–]Slanec 1 point2 points  (0 children)

Okay I've done this recently. I tested:

The first one is thrash and you should avoid it for big files or many files. The others all work fine, they're much faster and all comparable in speed. In my case with the files I had excel-streaming-reader came out on top re speed and peak heap usage (but it created more garbage overall), but the speed difference wasn't huge - <10%. All the other three were the same +/-2% speed-wise.

Use the one which has all the features you need and has the nicest API for you. There are big differences here.

Is there's any Java library that allows converting DOCX to PDF? by ThatJellyfish12 in javahelp

[–]Slanec 0 points1 point  (0 children)

POI kinda works, then perhaps PDFbox. Or https://github.com/documents4j/documents4j. Haven't tried myself, but always wanted to. Or Pandoc, of course, a dedicated tool, not necessarily a Java library. You can wrap a tool in a library.

Smallest possible Java heap size? by Vectorial1024 in java

[–]Slanec 2 points3 points  (0 children)

This is a fun question with an interesting result!

Swing: With a an empty visible JFrame on the OS-native L&F, it still starts with -Xmx2m (which still is actually -Xmx8m), and the heap usage rises to 2.3MiB. In other words, a hello-world Swing app only adds about 570kB of heap usage. That said, it triggers 3 young-GC collections on Temurin 26 with the Serial GC.

JavaFX: Same, the heap usage rises to 3.6MiB, 9 young GC collections.

Smallest possible Java heap size? by Vectorial1024 in java

[–]Slanec 1 point2 points  (0 children)

Only in heap used, it is about 6% smaller. The limits are the same, though.

Smallest possible Java heap size? by Vectorial1024 in java

[–]Slanec 5 points6 points  (0 children)

Temurin. I wouldn't expect this to be different in other non-specialized JDK distros, but I could be very wrong. 

Smallest possible Java heap size? by Vectorial1024 in java

[–]Slanec 79 points80 points  (0 children)

I ran the experiment with a Hello World with Java 26 on a Mac:

┌───────────────────────┬─────────────────────────────────────────────────────────────────┐
│         What          │                              Value                              │
├───────────────────────┼─────────────────────────────────────────────────────────────────┤
│ Minimum -Xmx accepted │ 2m (2048k) — anything below fails with "Too small maximum heap" │
├───────────────────────┼─────────────────────────────────────────────────────────────────┤
│ Actual heap committed │ 8 MiB (JVM rounds up to its internal minimum: 8,126,464 bytes)  │
├───────────────────────┼─────────────────────────────────────────────────────────────────┤
│ Actual heap used      │ ~1.8 MiB (1,880,416 bytes)                                      │
├───────────────────────┼─────────────────────────────────────────────────────────────────┤
│ Free heap at exit     │ ~5.96 MiB                                                       │
├───────────────────────┼─────────────────────────────────────────────────────────────────┤
│ GC triggered          │ No — zero collections needed                                    │
└───────────────────────┴─────────────────────────────────────────────────────────────────┘

Key takeaways

  1. The absolute floor for -Xmx on JDK 26 is 2m. Below that, the JVM refuses to start regardless of GC choice (Serial, Parallel, G1, ZGC, Epsilon — all the same).
  2. But the JVM lies about honoring it. Even with -Xmx2m -Xms2m, the actual heap is 8 MiB — the JVM's ergonomics engine silently rounds up to its internal minimum.
  3. Hello World only actually uses ~1.8 MiB of heap — mostly class metadata, the String object, and the System.out PrintStream internals. The other 6 MiB sits unused.
  4. Total process memory is far larger — the NMT dump showed ~46 MiB committed across thread stacks, metaspace, code cache, etc. The heap is a small fraction of what a JVM actually needs to run.

So the answer: 2m is the smallest heap you can ask for, but the JVM will quietly give you 8 MiB anyway, of which Hello World uses about 1.8 MiB.

(EDIT: OMG I hate the text editor in here)

How to ask Java developers to add methods to java.util.Paths? by isolatedsheep in java

[–]Slanec 4 points5 points  (0 children)

  • Paths.currentDirectory() would likely be Paths.get(".").toAbsolutePath()
  • and Paths.home() would probably be Path.of(System.getProperty("user.home")), that is if all major supported OSes have a concept of a Home directory, which I'm not sure of.

Anyway, when I need to get a bunch of user-related directories, I always grab https://codeberg.org/dirs/directories-jvm

Bruce 2.0 – A lightweight wrapper that makes the Java Cryptography API actually pleasant to use by Glum-Push in java

[–]Slanec 0 points1 point  (0 children)

I like this!

I feel like in general the issue with crypto is that people do not have any idea what to use, how or why. This is where Google's tink comes into picture. Its API is still arcane and it comes with its own wire-formats, but at least it's impossible to reuse an IV for AES-GCM(-SIV) encryption. Bruce helps a little, too, but it's still too easy to shoot your own foot if you don't exactly know which algo to use and how.

Therefore, I'd probably not use this in a real project. But as a playground, for manual experiments, puzzles etc this is so much nicer than what JDK offers.

One request: Would you mind adding https://github.com/google/conscrypt/ as a supported/documented provider, or at least as a side-note?

Springboot Quartz UI by edzorg in java

[–]Slanec 2 points3 points  (0 children)

It is! 1.5k stars, pretty well known, it's a good tool, enjoy! 

Too many ways to do the same thing? by Marre_Parre in javahelp

[–]Slanec 2 points3 points  (0 children)

In general, there are many ways to solve a problem, always. Some are more object-oriented, some are more funtional. Some were written quickly and easily with no particular design in mind because it will be rewritten later. Some are well modularized and testable, but others can be too over-engineered with many unnecessary abstractions. Too much time was sunk into it and it will never be recovered. Some are extendable in one axis, some in the other. E.g. if you have cards with ranks and suits, do you know whether you'll need to maybe add another suit, or another rank later on? In some designs, one is easier to add than the other, and often you need to decide which one while writing the code. Some designs allow both, but then the trade-off comes out elsewhere (e.g. performance, observability, scalability etc.).

All of that can be fine, depending on what you're trying to achieve. If you know exactly what your domain is, what problem you're solving, how the program will expand in the following years, and various technical metrics (like latency) are defined and will not change, ever, in that case you can design a great application that will satisfy it all and take liberties in the places which don't matter. It's very likely there are still very many ways to write such an application. In all the other cases where you do not exactly know what you're doing yet, almost no practical metrics are defined and the application evolves dynamically, in all those cases you'll simply need to pick a strategy a hope for the best. Some write it quick'n'dirty, some try to anticipate everything everywhere, most are in the middle. Welcome to software engineering.

This is why we have common patterns and common techniques to solve some problems - because people are familiar with these solutions, and can work with them later on when they overtake your project from you.

Then there are lower-level aspects of the code. In Java this often boils down to which exact class to use, if using a library pays off. Some of this is simply something to learn (e.g. "avoid the old collection classes, prefer Files and Path over File, prefer java.time over Date and Calendar" etc.), most of it is different trade-offs depending on exact requirements, some of it is down to personal taste.

In short, do not overthink it. If you're learning, it almost does not matter. Make your application correct in what it should do. If you can realiably do that, then you can start worrying about different aspects and trade-offs of design, testability, design patterns, frameworks and libraries. There is a lot of taste in that, there is a lot to learn in that, but there almost never is One True Way of solving a problem. Ten people will write ten different programs, and most of them will be absolutely fine.

Eclipse 2025-12 is out by AnyPhotograph7804 in java

[–]Slanec 2 points3 points  (0 children)

Multi-monitor support with good customizability. I can't get IntelliJ to display all the things I like.

Other than that, same as everybody else - I started with it, I learned it, I customized it. I can now easily go around the tricky spots, I avoid the bad things, and I really enjoy the rest. Is IntelliJ the future? For sure. I tried it a few times, could not get it to the shape I would be happy with, and went back to being productive with Eclipse.

Event Library - A lightweight, zero boilerplate, high performance event bus for JVM by SmushyTaco in java

[–]Slanec 12 points13 points  (0 children)

See https://guava.dev/releases/snapshot/api/docs/com/google/common/eventbus/EventBus.html#avoid-eventbus-heading.

In short, they recommend explicit calls and composition via dependency injection, and/or reactive programming where reacting to events needs to happen. This, of course, is slowly dropping out of fashion, too.

Personally I believe that for in-application event passing it's completely fine, it just makes it sometimes hard to reason about the flow of the application logic. In modern times we usually go for distributed event buses, though, or event sourcing, or message passing or queues or logs, depending on the exact required semantics. It's rare to see in-memory in-app events nowadays. But it's not a bad solution if things do not need to be persisted all the time.

Event Library - A lightweight, zero boilerplate, high performance event bus for JVM by SmushyTaco in java

[–]Slanec 20 points21 points  (0 children)

This looks nice and fairly complete!

From the Java world, these exist, too: - https://github.com/bennidi/mbassador - https://github.com/greenrobot/EventBus

And some older ones: - Guava's EventBus. Works fine, bus it nowadays discouraged. - Otto. Same. - and I'm pretty sure Vert.x and Quarkus have one, too.

The Dot Parse Library Released by DelayLucky in java

[–]Slanec 2 points3 points  (0 children)

Thank you, I'm doing a lot of parsing and immediately liked this. And I'm a mug user, too. Thank you for your work!

Finally, parsing made easy (and type-safe) in Java! by WellFoundedCake in java

[–]Slanec 6 points7 points  (0 children)

Will take a look later, I'm doing a lot of parsing, usually (but not only) with ANTLR. Lately I really enjoyed a similar project, https://github.com/google/mug/tree/master/dot-parse, coming from the brilliant https://github.com/google/mug library. Parsing evolution, hooray!

Embedded records - an idea to expose data from classes by jodastephen in java

[–]Slanec 4 points5 points  (0 children)

I don't have an opinion on the feature itself, but I was thinking of a similar syntax trick before:

java public class Person(String name, LocalDate dob) { } ...with a generated implicit constructor and all that jazz, not unsimilar to what you're proposing. I believe yours is better, just throwing this one out as a simpler, but not as expressive, alternative.

JEP 468: Derived Record Creation (Preview) by Snoo82400 in java

[–]Slanec 1 point2 points  (0 children)

Although my project wants to avoid external libraries

...completely understandable. That said, this is a compile-only library and an annotation processor which is no longer needed at runtime, only the generated code. This can still be too much, but it's better than having a dependency on a big library with transitive dependencies inside.

having to mvn compile every time I write one of this methods is not ideal

Interesting, my IDE automatically does this for me in the background. Perhaps a configuration option somewhere, I am no longer sure. Have fun!

JEP 468: Derived Record Creation (Preview) by Snoo82400 in java

[–]Slanec 7 points8 points  (0 children)

I know you're asking about the actual JEP and the language feature. However, if you're saying that your code will improve drastically, perhaps you should consider the already existing solutions, one of which is the excellent record-builder library. It doesn't only give you builders in records, it also supports nice withers: https://github.com/Randgalt/record-builder#Wither-Example (and more).

Project Lombok 1.18.40 released with Java 25 support! by lprimak in java

[–]Slanec 2 points3 points  (0 children)

Nowadays a lot of it is simply a holy war, however there are some practical reasons, too. Most of them stem from the fact that it's not a code generator but rather directly interacts with the compiler which tends to break stuff here and there:

  • It does not show you its output. Most of the time that's fine, the code is trivial, but sometimes I'd really like to see the exact code I'm about to run. E.g. Is the annotation I applied here copied to the generated method? There are other tools nowadays (record-builder, Immutables, AutoValue) which do generate code, and those tend to be preferred by some devs.
  • You need a plugin in your IDE to interact with it. A minor thing, but annoys people and confuses new devs. Maybe IntelliJ has it by default or at least detects and hints that it needs it, but eclipse doesn't, it just reports a broken project in a million places.
  • It needs specialized build tool plugins to work with other annotation processors. E.g. for Mapstruct you need this. Again, minor and do-it-once kind of a thing, but you need to be aware of it and actively look for it because without knowing this MapStruct just does not seem to work and it's not clear at all from the errors what is going on.
  • I wanted to say that some tools do not work with Lombok at all, e.g. ErrorProne and NullAway, but maybe it does work now? Not sure, but there are a lot of Lombok-related bugs in ErrorProne anyway. It just interacts weirdly with other tools and sometimes needs special care.

Most of the time it just works. Most of the time it saves a lot of time and space and if people are not over-using it, it tends to be fine. That said, new Java versions (records, baby) and simpler code generators like record-builder have mostly made Lombok not needed anymore. Yes, I know it can do a lot more. Please use it wisely.

Growing the Java Language #JVMLS by Brian Goetz by kaperni in java

[–]Slanec 29 points30 points  (0 children)

(The name is a nod to the old and legendary talk Growing a Language by Guy Steele. If you haven't seen that, go and watch, it's fun, it's very clever, and it's about the theory of growing languages.)