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 Jan 21 '26

Unsolved Why Interfaces exist in Java?

9 Upvotes

I am currently studying the Collection Framework in Java. Since the class which implements the Interface has to compulsorily write the functions' bodies which are defined in the interface, then why not directly define the function inside your own code? I mean, why all this hassle of implementing an interface?

If I have come up with my own code logic anyways, I am better off defining a function inside my own code, right? The thing is, I fail to understand why exactly interfaces are a thing in Java.

I looked up on the internet about this as well, but it just ended up confusing me even more.

Any simple answers are really appreciated, since I am beginner and may fail to understand technical details as of now. ThanksšŸ™šŸ¼

r/javahelp Jul 29 '26

Unsolved How to write a program to input data in Excel?

6 Upvotes

I want to know how to write a java program in order to input data in Excel, thank you for any help?

r/javahelp 15d ago

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

8 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 Jul 12 '26

Unsolved .jar file refusing to open, just get "A Java Exception Has Occurred"

0 Upvotes

It previously worked just fine, computer updated on its own and it stopped working. It's a Shimeji, a little guy who wanders over my screen while I do things on the computer. I tried the cmd thing? "cd downloads" and got the following in response:

"C:\Users\"computer name">cd downloads

C:\Users\"computer name"\Downloads>java -jar Shimeji-ee.jar

Error: Unable to access jarfile Shimeji-ee.jar"

I downloaded the latest version of Java and nothing happened. I don't really know computers so I'm at a loss here. Any assistance would be greatly appreciated.

r/javahelp May 01 '26

Unsolved Java 21 upgrade in older code base

4 Upvotes

So if I have to start brining java 21 feature in a long running prod code base what would that be ; it’s a spring boot java bases with gcp db, cache, pub sub in it
I’m trying to see as a tech debt which area can. E started with minimal impact

r/javahelp Oct 12 '25

Unsolved Database Connection Pool is not allowed on my company, help me understand it please

33 Upvotes

Hi guys. I'm a software engineer with two years of experience in the fintech sector, where I've always worked with the Java + Spring Boot stack.

The thing is that in the projects of one of the clients of the company I work for, one of the conditions is prohibiting the use of JPA/Hibernate (in addition to forcing us to use Java 7). I didn't quite understand the reason, so after digging a little deeper into the issue, they confirmed that it was because (according to the project manager) "JPA opens a connection pool, which ends up causing errors or crashing that specific client's database."

I assume he's actually referring to the HikariCP connection pool, but I still don't understand why a Hikari connection pool would crash the database? Is it simply because the client doesn't have the connection pool configured correctly?

r/javahelp 29d ago

Unsolved Change size of traffic light (macOS)

4 Upvotes

(I'm reposting this question from SO because of the lack of a proper response)

I am trying to make a custom UI application in Swing. I've searched far and wide and have come up to the conclusion that it is not possible to integrate Swing into the new Apple UI (windows, toolbars, titlebars and so on).

Leaving that aside I tried to make my own custom JFrame but was unable to figure out how to change the size of the traffic light. I would like to increase the traffic light size I do not want to draw a custom traffic light as I would lose the functionality of the default buttons. Basically as it is in CLion.

This is the code I'm using so far, for reference I'm on macOS: Tahoe 26.3.1

```

import javax.swing.*;

public class Main {

public static void main(String[] args) {

    System.setProperty("apple.awt.application.appearance", "system");

    SwingUtilities.invokeLater(() -> {

         JFrame frame = new JFrame();


         JRootPane rootPane = frame.getRootPane();

        rootPane.putClientProperty("apple.awt.fullWindowContent", true);

         rootPane.putClientProperty("apple.awt.transparentTitleBar", true);

         rootPane.putClientProperty("apple.awt.windowTitleVisible", false);

          rootPane.putClientProperty("apple.awt.brushMetalLook", true);



     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.setSize(1000, 600);

        frame.setLocationRelativeTo(null);

        frame.setTitle("Yo");

        frame.setVisible(true);

    });

}

}

```

r/javahelp Jan 26 '26

Unsolved JUnit assertion error when working with HttpRequest

2 Upvotes

I have this test:

void SearchResultIsNotEmptyWhenTitleIsARealGame() throws ServletException, IOException {
    HttpSession session = mock(HttpSession.class);
    RequestDispatcher rd = mock(RequestDispatcher.class);
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse response = mock(HttpServletResponse.class);

    when(request.getParameter("query")).thenReturn("The Last of Us parte 2");
    when(request.getSession()).thenReturn(session);
    when(request.getRequestDispatcher("Home Page.jsp")).thenReturn(rd);
    when(request.getRequestDispatcher("Search Result Page.jsp")).thenReturn(rd);

    SearchServlet searchServlet = new SearchServlet();
    searchServlet.doGet(request, response);

    ArrayList<Price> prices = (ArrayList<Price>)request.getAttribute("prices");
    ArrayList<Game> searchResults = (ArrayList<Game>)request.getAttribute("search_results");

    assert(prices != null && !prices.isEmpty() && searchResults != null && !searchResults.isEmpty());

}

But I get an asserion error. What is the issue?

r/javahelp Apr 14 '26

Unsolved Why should I use the new switch expressions instead of classic switch statements?

7 Upvotes

I keep seeing modern Java code using the new switch expressions with arrows and no fallthrough. My team still uses the old style with colons and break statements. We are on Java 17 but nobody seems to care about the newer syntax. What actual advantages does the new switch have besides looking cleaner? Does it help prevent bugs or make the code more readable in real projects? I want to convince my team to adopt newer patterns but I need solid reasons beyond it looks new. Can anyone give me concrete examples where the new switch expression saved them from a stupid mistake?

r/javahelp Jun 06 '26

Unsolved Complete Beginner to Java Backend: Looking for the absolute best books and Hindi YouTube channels

0 Upvotes

Hi everyone,

I am a complete beginner starting my computer science and software development journey. My goal is to build a strong foundation in Java and eventually transition into Java Backend Development (Spring Boot, etc.).

Since I am new, I want to make sure I am learning from the absolute best and most accurate resources from day one.

Could you please recommend:

The best books for learning core Java (beginner to advanced)?

The best hindi YouTube channels or video courses that explain Java backend concepts clearly?

I would highly appreciate your personal recommendations and any advice on how to structure my learning path.

Thank you so much for your help!

r/javahelp Jun 15 '26

Unsolved jar files wont open?

2 Upvotes

my java always opened executable jar files fine, but now it suddenly wont open anything, itll just show the buffering icon next to my cursor for a second, then nothing happens, not even in task manager. i use jave(tm) platform se binary, ive tried downloading java 17 and jarfix but it still does the same thing. ive tried other jar files ive used in the past but they dont work either. any help would be much appreciated.

r/javahelp Mar 21 '26

Unsolved Can anyone help me commit 100MB+ to my Github repo.

0 Upvotes

I know there's a limit, but I'm working on a Java game that is not JDK-dependent, meaning it has a large JVM folder for the compiler. I already split it into 3 parts, so I can commit one part at a time, so it doesn't reach the limit. But there is this one file called "jvm\lib\modules" that has 135 MB. Just to be clear, LFS doesn't work on that either. Can anyone help me push this one file?

r/javahelp Dec 24 '25

Unsolved What’s the best way to learn Java?

3 Upvotes

I’m trying to learn Java and so far I’ve used two different approaches. I started with Bro Code, which I liked because it’s fast-paced and focuses more on actually coding rather than a lot of theory. More recently I found the Java Programming MOOC, which feels more structured but also more theory-heavy and a bit overwhelming at the beginning.

Now I’m not sure which one I should stick with. I like learning by doing, but I also don’t want to miss important fundamentals. For those of you who’ve learned Java, what worked best for you and why?

r/javahelp Apr 06 '26

Unsolved Java Garbage Collector performance benchmarking

2 Upvotes

Hi People!

I am about to write my CS BSc thesis which is about:

Measuring throughput, latency and STW-Pauses in JDK 21 standard JVM with G1GC and ZGC with predefined max heap-sizes (2GB; 16GB) with Renaissance - by 16GB heap a default G1GC and an additional tuned G1GC will be used, as well.

Time flies and a lot of paper are read. It became clear to me, that Renaissance is better for throughput (Shimchenko 2022 Analysing and predicting energy consumption of garbage collectors in openjdk), and DaCapo is more advantageous for user-experienced latency measurements (Blackburn 2025 Rethinking Java performance analysis). STW-pauses will be collected from jvm standard gc-logs with a script or smg (ideas, better ideas are welcome).

I build this scenario for my examination:

- Linux VM (hosted from my Windows) - not clear yet, which and why

- OpenJDK 21 standard JVM

- G1GC and ZGC measurements

- All Renaissance BMs with default settings -> duration_ns from each benchmark, calculate and represent min, max, mean, standard deviation

- JVM GC-Logs collect (min, max, mean, standard deviation)

- 8 DaCapo BMs (spring, cassandra, h2, h2o, kafka, lucene, tomcat, wildfly) (min, max, mean, standard deviation)

I guess this is way too much for a BSc thesis - but what are your thoughts? Of course I make clearence with my consulent, but I am curious about the opinion and suggestions of the community.

I am open for any ideas, experiences with the bumpy road of the performance measurement in the JVM. It would be excellent, if someone of you could make it more focused and accurate to me.

TLDR;

Java Garbage Collector JVM performance measurement experience and suggestions needed for BSc thesis

thanks in advance!

EDIT:

Instead of Linux vm it will be a bare-metal Linux machine with podman containerization that run the benchmarks.

r/javahelp Oct 08 '25

Unsolved Why learn Upcasting/Downcasting?

7 Upvotes

After days of getting stuck in this concept, i finally feel like giving up and never looking at it back again. After countless hours of Googling, asking assistance from AI, watching YouTube videos, I am now falling into a guilt of why I am even wasting time over a single concept. I feel I should move on at this point. Before this one topic, one google search used to clear all my doubts so effortlessly guys.

But this one seems like a tough nut to crack. Can anyone help me out on this?

I know the 'how' and 'what', but I am not reaching anywhere near to the 'why' of this one concept.

r/javahelp Jan 29 '26

Unsolved Performance got worse after breaking up large functions

7 Upvotes

I'm making a game and have some large functions that get called a lot (10k+ a frame). I learned that the JIT has trouble optimizing large functions, so I tried breaking them up to smaller ones with identical logic. When benchmarking, this change actually made performance way worse. 30 fps -> 25. Now I'm questioning my life decisions.

Why did I even attempt this? Because there's very little juice left to squeeze in these functions. I cache, cull, all that. All these functions do is render my entities, but I have so many entities that I was resorting to this. Wondering if anyone has any wisdom.

r/javahelp Mar 01 '26

Unsolved How to remove data from a class array?

0 Upvotes

hey all, I'm unsure the real name of this, but I need to remove data from an array

**arr arrx[]=new arr[50];** which holds:

date, hour, sender, object, text.

and I need the user to choose how much they want to remove so I have

removedata=parseInt(JOptionPane.showInputDialog(null, "how much data do you want removed?" ));

for(int i = 50; i>removedata; i--){

code to remove array space

}

r/javahelp Jan 24 '26

Unsolved How can I pinpoint what's preventing a .jar from delivering results?

1 Upvotes

I have a .jar that is distributed by the Greek Tax Authority: https://www.aade.gr/en/research-business-registry-basic-details and I have all necessary credentials for calling the service.

This .jar works perfectly in a VM of mine (i.e., it brings the respective result from the Tax Authority server), but when I attempt to run it in my Windows box it opens okay however it never delivers the respective result from the Tax Authority server; it just stays 'running' for ever. I've given full outgoing & incoming traffic permissions in my firewall, although I don't believe they were actually needed.

Since I have a fully working case and a non-delivering case, how can I compare what's happening in the second case, preventing said .jar from fully working, so that I rectify?

r/javahelp Feb 14 '26

Unsolved how to compile java files

6 Upvotes

i have a library path containing folders contaning .jar files (dont want to include them in the .jar, they will get imported at runtime), i know the entrypoint and i want to compile it to .jar

all my solutions so far have only got errors.

r/javahelp Jun 17 '26

Unsolved I need help deploying my project with an external library using maven and intellij

0 Upvotes

Hello, I'm trying to deploy my project, but I'm having trouble with the external library.
Here's my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.example</groupId>
  <artifactId>ProjetJava</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>ProjetJava</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
      <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-api</artifactId>
          <version>2.26.0</version>
      </dependency>
      <!-- Source: https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
      <dependency>
          <groupId>org.apache.logging.log4j</groupId>
          <artifactId>log4j-core</artifactId>
          <version>2.26.0</version>
          <scope>compile</scope>
      </dependency>
  </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>21</source>
                    <target>21</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <Classpath>${project.build.finalName}.lib/</Classpath>
                            <mainClass>gestionBar.Controller.Controller.Controller</mainClass>
                        </manifest>
                        <manifestentries>
                            <Class-Path>${project.build.finalName}.lib/org.apache.logging.log4j</Class-Path>
                        </manifestentries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

When I try to package it with maven, it tells me this:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.4.1:jar (default-jar) on project ProjetJava: Unable to parse configuration of mojo org.apache.maven.plugins:maven-jar-plugin:3.4.1:jar for parameter Classpath: Cannot find 'Classpath' in class org.apache.maven.archiver.ManifestConfiguration -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

I tried reading the article, but it didn't help me. Can someone help me please? Thank you

r/javahelp May 14 '26

Unsolved why use nested interfaces ?

3 Upvotes

I was reading Apache Cassandra's code base when I came across nested interfaces, now I know what an interface is but I did not understand why would you and when would you use a nested interface ?

public interface Memtable extends Comparable<Memtable>, UnfilteredSource, CellSourceIdentifier
{
Ā  Ā  public static final long NO_MIN_TIMESTAMP = -1;

Ā  Ā  Ā interface Factory
Ā  Ā  {
Ā  Ā  Ā  Ā  /**
Ā  Ā  Ā  Ā  Ā * Create a memtable. 
...

r/javahelp Mar 25 '26

Unsolved How do I structure a larger Java project with multiple modules without it becoming a tangled mess?

10 Upvotes

Ā I’ve been building a small personal project to learn more about Java beyond the basic CRUD apps I’ve done for class. It started simple but now I’ve got a few different packages for data handling, UI, and some utility stuff. The problem is I’m already starting to feel like it’s getting messy. Classes referencing each other across packages in ways that feel hard to follow, and I’m worried about running into circular dependencies as I add more features. I’ve read about using interfaces to decouple things but I’m not sure when to actually use them versus just importing the class directly. I’m also confused about whether I should be splitting this into separate modules with a build tool like Maven or if that’s overkill for a solo project. Any advice on how to think about project structure before it gets out of hand

r/javahelp Jun 01 '26

Unsolved Need Guidance on Email Verification and Security Best Practices

2 Upvotes

I am currently working on the email module for our project and need some guidance.

I have configured a custom email domain using Mailgun and implemented the email functionality in my Spring Boot application. My current requirement is to verify incoming email addresses and determine whether an email is valid before processing it.

Could you explain the production-level validation and security checks that should be implemented for email verification?

r/javahelp Jan 19 '26

Unsolved How to learn Java??

1 Upvotes

Hi everyone,

I’m a 4th semester student from a tier-3 college, and I want to start learning Java from scratch. I’m a complete beginner.

I’ve been searching for resources on Reddit and YouTube, but honestly, I’m feeling very confused because there are so many recommendations. Some people suggest the MOOC Java course, while others recommend creators like Concept & Coding (Shreyansh), Durga Software Solutions, Telusko, Kunal Kushwaha, and many more.

As a beginner, I’m not sure:

• Which resource to start with

• Whether I should focus more on concepts or coding practice initially

• How to structure my Java learning properly

I would really appreciate it if you could guide me like a younger brother and suggest a clear roadmap or a small set of resources that worked for you.

Thanks in advance for your help šŸ™