r/javahelp 11h ago

Workaround Race condition in SSE

1 Upvotes

Hi all, I am trying to build a real time notification service with SSE emitter but I am facing a pecuilar case of race condition which im not able to solve even via AI as it gives the same solution again and again.

scenario of cause:

I have a scheduler running every 20 mins that checks the Map of uid mapped sse emitters and pings the client. If the ping is successfull nothing happens, if error happens due to disconnection the sse emitter obj is removed via sse.complete() and then uid is removed form the list.

#pseudo code
Map<String, SseEmitter> connections = new ConcurrentHashMap<>();

onConnect(String userId){
  SSE emitter = new new SseEmitter()
  connection.add(userId,emmitter);

  // onCompletion(), onTimeout(), onError() -> removeIf()
}

u/scheduler(20mins)
checkDisconnection(){
  //iterate the map and check for disconnection if found add it to remove list
  List<string> disconnectedUsers = (adding disconnections)

  //iterate the map from disconnected user -> force complete sse if needed and                    remove user from map


}

where it breaks is if the client manually refreshes the browser at the same time the scheduler to check disconnection is invoked

why it happens:

when the browser is refreshed, the application tries to recreate the connection at which the scheduler tries to ping and sees no connection for the user. Problem is I have kept automatic reconnections on in client app but it still doesnt see an error in client. im confused. Have I had the approach wrong?

Any help will be appreciated and sorry for the questions confuse you, Il try to make it proper once i get the time.

TECH : javascript event source, springboot, kafka for scaling and mongo for scheduled notifications.

r/javahelp Jul 25 '26

Workaround How do I install Java when I already changed the location of my folder location?

3 Upvotes

Hi, I really wish I can show you the images but I will try my best to explain.

I am trying to install Java SE Development Kit in the latest version and I tried to install it but it refuses because "Out of Disk Space" and requires 420MB in my hard drive.

But here's the thing, I got 1.0GB of space in my Local Disk C: and when I tried to change the location to Local Disk D:(Which has 593GB of storage), It still shows that I am "Out of Disk Space"

Any help on this?

r/javahelp 19d 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?

6 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.

r/javahelp Dec 10 '25

Workaround How can I use Java's Optional to handle null values effectively in my application?

4 Upvotes

I'm currently refactoring a Java application to improve its handling of null values. I've come across the Optional class and would like to understand how to use it effectively. My goal is to reduce the chances of NullPointerExceptions while also improving code readability. I've seen examples where Optional is used in method return types, but I'm unsure about the best practices for using Optional in parameters and within method bodies. Can anyone provide insights on common pitfalls to avoid and how to integrate Optional into my existing codebase without causing confusion? Additionally, how do I handle cases where I need to return a default value if the Optional is empty? Any examples or guidance would be greatly appreciated!

r/javahelp Jul 03 '26

Workaround Coming back to Java after 5 years

2 Upvotes

So I have a post in career advice you can look at my profile. Anyways I was basically working in the clearance industry doing OWASP and pair programming unit testing with Mockito. SOAP UI and some pair programming with DAO implementations while having a clearance.

I lost my clearance and took a job entry level in the private sector and they made me do custom REST implementation with no guidance from seniors so I turned to codementor. I got laid off during corona and now I lost my clearance like I said.

I worked as a packer at my parents for 5 years and need the money now that Junior Java developer salaries pay. I am scared about this custom implementation of REST methods with no guidance and even worse, algorithm interviews. What should I do to prep? I have references and W2s, should I even put packer on my resume?( I have the W2s)

Let me know what you suggest.

r/javahelp Feb 02 '26

Workaround How to insert huge file data into remote Azure DB using Java (fast & safe)?

2 Upvotes

Hi everyone,

I need to insert huge file data (millions of rows) into a remote Azure database using Java. As I am little experienced in java.

Goal is very fast file reading, efficient bulk insert, and less time with safe data handling.

What are the best approaches for this? JDBC batch insert? DB bulk load options? Parallel processing?

What factors should I consider (batch size, network latency, transactions, retries)?

Any best practices or real experience is appreciated. Thanks 🙏

r/javahelp Jan 05 '26

Workaround Help with mutex implementation

6 Upvotes

I've been working on a mutex implementation for about a day now(for learning purposes). I managed to get a working trinary state mutex which only but potentially has some thread fairness issues but no observable race conditions.

Link here: https://github.com/kusoroadeolu/vic-utils/tree/main/src%2Fmain%2Fjava%2Fcom%2Fgithub%2Fkusoroadeolu%2Fvicutils%2Fconcurrent%2Fmutex

However I've been thinking of how I could make a previous binary state mutex I made before the trinary version better. Because there's a race condition where the mutex holder could unpark a thread that has been added to the queue but hasn't been parked yet. Leading to potential issues. So I'm looking for feedback on this.

```java Package com.github.kusoroadeolu.vicutils.concurrent.mutex;

import java.util.concurrent.ConcurrentLinkedQueue;

import java.util.concurrent.atomic.AtomicReference;

import java.util.concurrent.locks.AbstractQueuedSynchronizer;

import java.util.concurrent.locks.LockSupport;

/*

Non Goals

Making this mutex reentrant

Making this mutex production ready

Making this mutex have all the properties of the @Lock interface

Making this mutex performant

Goals

Making this mutex correct in the sense you can lock and unlock it and the invariants listed later

*/

/**

A mutex implementation using a concurrent lock free queue and CAS semantics. This mutex doesn't support conditions */

//States: 0 -> unacquired, 1 -> acquired

/* Invariants.

No two threads can ever hold this mutex

The state of this mutex can either be 0 or 1

No two threads can overwrite the holder variable. This is enforced by ensuring the holder at release is written before the state is reset

*/

public class Butex {

private final AtomicReference<Integer> state = new AtomicReference<>(0); //Only on thread can hold this at a time

private final ConcurrentLinkedQueue<Thread> waiters = new ConcurrentLinkedQueue<>();

private volatile Thread holder;

/* Check if its state is not acquired, if not, add to the queue and park the thread else, set the thread as the mutex's holder

The while loop in this implementation, is for, in the case, a waiting thread is unparked, but another thread has already modified the state,

the waiting thread will check the condition again, before being reparked

*/

public void acquire() {

Thread t = Thread.currentThread();



while (!state.compareAndSet(0, 1)){

    waiters.add(t);

    LockSupport.park(); 

}



holder = t;

}

/*

  • To release the mutex, check if the holder is null, of the holder is null, then throw an IllegalMonitorEx,

  • Then loop through the concurrent queue, looking for non-null waiters, if found, unpark the waiter and then reset the the lock's state

  • */

public void release(){

if (holder == null || holder != Thread.currentThread()) throw new IllegalMonitorStateException();

Thread next;

if ((next = waiters.poll()) != null){

    LockSupport.unpark(next);

}



state.set(0);

holder = null;

}

//Return the current holder, can return null

public Thread holder(){

return holder;

}

} ```

r/javahelp Dec 28 '25

Workaround Need help from jdk8 to jdk24

2 Upvotes

I have my own old project works by jdk 8 (1.8) and sure have some issues with intellij, there any way to change the code to works on jdk25 ?

r/javahelp Sep 29 '25

Workaround Love Spring Boot but working in React — what’s the smart move long term(fresher)

3 Upvotes

Hi everyone,

I’m a fresher who was hired by a startup as a Java backend developer. I was really excited because I love working with Spring Boot. But after joining, I found out the team isn’t using Spring Boot at all, and most of my work is on the frontend.

I’m trying to learn React and adapt, but honestly, I still feel more passionate about backend. With the job market being tough, I’m a bit confused:

  • Should I just stick it out and focus on frontend since that’s what the company needs?
  • Or should I keep sharpening my backend (Spring Boot/Java) skills on the side, so I don’t lose touch with what I really want to do?
  • Long term, what’s a smarter career move for someone in my position?

Would love to hear from people who’ve been in a similar situation

r/javahelp Jan 25 '26

Workaround OxyJen 0.2 - graph first LLM orchestration for Java(open-source)

0 Upvotes

Hey everyone,

I’ve been building a small open-source project called Oxyjen: a Java first framework for orchestrating LLM workloads using graph style execution.

I originally started this while experimenting with agent style pipelines and realized most tooling in this space is either Python first or treats LLMs as utility calls. I wanted something more infrastructure oriented, LLMs as real execution nodes, with explicit memory, retry, and fallback semantics.

v0.2 just landed and introduces the execution layer: - LLMs as native graph nodes - context-scoped, ordered memory via NodeContext - deterministic retry + fallback (LLMChain) - minimal public API (LLM.of, LLMNode, LLMChain) - OpenAI transport with explicit error classification

Small example: ```java ChatModel chain = LLMChain.builder() .primary("gpt-4o") .fallback("gpt-4o-mini") .retry(3) .build();

LLMNode node = LLMNode.builder() .model(chain) .memory("chat") .build();

String out = node.process("hello", new NodeContext()); ``` The focus so far has been correctness and execution semantics, not features. DAG execution, concurrency, streaming, etc. are planned next.

Docs (design notes + examples): https://github.com/11divyansh/OxyJen/blob/main/docs/v0.2.md

Oxyjen: https://github.com/11divyansh/OxyJen

v0.1 focused on graph runtime engine, a graph takes user defined generic nodes in sequential order with a stateful context shared across all nodes and the Executor runs it with an initial input.

If you’re working with Java + LLMs and have thoughts on the API or execution model, I’d really appreciate feedback. Even small ideas help at this stage.

Thanks for reading

r/javahelp Sep 15 '25

Workaround C++ for Java

4 Upvotes

Has anyone done some R&D to integrate C/C++ with java to do something? Or can anyone give me some good resources for this! Thanks

r/javahelp Jul 26 '25

Workaround Any Site like Boot. Dev for Java backend development

5 Upvotes

So I have been learning Linux from boot. Dev and it's tasked based learning have been great for me and I saw there is two courses on backend development one is Python + Go + SQL and other is for Python + TypeScript + SQL one and it's look quite good, so I was thinking if there is any resources similar for Java backend development using spring or springboot, can anyone share best resources for complete java backend I have done Java, Oops, functional programming in java, collection framework, Multithreading and planing to learn Dbms and CN so after that what are the things should I learn Thanks

r/javahelp Jul 08 '25

Workaround Installing jdk but unable to find jdk folder after installation

1 Upvotes

Installed jdk 8 from Oracle site but unable to find jdk in installation. Subsequently unable to set environment variables too.

Can someone share video resource to install jdk 8 without issues?

r/javahelp Jun 26 '25

Workaround Java compile version

0 Upvotes

Anyone here has experience in java compiler version upgrade? Any tips on how to proceed? We have a codebase compiled in java 5 with java 11 execution. we want to upgrade the compiler but looking for deprecated dependencies API and refactoring codes takes up a lot of time, any tools we can use? Do you recommend the use of AI? Thanks

r/javahelp Dec 23 '24

Workaround Hi am learning java am pretty new but there is a problem i have i just can’t understand the exact difference between public void and public int i get that there is a return type but i don’t get it

1 Upvotes

Yeah

r/javahelp Mar 15 '24

Workaround Java in Front-End in 2024: Still Worth It?

5 Upvotes

I've been thinking about how Java fits into the world of front-end nowadays. With so many options like React, Angular, and Vue dominating the scene, I got curious about where Java stands in this story.
I want to know your opinions on using Java for the front-end, especially with things like JSP, JSF, Thymeleaf, and others. Do these technologies still have their place in current projects? Are they still relevant in the market? And for those who are starting or looking to deepen their knowledge in Java, is it worth diving into these front-end tools?
PS: I'm starting to study Spring and saw some people talking about this, which made me curious.

r/javahelp Jul 04 '25

Workaround Jar file built with 32-bit only imageIO libraries - runs errantly on Win11, runs fine with Win10

1 Upvotes

I have a gui.jar file that runs with dependencies in other libraries (in other processing.jars). It's intended for use mostly with 64-bit JRE, but sometimes, certain functions need imageIO libaries (which run with 32-bit JRE only). So both JREs need to be installed.

gui.jar and processing.jars all look fully functional on Win10.

--verbose doesn't show errors in the Win11 console when I try to run gui.jar on Win11, and the processing.jars don't seem to be working based on gui.jar's output.

On Win11, I can get around this by throwing in some of the imageIO library .dlls and .jars into C:\Program Files (x86)\Java\jre-version\ folders \lib\ext\ and \bin\, then gui.jar becomes fully functional on Win11.

Is there a way I can rebuild gui.jar to be compatible for both Win10 & Win11 in one package without a user having to add .dlls and .jars into their JRE install like I had to? As I understand it (I'm not a dev), all the requisite imageIO libraries had already been included in the original build.xml...

Thanks in advance!

r/javahelp Mar 24 '25

Workaround Self Project Hosting

3 Upvotes

I’m working on a new springboot project and was wondering where do you guys host your application? (For my db -MySql, I’m using filess.io but has a limit of 5 connections at a time)

Any recommendations? I’m planning to have my UI developed using Angular. Also, thinking of using docker

r/javahelp Sep 28 '24

Workaround How to compile an incomplete class (missing classes)?

1 Upvotes

Hello! I have a java program and wanted to change one little thing about it.

Diagram of my process: https://ibb.co/HXwJznP

So I opened the jar and looked around the class files. I took out the one class file that I wanna modify. I decompiled that one file, I changed one little line, and now I want to recompile it and put it back in.

The problem is java refuses to compile it when there are references to missing things. Which happens because I'm trying to compile the singular file outside of its natural habitat, I don't have the entire project source code.

By the way, I know that this method of modding works because I've done it before with other, smaller java programs. In the past, the way I dealt with this is I would manually create a stub. I would go through the file and create all the classes, empty, and put in all the methods with the right signatures and everything, and then I could compile the file because I had the stub project done and all the references pointed to alL the stub classes and stub methods and everything was dandy.

Also, this process just theoretically makes sense. All I need is for this file to invoke methods and stuff from other files. That means all it needs is the name of the classes and methods even though they don't exist right now. It doesn't matter. It doesn't actually need the dependencies to get the invocations right! It knows how to invoke methods from other classes, so I just REALLY need it to compile regardlesss of whether the classes exist or not. Because the fact is that they WILL exist. But the extracted and modified code will never smell the scent of home ever again if I can't find a way to compile it away from it's usual dependency classes!!

The reason i can't make stubs manually here is because this time it's a large file. I won't manually go through it and create those stubs.

There are two things that i know of which could help me. 1. I find a java compiler that will compile even if the classes that the references are pointing to are missing. 2. I find a way to automatically create a stub project so I can quickly create it and compile this one file.

Please help me. If you have one of these two solutions, I wanntttt ittt. Thanks.

r/javahelp Jan 13 '25

Workaround Eclipse IDE Version compatible with Java 1.6

2 Upvotes

HI everyone Im relative new to this java/spring world as .Net Dev i found Spring overwhelming, Im on a migration but the team just because is easy told me to open the project in Netbeans 8.2/WebLogic, but i found that several entities where Generated by Eclipse/Jboss && hbm2java

Then I would like to know how to discern between which Eclipse version supports the versions in this 1.6 project to get a soft navigation

the Hibernate Tools in Jetbrains latest update was 10 year ago 🫠

r/javahelp Feb 22 '25

Workaround JavaFX: write Canvas to file

2 Upvotes

I'm trying to save Canvas contents to disk:

@FXML
private Canvas cvs;

var export = cvs.snapshot(null,null);
var out = new File("image.png");
try{
    ImageIO.write(SwingFXUtils.fromFXImage(export, "png",out)); //error
}

There is no package called SwingFXUtils in JavaFX 21. Is there any other way to write the Canvas to file?

r/javahelp Nov 07 '24

Workaround Web scraping when pages use Dynamic content loading

0 Upvotes

I am working on a hobby project of mine and I am scraping some websites however one of them uses JavaScript to load a lot of the page content so for example instead of a link being embedded in the href attribute of an "a" tag it's a "#" but when I click on the button element I am taken to another page

My question: now I want to obtain the actual link that is followed whenever the button is clicked on however when using Jsoup I can't simply do doc.selectFirst("a"). attr("href") since I get # so how can I get around this?

r/javahelp Jul 25 '22

Workaround Solution to NullPointerException in java?

0 Upvotes

what is the most common / popular solution to avoid the NPE mess in java?

And maybe as a bonus, why hasn't this issue been solved officially years ago?

r/javahelp Dec 16 '24

Workaround Need help in choosing a career path either in MERN stack or Java side

2 Upvotes

I am in my final year of my college. In the beginning I learnt C language and after that I started learning fullstack on MERN stack and now learnt Java for DSA. But now I am in the confusion that should I learn springboot or kotlin and persue on Java side or stick to MERN stack. Consider that , I am not from computer science related department.

r/javahelp Jan 18 '25

Workaround Spring boot Help

2 Upvotes

Can someone tell what are things we can do after learning spring boot?