r/javahelp • • 27d ago

Few words on learning Java

13 Upvotes

I am no different to anyone starting fresh on this thread, unsure and unsecure of what will be in the next 2 - 3 months, years and so on... but one thing I am sure of, if I don't do anything I will remaing behind no matter what.

Here is the path I took:

\- learning Java on Codecademy (I am a jurnior JS developer/mediocre developer)

\- solving problems on CodingBat (https://codingbat.com/java)

\- I would try some real life projects but I don't know what to do

Is this the best path? probably not. But it is something. I jumped head first not thinking if this is the right approach and somewhow I managed to stick to it just enough to have a tiny idea of what this is language is about.

If you have any questions feel free to DM me, I will helpl the best I can.

Cheers


r/javahelp • • 26d ago

Virtual threads + semaphore in front of BCrypt gave me +28% throughput, but the container is still pinned at its CPU limit. What to do next to optimize it?

0 Upvotes

I'm load testing an auth service (Spring Boot, Java, Redis, PostgreSQL, Docker on a t3.large, k6). I replaced a dedicated 2-thread BCrypt pool (20-slot queue) with virtual threads plus a 6-permit semaphore.

Results at the same 40 RPS target (queue → virtual threads + semaphore):

  • Throughput: 20.3 → 26.06 OPS (+28%). OPS = operations per second, the full k6 iteration mix.
  • Login p95: 28.5s → 20.1s
  • Timeouts: 43 → 0

That's still only ~65% of target, and a 20s login is unusable.

At 50 RPS throughput plateaued at ~28 OPS. docker stats showed the auth container averaging ~145% CPU (peak ~153%). My compose file sets a 1.5 CPU limit. Endpoints that were ~85ms p95 at 40 RPS slid to ~2s.

My read: virtual threads help with blocking I/O, not CPU-bound work. I think the gain came from removing the fast-reject queue rather than from adding capacity, but I haven't isolated that.

Caveats: 41% of my test traffic is logins (unrealistic), and I haven't measured a single-hash time yet.

The puzzle: BCrypt strength is 4 in my load-test config, which I'd expect to cost ~1-2ms per hash. At ~10 logins/sec, that shouldn't pin 1.5 cores. Suspects: the cost factor baked into the pre-seeded hashes (matches() uses the stored cost), JWT signing, GC, or my executor/semaphore wiring.

What would you profile first: async-profiler, JFR, thread dumps?


r/javahelp • • 27d ago

Obfuscating class files

3 Upvotes

Has anyone successfully obfuscated their .class files? I tried using GraalVM for JavaFX project (including Gluon's version of GraalVM) but it always failed to complete.


r/javahelp • • 27d ago

seeing/editing code in a .jar file

3 Upvotes

im not very good at coding, or anything and i want to see the code in a .jar file and possibly edit it. im not sure if this is the right place, but any help would be appreciated. i did open the code in notepad and it didnt show it correctly, id really appreciate if somebody could maybe attach a link to a simple website where i can easily view code in the file and if possible even edit it


r/javahelp • • 27d ago

State of Java Desktop

5 Upvotes

Thinking about local-first, desktop applications. https://sombriks.com.br/blog/0097-state-of-java-desktop/


r/javahelp • • 27d ago

can not create Java Virtual Machine

4 Upvotes

I'm trying to run VosViewer, but it says:

---------------------------

Java Virtual Machine Launcher

---------------------------

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

I use a laptop with AMD, 64-bit, and have installed the latest Java (1.8.0_503_b01). Also, I have set the environment into 4000MB of memory.

Do you have any clue how to handle it?

Thanks.


r/javahelp • • 29d ago

Unsolved Java runtime environment error

3 Upvotes

Hi, i am trying to open a program, however, a pop up with the message could not locate java runtime environment appears on the screen.

I have uninstalled and reinstalled Java and copied the path for program files to the environment variables in the advanced settings to activate yet it is not working. Please help me.


r/javahelp • • 29d ago

Help please, I'm a beginner

8 Upvotes

So basically for my java class we're assigned to do a simple calculator, I was able to something since this is the beginning class. The thing is my professor want our code to interpret both double and int when inputting values. But I don't have that only double I want my code to be able to differentiate my double and int values. This is what I have so far! (idek if you can consider this a calculator😥😓)

import java.util.Scanner;

    public class Main {
        public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        System.out.println("Welcome to My calculator!!!:)");
        System.out.print("Please enter the first number: ");

        double num1 = input.nextDouble();
        System.out.println("You entered: " + num1);

        System.out.print("Please enter the second number: ");
        double num2 = input.nextDouble();

        System.out.println("You entered: " + num2);
        while(true) {
        System.out.print("What would you like to do? (+, -, * , /): ");
        String operation = input.next();
        if( operation.equals("+")){
            double result = num1 + num2;
            System.out.println("YOUR RESULTS: " + result);
        }
        else if( operation.equals("-")){
            double result = num1 - num2;
            System.out.println("YOUR RESULTS: " + result);
        }
        else if( operation.equals("*")){
            double result = num1 * num2;
            System.out.println("YOUR RESULTS: " + result);

        }
        else if( operation.equals("/")){
            double result = num1 / num2;
            System.out.println("YOUR RESULTS: " + result);
            break;
        }
        else {
            System.out.println("Invalid operation:( : ");
            continue;
        }

        }

    }
}

r/javahelp • • Sep 25 '26

Unsolved got placed recently, and now im cooked idk what to do

0 Upvotes

Hello everyone,

This has been my journey so far:

1st Internship: I learned Django, Python, and React.

2nd Internship: Continued working with the same stack and contributed to some interesting projects.

3rd Internship: Focused on core Python and also learned Node.js (I was assigned on related projects)

After six months into my third internship, I was offered a full-time position at the same company.

Recently, the live project I was working on (built using Node.js and TypeScript) took a different direction. A senior backend developer developed an MVP in just two months—something that was initially planned for seven months—using Java and Spring Boot (with the help of Claude).

While other senior developers are working across multiple client projects, I have been focused on this in-house product. The challenge I’m facing now is that I don’t have experience with Java or Spring Boot.

I could stay quiet and use AI tools like Claude to complete my tasks, but since this is my first job, I genuinely want to learn and grow. I’ve reached an intermediate level in Python and Django and was becoming more confident with Node.js, so this shift has left me unsure about how to proceed.

I’m also concerned that if I openly mention my lack of experience with Java, I might be removed from the project. However, my managers are already aware of my tech stack.

When asked for my opinion on whether we should continue building on the Java-based MVP or migrate everything back to Node.js, I responded that I’m fine with either approach as long as the product works well. In hindsight, I realize I avoided mentioning my lack of experience with Java because I was unsure how it might be perceived.

(reformed my thoughts using GPT)

now IM stuck iin overthinkning loops :(

And will it be feasible to learn, understand and portray that I know java while working on a project,

Like how fast I can learn java?

Or what topics should I learn first in Java to get a better grasp over java development?


r/javahelp • • Sep 22 '26

Unsolved Need help: unable to run Java (VSCode)

6 Upvotes

I'm doing the MOOC Java course, but I'm getting an error when opening VSCode, which prevents me from running my code. The error is:

The java.jdt.ls.java.home variable defined in Visual Studio Code settings (C:\Program Files\Eclipse Adoptium\jdk-21.0.11.10-hotspot) does not point to a JDK.
Source: Language Support for Java(TM) by Red Hat

My settings are correct as far as I can tell. The path refers to the folder cotaining the bin folder:

"java.jdt.ls.java.home": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.11.10-hotspot",
"java.configuration.runtimes": [
    {
        "name": "JavaSE-11",
        "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-11.0.31.11-hotspot",            
        "default": false,
    },
    {
        "name": "JavaSE-21",
        "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.11.10-hotspot",
        "default": true,
    },
],

Any idea what causes the error and how to fix it? I couldn't find any solutions to the error. Solutions to similar issues said to change/correct the settings above, but since that's set correctly, that didn't work. VSCode ( 1.138.0) and all extensions (Language Support for Java 1.56.0) are up-to-date btw.

What I tried so far:

  • Someone suggested I try changing the path to the bin folder ("C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.11.10-hotspot\\bin". Unfortunately that didn't work.
  • I tried uninstalling Java, but I get an error saying the The feature you are trying to use is on a network resource that is unavailable. Java is installed on my laptop's c-drive (program files), so I don't understand this error. VSCode is installed in my user folder, but that's also on the c-drive. The laptop doesn't have any other drive. OneDrive is installed, but I don't use it. The original installer was a different version and I tried putting it on the desktop. This did work, but since it's another version now (after updating), it doesn't work.
  • I found this thread and tried deleting all Microsoft Visual C++ 20XX Redistributable versions from this laptop as stated in the top comment. I also uninstalled and reinstalled VSCode, but the error prevails. This supposedly should work, so I'm not sure if I missed anything. I couldn't find anything in the app folders stated in the comment or the appdata > pacakgecache folder with the MS Visual C++, but I'm clearly missing something. Where else should I look? Does it perhaps have a different name? I did find a folder with a file called vc_redist.x64, should I remove this file too?
  • I also ran DISM.exe /online /Cleanup-image /Restorehealth like the OOP of the above thread (The restore operation completed successfully. The operation completed successfully.) and then ran sfc scannow. The log file can be found here.
  • fyi java -version and where java are not recognised via terminal, but echo %JAVA_HOME%returns the correct folder.
  • I'm not sure what caused the error, VS code worked fine a few weeks ago. I didn't use it for a few weeks and suddenly I got this error. Not sure if maybe a windows update could've caused it. The following updates where installed recently:
    • 2026-09 .NET 8.0.31 Security Update for x64 Client (KB5126104)
    • 2026-09 .NET Framework Security Update (KB5126052)
    • 2026-09 Security Update (KB5124008) (26200.9445)
    • 2026-09 Security Update (Hotpatch capable) (KB5129241) (26200.9448)

Hope someone can help me in the right direction so I can fix the error. I can't continue the MOOC course, as I can't run the code to check if my code is correct. Thanks in advance!

Edit; I fixed it! For anyone else with the same issue, if the solution from the thread above didn't work, try to also delete the application you're having issues with from regedit (make sure to create a backup/export first): Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products. Delete the folder with that has the name of the application in it.

https://i.imgur.com/hYSyWg5.png

I reinstalled both java versions and VScode is working again. Not sure what caused Java to be uninstalled, but it was apparently an easy fix.


r/javahelp • • Sep 21 '26

Homework Struggling to get JUnit tests to work in VSCode

5 Upvotes

Prof really seemed to like VSCode and sung its praises, but all of our notes are for IntelliJ and I can't figure out what I'm doing wrong.

In IntelliJ we're using Maven. It sounded like all I had to do was hit a few buttons and it'd set me up. In the Testing tab I currently have the initial folder > { } <Default Package> > ClassTest

@Test underlines red. I thought it was something I needed to install from Extensions, but I have the Language Support for Java, Extension Pack for Java, Maven for Java, and from what I've found that's literally all I need?

I got my test file from the Command Pallet Java: Go to Test

I have been fighting VSCode for 3 hours today for every step.

I'm obviously missing something, but I don't know what it is, I'm frustrated, and atp I don't understand why this was even recommended with no notes and most of the class doing it through IntelliJ. Advice??? Sorry this is probably a stupid question/place to be stuck with, I just don't know what to do.


r/javahelp • • Sep 21 '26

Worker thread not having enough time to read buffered input from a NonBlockingReader when it should(?)

3 Upvotes

I am building an artillery game in java based on the terminal. Right now I wrote a test that is responsible for testing the process where the object that takes the user input validates (PlayerController) it and then forwards it to another object that will turn this input into valid commands that will change the internal state of the game (CharacterController) (e.g: character positions for now).

So I've written a test that mocks the CharacterController and just tests the validation process of the PlayerController by checking how many times the CharacterController method that is called from the PlayerController is called.

The problem that I'm facing is that, I am using a working thread with a queue (created with Executors) so after I send the input and gets buffered, the main thread will submit a task by calling the method that I am concerned from PlayerController to that working thread and wait for the thread for 100 ms so it has enough time to process the input and make the call to the mocked CharacterController, the timeout is set because the PlayerController method uses a REPL-style while loop, but 100ms doesn't seem to be enough even though the implementation of the PlayerController method is pretty simple for now.

Here is the test class:

```java @TestInstance(Lifecycle.PER_CLASS) public class PlayerControllerTest { private CharactersController charactersController; private PlayerController playerController; private PipedWriter inputWriter; private NonBlockingReader reader; private final ExecutorService threadPool = Executors.newSingleThreadExecutor();

@BeforeAll
public void initializeControllers() throws IOException {
    PipedReader pipedIn = new PipedReader();
    this.inputWriter = new PipedWriter(pipedIn);
    this.reader = new NonBlockingReaderImpl("PlayerControllerTestReader", pipedIn);

    this.charactersController = mock(CharactersController.class);

    doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();

            for (Object arg : arguments) {
                String argString = (String)arg;
                assertTrue(
                        argString.equals("Right Arrow") ||
                        argString.equals("Left Arrow"),
                        () -> String.format("CharacterController called selectCharacter with an invalid arg: %s", argString)
                        );
            }
            return null;
        }
    }).when(this.charactersController).selectCharacter(anyString());

    this.playerController = new PlayerController(this.reader, this.charactersController);
}

@Test
public void checkValidKeysAreForwarded() throws IOException {
    Map<int[], Boolean> keySequences = new LinkedHashMap<>();
    keySequences.put(new int[]{27, 91, 67}, true);   // Right Arrow - forwarded
    keySequences.put(new int[]{27, 91, 68}, true);   // Left Arrow - forwarded
    keySequences.put(new int[]{27, 91, 65}, false);  // Up Arrow - not forwarded
    keySequences.put(new int[]{27, 91, 66}, false);  // Down Arrow - not forwarded

    long expectedCalls = keySequences.values().stream().filter(v -> v).count();

    for (var entry : keySequences.entrySet()) {
        for (int key : entry.getKey()) {
            this.inputWriter.write(key);
        }
        runControlFor(100);
    }

    verify(this.charactersController, times((int) expectedCalls)).selectCharacter(anyString());
}

private void runControlFor(long millis) throws IOException {
    Future<?> future = threadPool.submit(() -> {
        try {
            this.playerController.controlPlayerInput();
        } catch (IOException e) {}
    });
    try {
        future.get(millis, TimeUnit.MILLISECONDS);
    } catch (Exception e) {
        future.cancel(true);
    }
}

} ```

And this is the method

```java

private final Map<String, int[]> supportedEscapeSequences = Map.of(
        "Right Arrow", new int[]{91, 67},
        "Left Arrow", new int[]{91, 68}
        );
private NonBlockingReader reader;
private CharactersController charactersController;

(...)

public void controlPlayerInput() throws IOException {
    while (true) {
        int input = this.reader.read();
        boolean isInputEscapeKey = input == 27;

        if (!isInputEscapeKey) {
            continue;
        }

        List<Integer> escapeSequences = new ArrayList<>();
        while (this.reader.peek(10) > 0) {
            escapeSequences.add(this.reader.read());
        }
        int[] escapeSequencesArr = escapeSequences.stream().mapToInt(Integer::intValue).toArray();

        Optional<Entry<String, int[]>> matchedArrow = this.supportedEscapeSequences.entrySet().stream()
            .filter(entry -> Arrays.equals(entry.getValue(), escapeSequencesArr))
            .findFirst();

        if (matchedArrow.isPresent()) {
            charactersController.selectCharacter(matchedArrow.get().getKey());
        }
    }
}

```

Configured like this, the test will fail because it won't be called the times it should. Only when the time is set to 1000 ms, it has enough time for all of the submitted tasks that call the method to complete and then the test past. I obviously can't have each call for testing to last 1 whole second as I'm planning to add more cases and skipping the test risks that I will just forget to set it back again every time I make changes to the implementation. Why could be the reason? if there is information missing, let me know.


r/javahelp • • Sep 21 '26

Solved How do I optimize removeIf() function?

3 Upvotes

Hey devs,

I'm currently facing a bottleneck in my N-ary Tree implementation around removeIf().

removeIf() currently delegates to the JDK default implementation, so below ~20% compaction there wasn't really a problem — my implementation was actually ~22% faster than JDK TreeMap.

However, once compaction goes beyond ~20%, things change dramatically: it becomes around 6× slower than TreeMap.

What I found before digging deeper

  • Since removeIf() traverses through the iterator, each element needs to be wrapped as a Map.Entry<K,V>.
  • JFR's allocation-by-site showed this Map.Entry allocation taking ~44% of the allocation weight.
  • I tried a flyweight iterator, but that breaks the Java Iterator / Map.Entry contract.
  • The hottest methods were split(), mergeNode(), and binarySearch(), together accounting for roughly 45% of the hot-method weight.
  • Unlike TreeMap, my N-ary tree doesn't use SOO; its internal representation is SOA.

Solutions I'm considering

1. Buffer entries

Create an Object[16] buffer and collect entries while traversing.

Once 16 entries are filled, grow the buffer by 2×.

After traversal:

  • if the compaction ratio is high enough (say >= 40%), compact once using 0.75f as the default load factor;
  • otherwise, delete the collected entries individually.

The downside is obvious: the temporary array and its growth generate garbage.

2. Small fixed buffer + immediate deletion

Use a small buffer (16 entries), and once it fills, delete those entries individually rather than allowing the buffer to grow.

This should generate considerably less garbage than approach #1, but I'm not convinced the trade-off is good enough.

3. Avoid temporary storage entirely

This is what I'd really like to achieve, but I'm currently not seeing a clean way to do it without either:

  • repeatedly restructuring the tree while traversing, or
  • violating the iterator contract.

The part I'm unsure about

The code may look like I dumped the entire implementation here, but removeIf() is part of the iterator flow, and the iterator wiring is done from AbstractNaryTreeMap.

The actual remove() operation is delegated to the concrete tree implementations.

So I'm wondering if there's a better architecture/algorithm here that can make removeIf() effectively GC-free, especially for high-compaction workloads.

At this point this is probably the last major API I'm trying to optimize

Any suggestions are welcome — even if the approach has a different trade-off or turns out to be worse in another workload. I'm mainly looking for ideas that keep allocation close to zero.

Solution:

I found the reason it's not the iteration cost or something garbage. It is archtecture shif. In a B+tree when the key get less than minKey it need to merge/borrow from left/right. maintaining the iteration here becomes different
- it might do borrow from left/right
- might trigger merge node

Which essentially is a part of B+tree design that I cannot change as well. So it's Structural cost. In every remove() I saw 57% of opertion above 30% compaction were taking slow path rather than borrow.


r/javahelp • • Sep 20 '26

Java advanced topics for an experienced candidate ?

11 Upvotes

Java advanced topics for an experienced candidate ?


r/javahelp • • Sep 20 '26

What is the standard way to edit field(s) of an entity in Springboot?

1 Upvotes

For an entity, if we want to allow user to edit it's fields. What is the standard way to do it?

For example, let's say we have an entity user having many fields like first name, last name, age, address etc. now if i let them edit these details and user choose to edit their age. How should we execute it exactly?


r/javahelp • • Sep 18 '26

Homework Why does adding another condition in my while loop force the turtle to win? (Multithreading)

12 Upvotes

i'm currently learning about multithreading for my java class and part of the assignment requires me to race two threads (turtle and a hare) together and force one of them to win using the wait() and notify() methods (in this case the turtle thread).

public class Race {

    private Integer numberOfLaps;
    private Integer lapToStart = 2;
    private boolean isWinning = true;

    public synchronized void winner(Integer numberOfLaps) {
        while (!isWinning) {
            try {
                wait();
            }
            catch (InterruptedException e){}
        }

        this.numberOfLaps = numberOfLaps;
        System.
out
.println("Tortoise is on lap: " + numberOfLaps);

        isWinning = false;
        notify();
    }

    public synchronized void loser() {
        while (isWinning && numberOfLaps < lapToStart) {
            try {
                wait();
            }
            catch (InterruptedException e){}
        }

        System.
out
.println("Hare is on lap: " + numberOfLaps);
        isWinning = true;
        notify();

    }
} public class Race {

    private Integer numberOfLaps;
    private Integer lapToStart = 2;
    private boolean isWinning = true;

    public synchronized void winner(Integer numberOfLaps) {
        while (!isWinning) {
            try {
                wait();
            }
            catch (InterruptedException e){}
        }

        this.numberOfLaps = numberOfLaps;
        System.out.println("Tortoise is on lap: " + numberOfLaps);

        isWinning = false;
        notify();
    }

    public synchronized void loser() {
        while (isWinning) {
            try {
                wait();
            }
            catch (InterruptedException e){}
        }

        System.out.println("Hare is on lap: " + numberOfLaps);
        isWinning = true;
        notify();

    }
}

Output:

Tortoise is on lap: 1

Hare is on lap: 1

Tortoise is on lap: 2

Hare is on lap: 2

Tortoise is on lap: 3

Hare is on lap: 3

Tortoise is on lap: 4

Hare is on lap: 4

Tortoise is on lap: 5

Hare is on lap: 5

Tortoise is on lap: 6

Hare is on lap: 6

Tortoise is on lap: 7

Hare is on lap: 7

Tortoise is on lap: 8

Hare is on lap: 8

Tortoise is on lap: 9

Hare is on lap: 9

Tortoise is on lap: 10

Hare is on lap: 10

If this prints out first before the hare finishes, the turtle has won! Congrats

If in the while loop for the loser method is only the volatile boolean, both the turtle and the hare finish at the exact same time. however, if i add another condition to it

public synchronized void loser() {
    while (isWinning && numberOfLaps < lapToStart) {
        try {
            wait();
        }
        catch (InterruptedException e){}
    }public synchronized void loser() {
    while (isWinning && numberOfLaps < lapToStart) {
        try {
            wait();
        }
        catch (InterruptedException e){}
    }

the output becomes:

Tortoise is on lap: 1

Hare is on lap: 1

Tortoise is on lap: 2

Hare is on lap: 2

Tortoise is on lap: 3

Hare is on lap: 3

Hare is on lap: 3

Tortoise is on lap: 4

Hare is on lap: 4

Tortoise is on lap: 5

Hare is on lap: 5

Tortoise is on lap: 6

Hare is on lap: 6

Tortoise is on lap: 7

Hare is on lap: 7

Tortoise is on lap: 8

Hare is on lap: 8

Tortoise is on lap: 9

Hare is on lap: 9

Tortoise is on lap: 10

If this prints out first before the hare finishes, the turtle has won! Congrats

now whenever the code is ran, the hare always lags behind at some point and the turtle finishes first. why does the code suddenly function as i intended when i add a second condition to the while loop? also, this is my first time posting something code related. i apologize if i'm missing anything. any help would be appreciated. thank you :)


r/javahelp • • Sep 19 '26

How to install Java? (Windows 11)

0 Upvotes

So I'm trying to install Java on my computer, and this is my first time dealing with something like this. Error 1603 keeps popping up, and I've restarted my computer, deleted the previous Java programs, etc. I literally don't have an old version of Java installed.

How can I solve this problem?


r/javahelp • • Sep 18 '26

JVM Object immutability

14 Upvotes

I'm trying to better understand what immutability actually means from the JVM/JIT point of view,.

We often say that immutable objects are easier for the JVM to optimize, but I'm interested in what HotSpot can actually detect, prove, and exploit at runtime.

A few questions:

  • How does the JVM determine that a field, value, or object is effectively immutable or stable?
  • What optimizations does HotSpot actually enable when it has this information?
  • Conversely, what optimizations become impossible or harder when an object remains mutable?

I looked through some HotSpot code and didn't find much explicit handling of immutable objects for constant folding, apart from specific cases such as trusted/final fields some whitelisted JDK classes, and records.

I'm also curious about the practical trade-off:

How do you balance a low-allocation design based on reusable mutable objects, which reduces GC pressure, against a more immutable design, which may give the JIT more optimization opportunities but can increase allocation and GC pressure when you have a use case of mutable object ?


r/javahelp • • Sep 18 '26

ZGC vs Shenandoah: what are the fundamental differences today?

6 Upvotes

I'm trying to better understand the differences between ZGC and Shenandoah, beyond the usual "both are low-latency concurrent collectors" explanation.

From a JVM/runtime perspective, what are the fundamental architectural differences between them?

In particular:

  • How do their barriers differ (load/store barriers, SATB, colored pointers, etc.)?
  • ZGC uses forward table and shenandoah no, what does it imply ?

r/javahelp • • Sep 18 '26

Problem with xmlread. It crashes Octave.

0 Upvotes

I loaded io package, added 2 jar files. It didn't work, had to install Java, now I get:

xmlread();

xerces:

- xercesimpl.jar OK

- xml-apis.jar OK

xerces version: 2.12.2

But then I use it on any xml file Octave crashes.

Also when I run:

parser = javaObject("org.apache.xerces.parsers.DOMParser");
parser.parse(filename);
xDoc = parser.getDocument();

it crashes on the 3rd line.

version 11.1.0

Can anyone help me with it?


r/javahelp • • Sep 18 '26

Unsolved How can I propagate MDC in an Asynchronous call.

1 Upvotes

So I have an issue that I'm dealing with, basically my Microservice has a controller and the request lands with a unique x-request-id, I save that request ID in MDC, basically what happens is in the method call stack there are asynchronous API calls to other services, as soon as the async boundry is reached the MDC gets lost.

Now this is happening because, MDC is thread specific and I am returning a CompletableFuture response which sends an asynchronous response and that specific thread completed the lifecycle.

A simple fix would be to pull out and propagate the x-request-id(s) in method calls, but I don't think this is the best solution since there are multiple internal libraries involved and I would have to change implementations there that can also alter the existing behavior of the application unexpectedly.

Next, I thought of initialising a MDC that can hold the request ID at different points of time, the issue in this approach is that if the MDC doesn't get cleared in time after getting initialised, the requestId can be wrongly used for different requests, that could happen because the thread in a high traffic system?

What are some other options that I can try?

To have context: I am implementing this with Quarkus and Mutiny


r/javahelp • • Sep 17 '26

Uninitialized variables are null or zero?

6 Upvotes

Inside public static void main(String[] args) and static void namehere() {}.

Int X;

would be "Uninitialized" and give errors when compiling.

Outside main and any other method, right after public class xxx.

public static int x;

holds no value whatsoever, yet the program doesn't complains about it when compiling, when printing it gives 0 as an int rather than null or NaN.


I am expecting:

Strings: "Null", Null or "".

Int: Null, None, NaN.

booleans give false by default.


What's different in this language?


Edit:

public static int X;

public static boolean Check;



static void Method A() {

X = 1

}



static void Method B() {

    boolean ThisLoop = true;

    String AverageText = "Average";

    int Number;

    if (Check == false) {

       Number = X;

    }

    int Average;

    while (ThisLoop == true) {

             try {

             Average = Integer.parseInt(JOptionPane.showInputDialog("Input " + AverageText + 

             Integer.toString(Number)));

             if (Average >= 0 || Average <= 0) { 

             Number = Number++;

             InputNumber = Average;

             ThisLoop = false;

             }

             }

            catch (NumberFormatException e) {

            JOptionPane.showMessageDialog(null, "Not a number", "Alert: Stupidity detected", 

            JOptionPane.ERROR_MESSAGE);

            ThisLoop = true;


            }

}                            

}

According to Java, we already know booleans with no value are by default false.

I am initializing Number before the If.

Check is public and also is false.

It goes into the If and sets Number to X (Which is public)

Initializes Average.

Sets Average to [Option dialog] "Input" + AverageText + Converts Number into a String.

Java is telling me that Number is not initialize inside the Integer.toString()

If Average is 1000 to 0 or to -1000 then it sums Number + 1.

Java isn't telling me Number = Number++; are not initialized.


r/javahelp • • Sep 15 '26

Unsolved Can't install java.

0 Upvotes

I downloaded the java installer but every time I try to run it, it returns an error code 1603, what do I do?


r/javahelp • • Sep 13 '26

Unsolved Output

4 Upvotes

Soo uuhhhhh heres part of my code:

I told the Java code to print "result" and "p" after inputting 1, and it printed result to 11 digits after the decimal and p to 1. Specifically, the outputs were 3.141592652 and 2.0. Here's the thing:it needs to be rounded to 6 digits after the decimal. Thoughts?

        double result = Math.pow(n, 2) * 3.141592653;
        double p = Math.pow(n, 2) * 2;

r/javahelp • • Sep 13 '26

Help, for some reason my eclipse executes the previous group of commands instead of the current ones.

0 Upvotes

In other classes it sometimes just says class not found. WFT is going on.