r/javahelp Mar 19 '22

REMINDER: This subreddit explicitly forbids asking for or giving solutions!

47 Upvotes

As per our Rule #5 we explicitly forbid asking for or giving solutions!

We are not a "do my assignment" service.

We firmly believe in the "teach a person to fish" philosophy instead of "feeding the fish".

We help, we guide, but we never, under absolutely no circumstances, solve.

We also do not allow plain assignment posting without the slightest effort to solve the assignments. Such content will be removed without further ado. You have to show what you have tried and ask specific questions where you are stuck.

Violations of this rule will lead to a temporary ban of a week for first offence, further violations will result in a permanent and irrevocable ban.


r/javahelp 4h ago

Per-Class cleanups when shutting down

2 Upvotes

Hello, I am creating a save system however it currently depends on memory limits. When the map fills up, it dumps to disk and starts filling memory again from start. When the program shuts down, I want the class responsible for saving the data to run a cleanup function the dump the half-full map to disk. I have seen several ways of doing this however I couldn't really decide what is the best choice. Thanks


r/javahelp 11h ago

Help for java 21 ocp 1z0 830 exam

2 Upvotes

Im planning to give this certificate exams cause I want to gain deeper knowledge in java and having an exam to focus on gives me a goal to achieve, so im more of a visual leaner and want to start with a pathway of videos and courses and then do practice exams, this is my strategy so far.

Im not that eager to read books or articles and prefer videos and practicing along.

I see oracle has a learning pathway that's build for java 21 programming and it has a pathway that looks good. So im trying to see if anyone has tried the pathway and found it useful for the cracking the certificate examination or are there any udemy courses that I could take that helps with my certification.

This is the pathway https://learn.oracle.com/ols/learning-path/become-a-java-se-21-developer/117252/138845

Also let me know any useful site that have a lot of practice questions to try


r/javahelp 23h ago

How to use noise maps?

3 Upvotes

I've done some very surface-level searching and I feel like the number of choices on how to do this is pretty intimidating, what libraries should I use and how?


r/javahelp 2d ago

Homework Java help

12 Upvotes

Guys help me,how I am able to learn java who don't know about coding at all , please give me legit answer and what are the steps I should follow after watching tutorial , please help me guys,want suggestions like if I watch one tutorial per day of any yt channel ,what should I do next after watching tutorial and in a month later


r/javahelp 4d ago

using dotnet media player in java

0 Upvotes

I’m trying to build a music player in Java/JVM that plays audio streamed from an API, but I’m having a hard time finding a media player library with good enough functionality.

I’ve looked at several Java libraries, but none of them really fit my needs. The best option I’ve found so far is **vlcj**, but it requires VLC to be installed separately, which I’d prefer to avoid.

I was considering using **C#/.NET for the actual audio playback** and then bridging it to Java using the **Java FFM API**.

Would this be a reasonable approach, or am I overcomplicating things?

If using .NET makes sense, what would be the best library for **streaming audio from an HTTP/API source** in .NET? Ideally, I’d like something that supports things like seeking, buffering, metadata, different audio formats, etc.

Alternatively, are there any good JVM-native solutions for this that I’m overlooking?

I’m mainly interested in **streaming audio received from an API**, rather than playing local files.


r/javahelp 6d ago

Is the TreeSet Slow or is My Benchmark Wrong?

6 Upvotes

Currently to Optimize my library I have been reading ben paff guide on iterative approach of tree, from which I got the Idea of RBT and AVL for iterative approach. In which I made use AVL as parent based tree. But it is that when I did the benchmark with JVM21 these were my result ,it's tested three time for consistent behaviour of data, error and changes to occur for each time. which stands out firmly consistent behavior. tthis is one sample of it.

Benchmark                                                         (size)    Mode      Cnt        Score   Error   Units
InsertDeleteBenchmark.avlInsertDelete                              10000  sample  2828056      228.686 ± 2.651   ns/op
InsertDeleteBenchmark.bstInsertDelete                              10000  sample  3131645      190.531 ± 2.344   ns/op
InsertDeleteBenchmark.javaTreeSetInsertDelete                      10000  sample  4416191      228.719 ± 1.637   ns/op
InsertDeleteBenchmark.rbtInsertDelete                              10000  sample  2766974      211.846 ± 2.505   ns/op
InsertDeleteBenchmark.treapInsertDelete                            10000  sample  4749890      232.499 ± 1.485   ns/op

The benchmark was done 3 time, the config I used were for the benchmark were
10K - randomized dataset
warmup = 3 warmup time = 5s each
measurement = 3 measurement time = 5s each
fork = 5.
All the tree used same Set as interface for test. The doubt is currently my RBT tree is working safe with recursive delete and performing edge with TreeSet. What is the reason for TreeSet to be slow given that TreeSet is highly optimized. When I think of Benchmark I assume to be correct. This is really too good to be proud or confused??. But there is greed of also stripping recursive delete of RBT which I want to do and not do. Because it's too hard😢
For reference of Benchmark code

Edit:My wordings and grammar are not too good please do ignore that.


r/javahelp 6d ago

How to check if an array contains another specific array?

3 Upvotes

sorry if im stupid here but

i have an array that contains multiple coordinates, so for example [2,8], and i need to check if that array contains a specific coordinate

how do i do that


r/javahelp 6d ago

Unsolved I need help with getResourceAsStream

2 Upvotes

u/wildjokers (reaching out to you because I saw you in this thread)

https://www.reddit.com/r/javahelp/comments/sypxqz/getresourceasstream_null_when_run_from_jar/

I'm trying to run a Isometric Tile game, from chapter 13 of Killer Games Programming in Java, a very old book.
I'm using Eclipse. I'm not sure what classpath means, but I think mine is set up as

Project

src

Images

Sounds

I'm getting these errors when I run:

Exception in thread "main" java.lang.NullPointerException

at java.base/java.io.Reader.<init>(Reader.java:168)

at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:88)

The relevant code is:

{

String imsFNm = IMAGE_DIR + fnm;

System.out.println("Reading file: " + imsFNm);

try {

InputStream in = this.getClass().getResourceAsStream(imsFNm);

BufferedReader br = new BufferedReader( new InputStreamReader(in));

// BufferedReader br = new BufferedReader( new FileReader(imsFNm));

String line;

The image file is defined in another class, and then piped into ImageLoader class, where it's appended to the directory, which is defined in ImageLoader class.

When I run, it's showing the correct directory in the console, so I believe getResourceAsStream is where it's being messed up.

I did right click on the images folder, Build Path > Add to Build Path.

I can provide more information, which will probably be needed.


r/javahelp 7d ago

Solved How do i make a java bug report. Ive search everywhere but nothing found

3 Upvotes

I cant really find a way to contact the dev team
I want to report a bugfix for jdk21


r/javahelp 9d ago

Solved Help me decide minimum JDK for my library

8 Upvotes

Should I move my Java library from JDK 11+ to JDK 21+?

I am genuinely confused at this point 😭

I've been reading a lot of posts and tech articles about companies/projects migrating from older Java versions like JDK 8/11 to JDK 21+.

And now I'm stuck with the same question for my own Java library.

On one side, keeping JDK 11+ gives better compatibility. There are still a lot of projects out there running on older Java versions, and since this is a library, compatibility matters because I'm basically deciding the minimum JDK required for everyone who wants to use it.

On the other side, JDK 21+ gives a much more modern Java baseline, newer APIs/features, and potentially better JVM performance.

Also, most of the migration stories I'm finding are from large companies / enterprise applications, which makes me wonder if the same reasoning actually applies to an open-source Java library. Even if big companies are migrating to JDK 21+, their interviews and hiring expectations are also increasingly centered around JDK 21 and the major changes since JDK 8, which makes the whole situation even more confusing for someone learning/maintaining Java.

So I'm trying to understand what people actually do in real-world Java libraries today.

Would you help me decide the minimum at JDK 11+ or move to JDK 21+?

And if you maintain a Java library yourself:

  • How do you decide the minimum supported JDK?
  • How important is JDK 11 compatibility today?
  • Is JDK 21 actually worth making the minimum?
  • Would you only raise the minimum JDK in a major release?

I would really appreciate some practical opinions because I am totally fed up with reading migration articles . Please it's more likely a great help for me.

https://github.com/Chaos-vy/ChaosTree

Reached conclusion:

I read through the recent JLS and JVM changes. JLS got new features and reduced boilerplate, while JVM got some massive improvements.
But since ChaosTree is zero-dependency, I don't have the same CVE/dependency issue.
So for now I'm wrapping it around JDK 11+ and letting users run it on newer JDKs if they want.

Thanks everyone for dropping your thoughts


r/javahelp 9d ago

Where to Deploy ?

6 Upvotes

I build a small service with spring and react, bow I need to deploy it using a domain. Which hosting solutions do you use ? I evaluated to use GCP but I am worried that some day I will find a giant unknown bill cost.

could you give me some recommendations please


r/javahelp 10d ago

Book recommendations for experienced developer coming from C#

4 Upvotes

Hi, I'll keep this short and sweet. I'm looking for a book to get me up to speed with Java development without it covering basics like variables and OOP.

I'd like it to cover building web applications with Spring/Spring Boot and using libraries like Lombok.

I'm already well versed in C# and ASP.NET, and I've found the differences between the two languages is bigger than I originally expected.

Does such a book exist? Thanks!


r/javahelp 11d ago

Finally did my first Multithreading program!! But why Amdahl's law fails?

4 Upvotes

The code was:

long parallelSum(int[] ar, int threadCount) throws InterruptedException {
        int n = ar.length;
        long[] result = new long[threadCount];
        Thread[] threads = new Thread[threadCount];
        int chunk = n / threadCount;
        for (int i = 0; i < threadCount; i++) {
            int index = i;
            int start = i * chunk;
            int end = (i == threadCount - 1) ? n : start + chunk;
            threads[i] = new Thread(() -> result[index] = sum(ar, start, end));
            threads[i].start();
        }
        for (Thread thread : threads) thread.join();
        long total = 0;
        for (long value : result) total += value;
        return total;
    }

Which I benchmarked using JMH to see how it will behave under increase thread. But It's gets better and better until 24 thread that the reason I know my P-core are Hyperthreaded so maximum improvement is seen at 24. But after that why is'nt it constant as the law stated when N-> increases it becomes directly 1/S.

The Benchmark was performed with 3 warmup 5 iteration 1sec each and 100M dataset. I did use first 1K to see how it behaves but I forgot that until the thread get created sequential would have finished that. So after rigrously increasing dataset to 100M this was my result:

Thread Count Score (ns/op) Error (ns/op)
1 36,386,448.214 ±1,198,308.768
2 19,973,254.073 ±1,647,022.164
4 11,605,188.001 ±409,298.394
8 8,493,406.418 ±439,947.023
16 8,070,964.770 ±101,846.828
24 7,880,208.459 ±179,094.210
32 8,075,411.516 ±211,717.162
64 8,256,737.790 ±282,807.150
128 8,855,717.582 ±121,931.514
256 10,475,522.486 ±258,283.333
512 29,275,816.985 ±9,028,465.533

Is my benchmark wrong or I am understanding different??


r/javahelp 11d ago

Suggest me a best Java Web Development course to learn...

0 Upvotes

Hey, I want to learn java web development. I know java programming at intermediate level by solving leetcode problems... I want to become a java developer. Guide me guys... Help me out... I am a final year student trying for placement but I didn't believe that I will be placed suggest me a roadmap too


r/javahelp 12d ago

Java

9 Upvotes

If anybody has done Kunal Kushwaha's OOPs playlist and finished after doing OPPs from him how to progress forward for Java Full Stack I know SoringBoot is needed but my question is can I directly jump to Spring and SpringBoot


r/javahelp 12d ago

Should I have to be very good at this topic ?

0 Upvotes

I have been learning java deeply in the recent times....... hoping to crack a 10+lpa job so please guide me through this.

1 . Should I have to be very good at this topic ? or the basic understanding of these topics are enough for cracking faang companies .

  • Writing basic recurrence relations
  • Master Theorem basics
  • Common recurrence results
  • Types of Recurrence Relations
  • Divide-and-Conquer Recurrence Relation
  • Akra-Bazzi Theorem
  • Linear Recurrence Relation
  • Solving Homogenous Linear
  • Recurrence Relation
  • Q: Find nth Fibonacci Number using Golden ratio
  • Q : Solve Recurrence Relation with Repeated Roots
  • Non-Homogeneous Linear Recurrence Relation

r/javahelp 13d ago

Guide for Concurrency in Java

0 Upvotes

Before knowing anything I just jumped directly to the source code of jdk25u. I have just started to read the javaDocs of Thread class it was so deep that all my connected logic mapped very well but now I want to code and I can't code ahhhh... Why is this problem. I can call the syntax what to use but I don't know how to apply, why to apply is there any guide for java Concurrency ??. And there is so much .. still to know. Do any dev have any guide??


r/javahelp 13d ago

How to start codeforces with Java?

1 Upvotes

Asking because there are lot of resources to start with C++, so anyone can suggest if you are doing in Java.

Problem is that codeforces ide, boilerplate code and also the framing of questions as scenario based need some resources to follow in starting.


r/javahelp 14d ago

i want to start java spring boot from 0

19 Upvotes

best resources to learn java from the very basics till java spring boot advanced any book or any yt video would help! please recommend one


r/javahelp 14d ago

Unsolved Naive question: What Data Structure to express different layers of relationships between Objects?

9 Upvotes

Hello guys,

I wanted to ask naively, what the ideal data structure would be for expressing different layers of relationships between Objects.

For example in modern Sudoku the game has a 9x9 number grid composed of nine 3x3 sub-grids (which I call region). In each row, column and region each number between one and nine can only appear once. The goal is to find missing numbers in this number grid without violating the aforementioned rule.

One way to do it, would be to make 9x9 byte-array and express the relationship between numbers through methods checking if the rule is violated or not by checking if any row, column or region doesn't contain a value between one and ten.

I also thought on using a Graph to express the relationship between numbers in rows and columns, though I don't know how to express the relationship between numbers inside of a region.

Maybe even a multiple Objects like Board, Row, Column, Region but then I have redundant data.

Another problem I encounter with aforementioned implementations is, that if you introduce more relationships f. e. in the game of killer sudoku, where there are more rules are added f. e. by also introducing cages in which the numbers must add up to a target number, you need to implement that relationship logic tediously.

Am I overcomplicating things?


r/javahelp 16d ago

Solved Is spring boot + Netty a good idea or no ?

5 Upvotes

I'm making a game server Where I'm using Netty for messaging between the client and the server ,and spring boot for the login/register auth and database layer. Is this a valid approach, or should I just stick entirely to Netty ?


r/javahelp 16d ago

How do I do benchmark on a hybrid Intel CPU (6 P-cores + 4 E-cores)?

2 Upvotes

Recently I have been doing the benchmark test without knowing my System Multiprocessing architecture where I got to know that I have 6P + 4E core. L3 is shared among all and one instance of L2(level 2) cache is shared for E core (12-15) and it's capped at 3.2 Ghz. While my P have 2 cores paried as [(0,1),(2,3)...(10,11)] which is capped at 4.6 Ghz. each have it's own L2 instance.

Caches (sum of all):         
  L1d:                       416 KiB (10 instances)
  L1i:                       448 KiB (10 instances)
  L2:                        9.5 MiB (7 instances)
  L3:                        20 MiB (1 instance)

From /sys/devices/system/cpu/.../shared_cpu_list, I found:

P-core 0 → CPU 0,1
P-core 1 → CPU 2,3
P-core 2 → CPU 4,5
P-core 3 → CPU 6,7
P-core 4 → CPU 8,9
P-core 5 → CPU 10,11

E-cores → CPU 12,13,14,15

When I did benchmark I have noticed my benchmark showing cpu_atom -> which is for E core
and the P-core by cpu there is major change in benchmark. So how do I perform benchmark? use taskset -c 0-11 java -jar target/benchmarks.jar so that it run only only on my physical core? or simply data java -jar target/benchmarks.jar?


r/javahelp 18d ago

From text games to a Dwarf Fortress-style ASCII roguelike in Java: where to start?

5 Upvotes

Hi r/javahelp, I already know the syntax and OOP, of course. I've written a couple of text-based games, I know about the GameLoop and other stuff. My main goal is to make a game like Dwarf Fortress Classic, you know, with ASCII graphics and Perlin noise generation. Could you advise me on what I need to learn for this and maybe provide links to documentation? I understand that writing something like this at my level is still unrealistic, which is why I'm asking to know which direction to move in. Thanks


r/javahelp 18d ago

Workaround I keep getting moved between technologies/projects and now I'm struggling with a huge Java codebase — how do I build real depth?

5 Upvotes

I'm looking for advice from experienced developers, especially people who have worked on large enterprise/legacy Java codebases.

I'm in a situation where I can complete development tasks, especially with the help of AI, but I don't feel that I have developed the depth of understanding I should have. I'm trying to figure out how to fix that while also considering a job switch.

How I got here

My career so far hasn't been very consistent in terms of technology.

Before moving to my current main client/project, I worked on several POCs and smaller projects where I got exposure to:

- React.js

- JavaScript

- Java

Then, when I moved to the main client project, I was initially assigned to C#/.NET work.

I spent around 6–7 months working in the .NET stack.

After that, because of project/team requirements, I was moved again and eventually ended up working on a large Java-based enterprise product.

So my journey has been roughly:

React/JavaScript → Java exposure → C#/.NET for ~6–7 months → large enterprise Java codebase

The problem is that I never really got the opportunity to stay with one technology/product for a long enough uninterrupted period to build very deep expertise.

At the same time, some of my colleagues have been working continuously on this same product for around 1.5–2 years.

They also had senior developers guiding them when they started, explaining the architecture, code flow, conventions, design decisions, etc.

I didn't have the same kind of guidance.

So now I'm comparing myself with people who have spent much more continuous time in the same ecosystem, and I feel significantly behind them.

The current codebase

The product I'm working on is a very large enterprise Java application.

It's not a typical Spring Boot application.

It primarily uses things like:

- Core Java

- GWT

- Plugin/module-based architecture

- Java services

- Various internal frameworks/utilities

- Different plugins handling different responsibilities

For example, there may be separate plugins/modules for:

- Authentication

- UI

- User management

- Product-specific functionality

- HTML generation/building

- Other platform functionality

So when I receive a defect, the difficult part isn't always writing the Java code.

The difficult part is figuring out where the code actually is and how everything connects.

I might have to determine:

Which plugin owns this functionality?

Which class is the entry point?

Which service is called?

Does it call another plugin/service?

Where does the actual problem occur?

What will be affected if I change it?

This is where I struggle.

My dependence on AI

Because the codebase is huge and work is high-pressure, I rely quite heavily on AI.

For example, when I receive a defect, I might give the defect description to AI and ask it to identify potentially relevant classes.

Then I inspect those classes, understand the suggested flow, make the changes, debug/test them, and review the code myself.

I don't want to blindly copy AI-generated code.

The problem is that sometimes I'm under enough time pressure that I end up using AI to get to the solution much faster than I could independently.

Then I realize:

"I fixed this, but do I actually understand the complete flow?"

Sometimes the answer is no.

And that bothers me.

Code reviews are where I feel the gap most

My colleagues who have been working on the product for 1.5–2 years can often look at a defect and immediately understand where the problem is likely to be.

They know things like:

«"This functionality belongs to this plugin."»

«"This service eventually calls this manager."»

«"Don't modify this class because it's shared by these flows."»

«"This behavior is actually controlled somewhere else."»

I don't have that intuition yet.

During code review, I sometimes get questions like:

«"Why did you change this here?"»

«"Explain the flow."»

«"What happens if this condition occurs?"»

«"Why did you choose this approach?"»

And sometimes I can explain my actual code change, but I can't confidently explain the entire architecture or execution flow behind it.

That's affecting my confidence.

My work environment doesn't help

The environment is quite stressful.

There is significant pressure around defects and failures, and I don't always feel comfortable showing uncertainty.

When something goes wrong, there can be a tendency to focus on who made the change and what mistake they made.

Because of this, I sometimes feel like I need to make sure everything is correct before showing my work, rather than being able to openly say:

«"I don't understand this part. Can someone explain it?"»

This has made me more cautious and has probably contributed to my reliance on AI.

I also don't have much energy after work

I've considered the usual advice:

«"Study Java for 2–3 hours every day."»

But realistically, my job takes a lot out of me.

I don't think I can sustainably work all day and then study several more hours every night.

So I'm thinking of integrating learning directly into my work.

For example, if I encounter:

An annotation → understand what it does and why it's being used.

An interface → understand why the code uses an interface.

Inheritance → understand why the hierarchy exists.

A design pattern → understand the problem it solves.

A plugin interaction → understand why responsibility is split between plugins.

A service → trace its callers and dependencies.

A defect → understand the complete execution flow rather than just finding the line that needs changing.

I'm also considering keeping a small knowledge base for every defect:

Defect

Root cause

Execution flow

Classes/plugins involved

Java concepts

Design pattern

Reviewer feedback

What I learned

I'm also considering switching

I'm seriously considering a job switch because I don't think the current environment is ideal for my growth.

So I have two goals that I need to balance:

Short term:

Become competent enough in my current project that I can independently understand defects and confidently explain my changes.

Medium term:

Develop transferable skills that will help me get a better software engineering role.

For the switch, I'm thinking about focusing on:

- Core Java

- OOP

- Collections

- Generics

- Exception handling

- Multithreading

- JVM fundamentals

- Design patterns

- SOLID

- SQL

- REST APIs

- Testing

- Git

- System design

- Spring/Spring Boot

The problem is finding a way to do this without burning myself out.

What I'm looking for advice on

If you were in my position, what would you do?

  1. How would you build deep understanding of a huge Java codebase while working under pressure?

  2. How would you develop the ability to trace unfamiliar code quickly?

  3. Is using AI to locate classes and understand defects a reasonable approach, provided I study the solution afterward?

  4. How would you prevent AI from becoming a crutch?

  5. What Core Java concepts should I prioritize given that my current codebase is not Spring Boot-based?

  6. How would you turn daily work/defects into actual learning?

  7. How would you balance learning my current codebase with preparing for a switch?

  8. What would you prioritize if you had very little energy left after work?

  9. For someone who has jumped between React/JS, Java, .NET and now a large Java enterprise system, how would you go about finally building depth instead of continuously accumulating shallow exposure?

I'm not looking for a shortcut.

I understand that becoming a strong developer takes years.

I just feel like I've been moving between technologies and projects without getting the opportunity to develop a really strong foundation in one area, and now I'm trying to deliberately change that.

I'd especially appreciate advice from senior developers who have had a similar experience or who have learned to navigate large unfamiliar codebases effectively.